weldx.core.SpatialSeries#

class weldx.core.SpatialSeries(obj, dims=None, coords=None, units=None, interpolation=None, parameters=None)#

Describes a line in 3d space depending on the positional coordinate s.

Create a generic series.

Parameters:
  • obj (Quantity | DataArray | str | MathematicalExpression) – Either a multidimensional array of discrete values or a MathematicalExpression 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 use dict(t="time") to tell the weldx.GenericSeries that the symbol t refers to the dimension time.

  • 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 use dict(t="s") we can use minutes, hours or any other time unit for t 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 the t parameter to the output dimension time.

>>> 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

Evaluate the generic series at discrete coordinates.

interp_like

Interpolate using the coordinates of another object.

Attributes

coordinate_names

Get the names of all coordinates.

coordinates

Get the coordinates of the generic series.

data

Get the internal data.

data_array

Get the internal data as xarray.DataArray.

dims

Get the names of all dimensions.

interpolation

Get the name of the used interpolation method.

is_discrete

Return True if the time series is described by discrete values.

is_expression

Return True if the time series is described by an expression.

ndims

Get the number of dimensions.

position_dim_name

Return the name of the dimension that determines the position on the line.

shape

Get the shape of the generic series data.

units

Get the units of the generic series data.

variable_names

Get the names of all variables.

variable_units

Get a dictionary that maps the variable names to their expected units.