weldx.GenericSeries#
- class weldx.GenericSeries(obj, dims=None, coords=None, units=None, interpolation=None, parameters=None)#
Describes a quantity depending on one or more parameters.
Create a generic series.
- Parameters:
obj (
Quantity
|DataArray
|str
|MathematicalExpression
) – Either a multidimensional array of discrete values or aMathematicalExpression
with one or more variables. The expression can also be provided as string. In this case, you need to provide all parameters using the corresponding interface variable (see below).dims (
Union
[list
[str
],dict
[str
,str
],None
]) – For discrete data, a list is expected that provides the dimension names. The first name refers to the outer most dimension. If an expression is used, this parameter is optional. It can be used to have a dimension name that differs from the symbol of the expression. To do so, you need to provide a mapping between the symbol and the dimension name. For example, you could usedict(t="time")
to tell theweldx.GenericSeries
that the symbolt
refers to the dimensiontime
.coords (
Optional
[dict
[str
,list
|Quantity
]]) – (Only for discrete values) A mapping that specifies the coordinate values for each dimension.units (
Optional
[dict
[str
,str
|Unit
]]) – (Only for expressions) A mapping that specifies the expected unit for a free dimension/expression variable. During evaluation, it is not necessary that the provided data points have the exact same unit, but it must be a compatible unit. For example, if we usedict(t="s")
we can use minutes, hours or any other time unit fort
during evaluation, but using meters would cause an error.interpolation (
Optional
[str
]) – (Only for discrete values) The interpolating method that should be used during evaluation.parameters (
Optional
[dict
[str
,str
|Quantity
|DataArray
]]) – (Only for expressions) Parameters to set in the math expression.
- Raises:
TypeError – If
obj
is any other type than the ones defined in the type hints.KeyError – If one of the provided mappings refers to a symbol that is not part of the expression
ValueError – Can be raised for multiple reasons related to incompatible or invalid values
pint.DimensionalityError – If an expression can not be evaluated due to a unit conflict caused by the provided parameters and dimension units
Examples
Create a
weldx.GenericSeries
representing a translation with 3 m/s in x-direction starting at point[0, 2 ,2] cm
>>> from weldx import GenericSeries, Q_ >>> GenericSeries( ... "a*t + b", ... parameters=dict(a=Q_([3, 0, 0], "mm/s"), b=Q_([0, 2, 2], "cm")), ... units=dict(t="s"), ... ) <GenericSeries> Expression: a*t + b :param a = [3 0 0] mm / s: :param b = [0 2 2] cm:
- Free Dimensions:
t in s
- Other Dimensions:
[‘dim_0’]
- Units:
mm
The same
weldx.GenericSeries
from above but assigning thet
parameter to the output dimensiontime
.>>> GenericSeries( ... "a*t + b", ... parameters=dict(a=Q_([3, 0, 0], "mm/s"), b=Q_([0, 2, 2], "cm")), ... units=dict(t="s"), ... dims=dict(t="time"), ... ) <GenericSeries> Expression: a*t + b :param a = [3 0 0] mm / s: :param b = [0 2 2] cm:
- Free Dimensions:
t in s
- Other Dimensions:
[‘dim_0’]
- Units:
mm
A
weldx.GenericSeries
describing linear interpolation between the values 10 V and 20 V over a period of 5 seconds.>>> GenericSeries( ... Q_([10, 20], "V"), ... dims=["t"], ... coords={"t": Q_([0, 5], "s")}, ... ) <GenericSeries> Values: [10 20] Dimensions: ('t',) Coordinates: t = [0 5] s Units: V
Methods
Evaluate the generic series at discrete coordinates.
Interpolate using the coordinates of another object.
Attributes
Get the names of all coordinates.
Get the coordinates of the generic series.
Get the internal data.
Get the internal data as
xarray.DataArray
.Get the names of all dimensions.
Get the name of the used interpolation method.
Return
True
if the time series is described by discrete values.Return
True
if the time series is described by an expression.Get the number of dimensions.
Get the shape of the generic series data.
Get the units of the generic series data.
Get the names of all variables.
Get a dictionary that maps the variable names to their expected units.