unitsml / unitsdb

UnitsDB
https://www.unitsml.org
5 stars 5 forks source link

Support on-the-fly generation of (new) composite units encoding #27

Closed ronaldtse closed 3 years ago

ronaldtse commented 3 years ago

A feature of UnitsML is the dynamic encoding of non-UnitsDB units through combining existing units (root or derived units).

We'll have to figure out how to do that.

ronaldtse commented 3 years ago

This is an example of "watt per square meter steradian" which is SI-derived and can be (technically) user-defined without needing a UnitsDB entry.

"NISTu14.u1e-2/1.u10e-1/1":
  dimension_url: "#NISTd38"
  short:
  root: false
  unit_system:
    type: "SI_derived_non-special"
    name: "SI"
  unit_name:
    - "watt per square meter steradian"
  unit_symbols:
    - ascii: "W*m^-2*sr^-1"
      html: W/(m^2 · sr)
      latex: \ensuremath{\mathrm{W/(m^2\cdot sr)}}
      unicode: "W/(m²·sr)"
  root_units:
    enumerated_root_units:
      - unit: "watt"
        power_denominator: 1
        power_numerator: 1
      - unit: "meter"
        power_denominator: 1
        power_numerator: -2
      - unit: "steradian"
        power_denominator: 1
        power_numerator: -1
  quantity_reference:
    - name: "radiance"
      url: "#NISTq89"

The key points are:

Maybe something like this:

unitsml(
  composite: watt * meter^-1 * steradian^-1, 
  quantity: radiance
)

will already give us what we want?

Questions:

"watt per square meter steradian" dimensions:

NISTd38:
  mass:
    powerNumerator: 1
    symbol: M
  time:
    powerNumerator: -3
    symbol: T

Watt dimensions:

NISTd16:
  length:
    powerNumerator: 2
    symbol: L
  mass:
    powerNumerator: 1
    symbol: M
  time:
    powerNumerator: -3
    symbol: T

Steradian dimensions:

NISTd9:
  dimensionless: true
  plane_angle:
    powerNumerator: 1
    symbol: phi

Meter dimensions:

NISTd1:
  length:
    powerNumerator: 1
    symbol: L

So may be not?

ronaldtse commented 3 years ago

Or is NISTd38 actually wrong?

opoudjis commented 3 years ago

I do do this already. I do generate the dimensions. I don't yet generate or read in the quantities, for any unit. My code has a TODO for generating the user name, but I agree there should be an option for the user to provide a name.

opoudjis commented 3 years ago

Quantities and dimensions are read in, where available. User input of quantities now supported.

opoudjis commented 3 years ago

Allowing name input. Will close this for now.

ronaldtse commented 3 years ago

This functionality should be split into the two locations: unitsml gem (https://github.com/unitsml/unitsml-ruby) and asciiunits (https://github.com/plurimath/asciimath2unitsml).