How to work with torque data#
Be careful when working with torque. The unit Nm (Newton meter) is not a SI-unit but a product of N and m, so you need to use it in this way i.e. mind the space or provide a multiplipaction: “N m” or “N*m”. Here’s an example:
import h5rdmtoolbox as h5tbx
incorrect usage:
h5tbx.use('h5tbx')
with h5tbx.File() as h5:
h5.create_dataset('torque', data=[1,2, 3], units='Nm')
t = h5['torque'][:]
try: # check by converting to SI:
t.pint.quantify().pint.to('m^2/s^2*kg')
except Exception as e:
print(e)
Cannot convert variables:
incompatible units for variable 'torque': Cannot convert from 'number_meter' ([length] / [mass]) to 'meter ** 2 * kilogram / second ** 2' ([length] ** 2 * [mass] / [time] ** 2)
correct usage:
with h5tbx.File() as h5:
h5.create_dataset('torque', data=[1,2, 3], units='N*m') # incorrect would be using "Nm"
t = h5['torque'][:]
t
<xarray.DataArray 'torque' (dim_0: 3)> Size: 24B
1 2 3
Dimensions without coordinates: dim_0
Attributes:
units: m*N# check by converting to SI:
t.pint.quantify().pint.to('m^2/s^2*kg')
<xarray.DataArray 'torque' (dim_0: 3)> Size: 24B [kg·m²/s²] 1.0 2.0 3.0 Dimensions without coordinates: dim_0