Skip to content

Implement log units for FITS and VOTable #16540

Closed

Description

@olebole

What is the problem this feature will solve?

The FITS standard allows a number of logarithmic units, namely "log()" and "ln()" as generic units, and "mag" as dimensionless mag unit. While "mag" is supported, "log()" and "ln()" are not.
These units are also not supported on a general level.
At least "log()" could be easily supported, since it seems to be an alias for the supported "dex" magunit (if I understand dex right). And "log" is the one where I now got a user request.

Describe the desired outcome

IMO there should be

  • an u.log class which behaves as u.dex (alias) in conversions,
  • an extension to the parser to accept log() as a function, like dex(),
  • FITS and vounit parser that can handle function units,
  • FITS and votable formatter that allow function units to be written, and correctly format the argument (i.e. for vounit the argument shall be vounit compliant).

Like:

>>> import astropy.units as u
>>> u.log(u.cm**-2)
Unit("log(1 / cm2)")
>>> u.log(u.cm**-2).to_string("fits")
'log(1 / cm2)'
>>> u.log(u.cm**-2).to_string("vounit")
'log(cm**-2)'
>>> u.Unit("log(cm**-2)", format="fits")
Unit("log(1 / cm2)")

Additional context

I think that was somewhere discussed before, but I couldn't find the relevant bug. Specifically there was a discussion about why FITS (and VOTable) don't support function units yet.
IMO there was also a can of worms waiting on what the difference between u.mag and u.mag() is, which is a bit confusing.

Activity

  1. mhvk commented on Jun 5, 2024

    @mhvk
    Contributor

    Yes, indeed, it should not be too difficult, but while I raised an issue about it now almost 10 years ago (#3822), just after implementing the function units, I've not gotten around to actually implementing it...

    p.s. And, yes, the difference between u.mag and u.mag() remains a bit annoying, but probably best discussed separately...

  2. pllim commented on Jun 5, 2024

    @pllim
    Member

    So, this is a duplicate of #3822?

  3. olebole commented on Jun 5, 2024

    @olebole
    MemberAuthor

    I think this one is duplicate. My proposal included an additional "u.log" unit; however this is not really required. Just reader/writer would be great.

  4. pllim commented on Jun 5, 2024

    @pllim
    Member

    Thanks! I will close this as duplicate then and add a note about your new request in the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions