5. Measurement chains#
This tutorial covers:
MeasurementChain class that describes in detail how the experimental date was acquired
# download the example file for this tutorial from util import download_tutorial_input_file download_tutorial_input_file(print_status=False)
5.2. Plotting the measurement chain#
When working with experimental data we sometimes need more information than just the pure data itself. For example, we might want to know how large the measurement error can be or if the data has already been preprocessed before it was written to the file. Getting this information might be challenging because the person who conducted the experiment might be not available to you or the information is simply lost because nobody remembers and it hasn’t been documented.
WelDX solves this problem by enforcing that the experimental setup is actually documented and stored during the creation of a file. Therefore, it uses a dedicated data structure called the
Measurement. Let’s get it out of our example file and explore the information it provides.
As always, we get us a quick overview of the file content to find out how to access the data:
from weldx import WeldxFile wxfile = WeldxFile("single_pass_weld.wx")
root (dict) ├─TCP (LocalCoordinateSystem) ├─coordinate_systems (CoordinateSystemManager) ├─equipment (list) │ ├─ (MeasurementEquipment) │ ├─ (MeasurementEquipment) │ └─ (MeasurementEquipment) ├─measurements (list) │ ├─ (Measurement) │ ├─ (Measurement) │ ├─ (Measurement) │ └─ (Measurement) ├─process (dict) │ ├─shielding_gas (ShieldingGasForProcedure) │ ├─weld_speed (TimeSeries) │ ├─welding_process (GmawProcess) │ └─welding_wire (dict) │ ├─class (str) │ ├─diameter (Quantity) │ └─wx_user (dict) │ ├─charge id (str) │ └─manufacturer (str) ├─reference_timestamp (Timestamp) ├─welding_current (TimeSeries) ├─welding_voltage (TimeSeries) ├─workpiece (dict) │ ├─base_metal (dict) │ │ ├─common_name (str) │ │ └─standard (str) │ └─geometry (dict) │ ├─groove_shape (VGroove) │ └─seam_length (Quantity) └─wx_user (dict) ├─WID (int) ├─operator (str) └─project (str)
From the file content we see, that there actually multiple
Measurement objects stored under the key
"measurements". Let’s extract the list and print the names of all measurements by using the
name attribute of the
measurements = wxfile["measurements"] for measurement in measurements: print(measurement.name)
welding current welding voltage temperature T1 temperature T2
From the output we learn that there are a current, voltage and two temperature measurements. We will pick the current measurement for further discussion:
current_measurement = measurements
Measurement class is just a data container that stores the name of a measurement, the data that belongs to it, and a special class called
MeasurementChain documents the setup of a measurement and provides a complete overview of the different involved processing steps. Let’s extract it from the
current_measurement_chain = current_measurement.measurement_chain
The easiest way to get an overview of the
MeasurementChain is to call the
As you can see in the flow chart, we had an initial analog signal that was converted to a digital one by an AD converter. By applying the calibration, we finally got a digital signal that corresponds to the welding current. We only stored values after the last transformation step as measurement data.
The plot also shows us the formulas of the transformation step. Furthermore, the error percentage of the AD-conversion is shown.
5.3. Extracting the data#
get_signal_data function, we can extract the data from the
MeasurementChain. But this requires us to provide the name of the signal that was recorded. The signal name is equal to the preceding transformation or source name. We could deduce this from the plot, but another way is to use the
['AD current conversion', 'current calibration']
Because only the data after the calibration step was stored, we use
"current_calibration" as input to
current_data = current_measurement_chain.get_signal_data("current calibration")
The returned data is a
TimeSeries that was introduced in an earlier tutorial. We can simply call its
plot function to take a look at the data:
This tutorial demonstrated that WelDX provides a class called
MeasurementChain that captures not only the measurement data itself but also important meta data about how it was gathered. It has a useful visualization method that provides a quick overview over the experimental setup.