ivoa-std / VOUnits

Units in the VO
Creative Commons Attribution Share Alike 4.0 International
0 stars 4 forks source link

Scale factors in function arguments: eg, log(1e3W) #17

Closed nxg closed 1 year ago

nxg commented 2 years ago

Should log(1e3W) be deemed a valid units string in the VOUnits syntax? And in the other syntaxes?

Adding this was suggested (in the sense of its absence being noted as a defect) by Sébastien. This unit string appears in a number of Vizier catalogue metadata entries – ie, it's found ‘in the wild’.

Norman thinks ‘Yes’: rationale

The log function should of course be applied only to a dimensionless argument. The VOUnits spec says, however, that

Note that since functions such as ‘log’ require dimensionless arguments, when a quantity x is (for example) represented by numbers labelled with units log(Hz), that indicates that the numbers are related to x by the function log(x/(1 Hz)).

This interpretation is consistent with including a scalefactor in the argument. This change has been implemented successfully in the Unity grammars, and it doesn't syntactical or processing problems.

And other grammars...

A related question is: should the same be true of the FITS/OGIP/CDS formal grammars? These grammars (yacc grammars, included in the VOUnits standard for reference) are deduced from the corresponding standards texts rather than being specified by them.

The standards for these other syntaxes are a little vague, but a reasonably narrow interpretation of the text there would not accommodate scale factors in function operands. But even a modestly broad interpretation would, I think, permit them.

Specifically (detail...): The nearest to a proscription is the FITS spec, which says that 'The final units string is the compound string, or a compound of compounds, preceded by an optional numeric multiplier...', implicitly distinguishing 'the final units string' from 'base unit strings': a narrow interpretation of this would deem the operand to log(x) to be a 'base unit string', which doesn't have this 'optional numeric multiplier' prepended). The OGIP spec largely inherits the FITS spec, but is slightly contradictory, in that it says that str1 in 'log(str1)' is 'strings conforming to the rules given in Section 2 to specify physical units.' (which could be taken to rule out permitting a scalefactor, but also says 'the numerical factor can simply be considered a basic unit string', which would seem to more-or-less explicitly permit it.

On the basis of a Principle of Least Astonishment, therefore, Norman suggests that the grammars (and thus the Unity library) be adjusted to permit scale factors within function arguments for all of the referenced syntaxes.

nxg commented 1 year ago

See Unity issue 11.