ivoa-std / VOUnits

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

[1.1] Contradicting text for dimensionless units #37

Open olebole opened 1 month ago

olebole commented 1 month ago

As a followup to #9 ...

In version 1.1, section 2.2 now states

In each of the grammars here, the empty string is not a valid units string - in particular, it is not taken to indicate a dimensionless quantity. […] The VOUnits syntax, though it also deems the empty string to be invalid, recognises the string 1 as positively indicating a dimensionless quantity.

Although I must admit that I don't fully understand this (what means "each of the grammars here"?), my interpretation is that a dimensionless quantity cannot be written as empty string but must be written as "1".

However, then section 2.8 comes with

If there is no unit associated with a quantity (for example a quantity that is a character string, or unitless), data providers should indicate this with an empty string rather than blanks or dashes.

which recommends the empty string and does not even mention the "1".

This is also important when one wants to use the dimensionless logarithmic unit, for example to specify the metallicity unit dex: should one use log() or log(1)? What is current practice in catalogues here?

BTW, in the cited statement from section 2.8: why does it say "should" and not "must" or "shall"? Are there circumstances where spaces or dashes are useful (see RFC2119)? And there is "dimensionless" in 2.2 but "unitless" in 2.8; this should be consistent wording.

olebole commented 1 month ago

One more comment here: using 1 for the dimensionless quantities may break the FITS conformity of the VO unit representation. Although I couldn't find a statement that directly forbids a solely 1 as unit, it is not listed as a valid unit there; also Astropy fails to recognize it

>>> import astropy.units as u
>>> u.Unit("1", format="fits")
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/astropy/units/format/generic.py", line 585, in _do_parse
    return cls._parse_unit(s, detailed_exception=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/astropy/units/format/fits.py", line 98, in _parse_unit
    cls._validate_unit(unit, detailed_exception=detailed_exception)
  File "/usr/lib/python3/dist-packages/astropy/units/format/fits.py", line 89, in _validate_unit
    raise ValueError()
ValueError
[…]
nxg commented 1 month ago

Thanks for this, Ole. This is clearly a slightly intricate one.

I won't have the bandwidth to think about this for a couple of weeks, so this comment is (a) a placeholder ACK, and (b) an opportunity to @msdemlei Markus, in case he wants to leap in.

msdemlei commented 1 month ago

On Wed, Oct 23, 2024 at 02:22:08PM -0700, Norman Gray wrote:

opportunity to @msdemlei Markus, in case he wants to leap in.

Well, I think this has two aspects. One is that we clearly have not quite managed to express our solution of the dimensionless vs. non-unit thing such that people won't get confused despite our best plans for 1.1. I suppose clarifying the language in 2.8 by saying "(for example a quantity that is a character string, as opposed to a dimensionless quantity, which by 2.2 has a 1)" or something like that should fix Ole's immediate concern.

While this ought to make clear that the infamous "dex" is written as "log(1)". Which we might as well spell out explicitly. If we believe this is something we want to handle with the unit metadata, that is, and I still have doubts about that.

The other aspect in my opiniton is Ole's immediate problem, the way astronomy currently deals with abundance ratios obtained from spectral analysis. I would like to see that discussed somewhere (and probably non-normatively but as a best practice), and VOUnits perhaps is not the worst place for that.

My trouble is that if someone says "dex", it's usually the case that they give (sometimes ratios of) abundance ratios, log(object/sun), but there are exceptions to that. So, telling people something like "If feel the urge to write 'dex' and be done with it, please instead write log(1) and in the description say something like 'log of the ratio of Fe/H to solar Fe/H'; whatever it is, be explicit in the description what ratio it is that has canceled out the units." Or something along these lines.

olebole commented 1 month ago

One other question appeared here during the course of implementing this in astropy, https://github.com/astropy/astropy/pull/17230: It is not clear to me whether this is an incompatible structural change in 1.1, just a clarification or some practice already unofficially established with 1.0, or introducing a new semantics because the old one (using an empty string) was contradicting the grammars? I.e.

Finally, I would like to know how this translates to FITS units, i.e. if I have 1 or log(1) in VOUnit, how does one write it when converting to FITS?