How to work with torque data

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
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import h5rdmtoolbox as h5tbx

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/checkouts/v1.7.0/h5rdmtoolbox/__init__.py:129
    125     with File(src) as h5:
    126         return h5.dumps()
--> 129 from h5rdmtoolbox.wrapper.ld.hdf.file import get_ld as hdf_get_ld
    130 from h5rdmtoolbox.wrapper.ld.user.file import get_ld as user_get_ld
    133 def get_ld(
    134         hdf_filename: Union[str, pathlib.Path],
    135         structural: bool = True,
    136         semantic: bool = True,
    137         blank_node_iri_base: Optional[str] = None,
    138         **kwargs) -> rdflib.Graph:

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/checkouts/v1.7.0/h5rdmtoolbox/wrapper/ld/__init__.py:1
----> 1 import ssnolib.ssno.standard_name
      2 from ontolutils.namespacelib import M4I
      3 from ontolutils.namespacelib import SCHEMA

ModuleNotFoundError: No module named 'ssnolib'

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 'kilogram * meter ** 2 / 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)>
1 2 3
Dimensions without coordinates: dim_0
Attributes:
    units:       N*m
    PROVENANCE:  {'HDF': {'root': {'__h5rdmtoolbox_version__': '0.9.0a0'}, 'g...
# check by converting to SI:
t.pint.quantify().pint.to('m^2/s^2*kg')
<xarray.DataArray 'torque' (dim_0: 3)>
[kg·m²/s²] 1.0 2.0 3.0
Dimensions without coordinates: dim_0
Attributes:
    PROVENANCE:  {'HDF': {'root': {'__h5rdmtoolbox_version__': '0.9.0a0'}, 'g...