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
For complex types that are not currently in the list NeXus unit categories, allow the attribute, units, to in addition to being NX_ANGLE, NX_AREA, etc, be a vector of fractional SI dimensions. Example,
This means the user needs to include the attribute units, and the string they provide needs to have dimensionality of mass * time^2 * electric current^3 * temperature^4
The vector is:
length
mass
time
electric current
thermodynamic temperature
amount of substance
luminous intensity
This is the same order as in UDunits (link)
The HTML rendering won't show the numbers, but instead will use the SI defaults and the exponents to be more human readable. For example, g * s^2 * A^3 * K^4. The XML will have the vector. Whenever this convention is used, it is highly encouraged to proved the common name for these units in the doc string of the field.
This is a supplement to the list of allowed NeXus unit categories, and can be considered for complex types not in the list.
A sequence of seven numbers (in the NXDL file) is hard to embrace as a person who is coaching people to write new application definitions. This is a code that must be remembered. I foresee continual challenges about the proper order of the numbers, for example.
Perhaps there is another, more natural, way to implement this idea?
The problem to be solved here is that a pre-defined a list of units categories might not be bounded. To allow the NeXus standard to be flexible to our community, we need a more robust system to describe expected units as our community's needs expand.
We could add a unit_example="ev/mm" attribute for the monochromator disperion cited above. In general, the unit_example would have a human readable expression that is convertible with UDunits, pint, whatever. This type of expression satisfies the list of numbers with a human readable text. The expression is comparable to the examples already provided in nxdlTypes.xsd. Could it eventually replace the unit categories altogether?
The second example above (units="0,1,2,3,4,0,0") could be expressed unit_example="g * s^2 * A^3 * K^4". It could also be expressed in other variations which evaluate to the same units.
Of these I prefer the vector representation, but only because the user would never see it. The HTML for the documentation would be rendered as g * s^2 * A^3 * K^4, and we would recommend that developers put in their doc strings the more conventional name for their units. Only the XML would contain the more machine-readable vector.
The unit_example attribute is worth considering though.
If a unit is not provided by the list of NeXus unit categories, instead of providing a category, the field statement can include an example of the units directly.
The example does not constrain the scale of the units. For example, if the unit is eV/mm, they user could specify in a data file eV/cm, or any other unit that is convertible to the example given.
Activity
prjemian commentedon Sep 28, 2024
Is it appropriate to define a new type of units for this purpose? Here is where they are defined.
https://github.com/nexusformat/definitions/blob/main/nxdlTypes.xsd
phyy-nx commentedon Sep 28, 2024
Proposal:
For complex types that are not currently in the list NeXus unit categories, allow the attribute,
units, to in addition to beingNX_ANGLE,NX_AREA, etc, be a vector of fractional SI dimensions. Example,This means the user needs to include the attribute
units, and the string they provide needs to have dimensionality ofmass * time^2 * electric current^3 * temperature^4The vector is:
length
mass
time
electric current
thermodynamic temperature
amount of substance
luminous intensity
This is the same order as in UDunits (link)
The HTML rendering won't show the numbers, but instead will use the SI defaults and the exponents to be more human readable. For example,
g * s^2 * A^3 * K^4. The XML will have the vector. Whenever this convention is used, it is highly encouraged to proved the common name for these units in the doc string of the field.This is a supplement to the list of allowed NeXus unit categories, and can be considered for complex types not in the list.
(the NIAC will return to this tomorrow)
tacaswell commentedon Sep 28, 2024
prjemian commentedon Sep 28, 2024
A sequence of seven numbers (in the NXDL file) is hard to embrace as a person who is coaching people to write new application definitions. This is a code that must be remembered. I foresee continual challenges about the proper order of the numbers, for example.
Perhaps there is another, more natural, way to implement this idea?
The problem to be solved here is that a pre-defined a list of units categories might not be bounded. To allow the NeXus standard to be flexible to our community, we need a more robust system to describe expected units as our community's needs expand.
We could add a
unit_example="ev/mm"attribute for the monochromator disperion cited above. In general, theunit_examplewould have a human readable expression that is convertible with UDunits, pint, whatever. This type of expression satisfies the list of numbers with a human readable text. The expression is comparable to the examples already provided innxdlTypes.xsd. Could it eventually replace the unit categories altogether?prjemian commentedon Sep 28, 2024
The second example above (
units="0,1,2,3,4,0,0") could be expressedunit_example="g * s^2 * A^3 * K^4". It could also be expressed in other variations which evaluate to the same units.tacaswell commentedon Sep 29, 2024
is also pretty straight forward (modulo details like supporting
^1implicitly).Maybe instead of trying to write a "nice" string we have to parse, we instead make it a json object as:
It is a bit verbose, but it is unambiguous to both humans and computers. Dropping the keys who's value is 0 is likely reasonable.
phyy-nx commentedon Sep 29, 2024
Of these I prefer the vector representation, but only because the user would never see it. The HTML for the documentation would be rendered as
g * s^2 * A^3 * K^4, and we would recommend that developers put in their doc strings the more conventional name for their units. Only the XML would contain the more machine-readable vector.The
unit_exampleattribute is worth considering though.phyy-nx commentedon Sep 29, 2024
Note this is literally #1325, with the addition of extra HTML rendering code to smooth out the non-human readable unit vector.
phyy-nx commentedon Sep 29, 2024
Alternate proposal:
eV/mm, they user could specify in a data fileeV/cm, or any other unit that is convertible to the example given.Example:
<field name="monochromator_dispersion" units="eV/mm">It is recommended that users and application developers check if their units and their unit examples adhere to the UDUNITS standard.
This proposal is accepted by NIAC vote as part of NIAC2024
prjemian commentedon Sep 29, 2024
The PR should close these related issues:
prjemian commentedon Sep 29, 2024
Probably needs a modification to the NXDL Schema.
MNT #1435 per NIAC2024
DOC #1435 user-facing documentation