weldx.measurement.MeasurementChain.create_transformation#
- MeasurementChain.create_transformation(name, error, output_signal_type=None, output_signal_unit=None, func=None, data=None, input_signal_source=None)#
Create and add a transformation to the measurement chain.
- Parameters:
name (
str
) – Name of the transformationerror (
Error
) – The error of the transformationoutput_signal_type (
Optional
[str
]) – Type of the output signal (analog or digital)output_signal_unit (
Union
[str
,Unit
,None
]) – Unit of the output signal. If a function is provided, it is not necessary to provide this parameter since it can be derived from the function. In case both, the function and the unit are provided, an exception is raised if a mismatch is dimensionality is detected. This functionality may be used as extra safety layer. If no function is provided, a simple unit conversion function is created.func (
Optional
[MathematicalExpression
]) – A function describing the transformation. The provided value interacts with the ‘output_signal_unit’ parameter as described in its documentationdata (
Optional
[TimeSeries
]) – A set of measurement data that is associated with the output signal of the transformationinput_signal_source (
Optional
[str
]) – The source of the signal that should be used as input of the transformation. IfNone
is provided, the name of the last added transformation (or the source, if no transformation was added to the chain) is used.
Examples
>>> from weldx import Q_ >>> from weldx.core import MathematicalExpression >>> from weldx.measurement import Error, MeasurementChain, SignalTransformation
>>> mc = MeasurementChain.from_parameters( ... name="Current measurement chain", ... source_error=Error(deviation=Q_(0.5, "percent")), ... source_name="Current sensor", ... output_signal_type="analog", ... output_signal_unit="V" ... )
Create a mathematical expression that accepts a quantity with volts as unit and that returns a dimentsionless quantity.
>>> func = MathematicalExpression(expression="a*x + b", ... parameters=dict(a=Q_(5, "1/V"), b=Q_(1, "")) ... )
Use the mathematical expression to create a new transformation which also performs a analog-digital conversion.
>>> mc.create_transformation(name="Current AD conversion", ... error=Error(deviation=Q_(1,"percent")), ... func=func, ... output_signal_type="digital" ... )