Skip to content

Functional units in FITS and VOTable #3822

Open

Description

@mhvk

This is to remind me/us that now that function units are present (#1894), it should also be possible to write/read them to FITS and VOTable, at least for the subset for which the standard allows this.

EDIT: For instance, in fits dex(erg/s) can be written as log(erg/s).

The general writer is addressed in #3618.

Activity

  1. embray commented on Jun 5, 2015

    @embray
    Member

    👍

  2. added this to the v4.0 milestone on Jul 17, 2019
  3. removed this from the v4.0 milestone on Oct 24, 2019
  4. pllim commented on Oct 24, 2019

    @pllim
    Member

    I removed the milestone, @mhvk . FYI.

  5. pllim commented on Jun 5, 2024

    @pllim
    Member

    @olebole would also like a new u.log unit. See #16540 (comment)

  6. olebole commented on Oct 22, 2024

    @olebole
    Member

    I'd like to bring this back to the top again, because it seems to me the issue is almost complete now:

    This should be rather trivial, not? I could try to create a PR here, but before I would like to clarify what prevented us from implementing this also for FITS and VO, at least for dimensionless mag and for dex (which can be represented with the log function in FITS and VO)?

    i.e.

    >>> u.mag(1).to_string("vounit")
    'mag'
    >>> u.dex(1).to_string("vounit")
    'log(1)'
    >>> u.dex(u.solLum).to_string("vounit")
    'log(solLum)'

    The first one doesn't pass a roundtrip, as u.Unit("mag", format="vounit") doesn't return a magUnit, but the log/dex representation should be simple, not?

  7. pllim commented on Oct 22, 2024

    @pllim
    Member

    Also cc @eerovaher and @nstarman who also work on units a lot lately.

  8. eerovaher commented on Oct 22, 2024

    @eerovaher
    Member

    I don't know enough about function units to contribute to this meaningfully.

  9. nstarman commented on Oct 22, 2024

    @nstarman
    Member

    I would like to clarify what prevented us from implementing this also for FITS and VO, at least for dimensionless mag and for dex

    I think that was before my time.
    Seems like something we should support, and if it's easy to do now, that's great!

  10. mhvk commented on Oct 22, 2024

    @mhvk
    ContributorAuthor

    It never was particularly difficult, just needs someone to put in the time to think how exactly it should work and then implement it -- apparently, I didn't find that time in 9 years... If someone can write a series of tests, that would be a great start...

  11. jwfraustro commented on Dec 13, 2024

    @jwfraustro

    This is something I have just bumped into as well, somewhat related to the above #17297. I would love to see this as well.

    In our case, it was from another package that was using astropy.units to validate FITS and VO unit strings. I was very surprised when I found that VOUnit("log(solMass)") did not pass as valid, when the syntax is allowed by the standard.

  12. mhvk commented on Dec 13, 2024

    @mhvk
    ContributorAuthor

    Yes, it would be good. Not sure I'll get around it myself soon, but there are some hints here and especially in #17297 on how to implement it. As I wrote here, even just having a good set of tests would be a great start.

  13. gpdf commented on Dec 17, 2024

    @gpdf
    Contributor

    Perhaps the original issue was that log/ln/exp() function units are mathematically (very) different from "ordinary" units, which are inherently multiplicative. Note that they are not at all like sqrt() -- e.g., sqrt(m) is still a multiplicative unit.

    Is the issue not one of string-parsing, but rather one of what Astropy is supposed to do when a unit conversion is requested? Perhaps that code isn't ready for this?

  14. mhvk commented on Dec 17, 2024

    @mhvk
    ContributorAuthor

    @gpdf - astropy supports these "functional" units, which are used for Magnitude, Decibel, etc. The issue here is just about correctly translating these to FITS and VOTable (as is already possible for CDS format).

  15. jwfraustro commented on Dec 17, 2024

    @jwfraustro

    @gpdf Yes, I will admit my problem here is slightly reductionist. The angle from which I encountered this issue was not unit conversion or mathematical support, but straight parsing.

    My naive confusion was simply that VOUnit.parse() should be able to parse (in some form) any VOUnit. The fact that an exception was thrown when parsing a syntactically correct VOUnit is what threw me for a loop.

    Whether or not it can correctly map log(solMass) to the correct astropy function/unit is less worrisome to me than the fact that it should not throw a:

    >>> VOUnit.parse("log(solMass)")
    ValueError: 'log' is not a recognized function
    

    error for a correct VOUnit.

  16. gpdf commented on Dec 17, 2024

    @gpdf
    Contributor

    @jwfraustro Yes, understood. So perhaps the situation is just "haven't gotten to it" rather than "difficult to implement correctly"?

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