xml_to_hdf5
When very large experimental files are generated from the biaxial testing machine, it is unable to export as raw
data. To alleviate this issue, the present module can read the raw xml file that the biaxial testing machine uses
internally to store the testing data. That file can be found in the test folder: e.g.
<TestName>/test_runs/<TestRunName>/Data/daqTaskActivity1.xml
- xml_to_hdf5.save_data(file, data, units, dtypes=None, global_attributes=None)[source]
Save data to hdf5 file for later use
- Parameters:
file (str) – Path to hdf file to save data to, excluding .hdf suffix
data (dict) – Data dictionary where each item is a numpy array
units (dict) – Dictionary with same keys as data, describing the units of the data
dtypes (dict) – Dictionary with the data types with which the data should be saved
global_attributes (dict) – Attributes to add the the top level
- xml_to_hdf5.get_data(file, max_lines=None, start_line=0)[source]
Get data from the biaxial machine’s raw xml file.
- Parameters:
file (str) – Path to xml file
max_lines (int) – Max “line number” (i.e. datapoints) to read from xml file. Defaults to None, meaning read until the end
start_line (int) – Which line (time step number) to start at. Useful to get data in parts for large files.
- Returns:
Dictionary with key based on names in the xml file and content as numpy arrays (float64) Dictionary with key based on names in the xml file and content strings with unit description
- Return type:
dict, dict
- xml_to_hdf5.get_name_and_unit(line)[source]
Get the name and unit of the given signal description. An example line is
<Signal Name="Running Time" InternalName="Running Time" Dimension="time" Unit="sec" />\n- Parameters:
line (str) – The line in the xml file
- Returns:
name, unit
- Return type:
str, str
- xml_to_hdf5.get_data_value(line, dtype)[source]
Get the data value from the line, an example line is
<Value>8.14404296875</Value>\n- Parameters:
line (str) – The line in the xml file
dtype (type) – The data type to convert to
- Returns:
The value in the requested data type
- Return type:
dtype
- xml_to_hdf5.reduce_data(raw_data, raw_units, save_disp=False, use_tcnt=False, sensor_dtype=<class 'numpy.float32'>, time_accuracy=0.0001, cnt_tol=0.1)[source]
Reduce the amount of data stored by
Choose appropriate datatypes for sensor values
Automatically determine datatype for time column
Not saving displacement/rotation values unless requested
Save only the indices when the counter changes
Join counters unless requested not to
- Parameters:
raw_data (dict) – The raw data read from the xml file
raw_units (dict) – The units corresponding to raw_data
save_disp (bool) – Should displacements and rotations be saved? Defaults to False
use_tcnt (bool) – Should the torsional counter be included as well?, Defaults to False
sensor_dtype (type) – Datatype for sensor values (load,strain and disp/rota)
time_accuracy (float) – The minimum time difference that should be stored accurately
cnt_tol (float) – The minimum counter change required to detect new count
- Returns:
(data, units, dtype) data: New dictionary with keys “forc”, “torq”, “astr”, “tstr”, “disp”, “rota”, “time”, [“cnt” or (“acnt”, “tcnt”)] whichever is available. Note that only the data in the counters are modified, otherwise no conversion from the machine data is performed. units: Unit strings (converted to ascii characters to avoid strange unicode issues) dtype: The datatype with which the data should be stored.
- Return type:
(dict, dict, dict)
- xml_to_hdf5.compensate(data, units, outer_diameter, tstr_sign=0)[source]
Compensate data wrt. units, stiffness and cross-talk.
- Parameters:
data – The data dictionary to be compensated (as returned from
reduce_data())units – Dictionary of units (as returned from
reduce_data())outer_diameter – The outer diameter of the test bar [mm]
tstr_sign – The sign with which to scale the torsional strain in relation to the torque. -1 if extensometer text upside down, 1 otherwise). If 0 (default), try to automatically detect by correlation with the torque.
- Returns:
The compensated data dictionary, adjusted units, attributes describing compensation
- Return type:
(dict, dict, dict)