You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chris showed me that the C Das2 library supports SI units, where it knows "1 meter" divided by "1 second" is "1 meter/second". I've got code in the Das2Datum library that does this, and I should make sure it considers what Chris is supporting in the C library. For example, he has a parser and I should support strings formatted and parsed with that code. See https://github.com/das-developers/das2C/blob/master/test/TestUnits.c
The units module in das2C was originally written to support the das2_psd utility. I wanted the units on the resulting spectrograms to be correct without human intervention but didn't want special case code in das2_psd, thus a generalized units module was written.
The code in units.c consists of six sections:
SI Prefix handling, both as symbols and names, i.e: micro and μ
SI Unit handling, both as symbols and names, i.e.: ohms and Ω
Mathematical operations: i.e. div( "meters", "second") => "m s**-1"
Reduction, i.e. "m/s" * "s" -> "m"
Conversion: ratio = convert(1.0, "meters/sec", "km/day")
Singleton assignment
The fundamental assumption on all the parsing code is that units strings are encoded as UTF-8, period. There is no handling of any other encodings.
Activity
cpiker commentedon Feb 24, 2026
It a tangent, but a companion issue has been opened in das2C to add support for offset units: das-developers/das2C#19 .
cpiker commentedon Feb 24, 2026
The units module in das2C was originally written to support the
das2_psdutility. I wanted the units on the resulting spectrograms to be correct without human intervention but didn't want special case code in das2_psd, thus a generalized units module was written.The code in units.c consists of six sections:
microandμohmsandΩdiv( "meters", "second") => "m s**-1""m/s" * "s" -> "m"ratio = convert(1.0, "meters/sec", "km/day")The fundamental assumption on all the parsing code is that units strings are encoded as UTF-8, period. There is no handling of any other encodings.