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
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).
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)?
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?
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...
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.
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.
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?
@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).
@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
Activity
embray commentedon Jun 5, 2015
👍
pllim commentedon Oct 24, 2019
I removed the milestone, @mhvk . FYI.
pllim commentedon Jun 5, 2024
@olebole would also like a new
u.logunit. See #16540 (comment)olebole commentedon Oct 22, 2024
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
logfunction in FITS and VO)?i.e.
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?pllim commentedon Oct 22, 2024
Also cc @eerovaher and @nstarman who also work on
unitsa lot lately.eerovaher commentedon Oct 22, 2024
I don't know enough about function units to contribute to this meaningfully.
nstarman commentedon Oct 22, 2024
I think that was before my time.
Seems like something we should support, and if it's easy to do now, that's great!
mhvk commentedon Oct 22, 2024
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...
jwfraustro commentedon Dec 13, 2024
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.unitsto validate FITS and VO unit strings. I was very surprised when I found thatVOUnit("log(solMass)")did not pass as valid, when the syntax is allowed by the standard.mhvk commentedon Dec 13, 2024
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.
gpdf commentedon Dec 17, 2024
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?
mhvk commentedon Dec 17, 2024
@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).jwfraustro commentedon Dec 17, 2024
@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:error for a correct VOUnit.
gpdf commentedon Dec 17, 2024
@jwfraustro Yes, understood. So perhaps the situation is just "haven't gotten to it" rather than "difficult to implement correctly"?