Skip to content
Snippets Groups Projects

Make JPK files containing data in physical units convertable to sdf-force

Merged ikuhlem requested to merge handle_converted_jpkfiles into master
1 file
+ 14
17
Compare changes
  • Side-by-side
  • Inline
+ 14
17
@@ -277,29 +277,26 @@ def _parse_dataset(ds_sdf: sdf_object, channel_parameters: sdf_par,
def _extract_conversion_parameters(par: sdf_par) -> Tuple[float, float]:
conv_set = par['conversion-set']
# extract scaling parameters
if 'encoder' in par:
encoder = par['encoder']['scaling']
mult = float(encoder['multiplier'].value)
offs = float(encoder['offset'].value)
elif 'data' in par:
if 'encoder' in par['data']:
encoder = par['data']['encoder']['scaling']
mult = float(encoder['multiplier'].value)
offs = float(encoder['offset'].value)
else:
# no encoder parameters found.
# => data is already converted into physical data
mult = 1.0
offs = 0.0
scaling_parameters = par['encoder']['scaling']
elif 'data' in par and 'encoder' in par['data']:
scaling_parameters = par['data']['encoder']['scaling']
else:
scaling_parameters = None
# set initial multiplier and offset
if scaling_parameters is not None:
mult = float(scaling_parameters['multiplier'].value)
offs = float(scaling_parameters['offset'].value)
else:
# no encoder parameters found.
# => data is already converted into physical data
# no encoder parameters found => data is already converted into physical data
mult = 1.0
offs = 0.0
# apply conversions to multiplier and offset
conv_set = par['conversion-set']
conversions = _determine_conversions(conv_set)
for conv in conversions:
m = float(conv_set['conversion'][conv]['scaling']['multiplier'].value)
b = float(conv_set['conversion'][conv]['scaling']['offset'].value)
Loading