Repository navigation
Relax the VOTable requirements when parsing units - #620
Conversation
|
How can we no what to do with the unit, if it doesn't conform to the standard? There are two many adhoc ways that people spell units to possibly know. I'd rather have an option to the parser that allows the user to "select" a given unit format if they know that cds is not the one in the file. |
|
I might be overlooking something, but as far as I can see, the call might be be replaced by when the votable parser is called with pedantic=False. The only thing that changes is that calls like unit = u.Unit('Angstrom', parse_strict='silent') will not return an UnrecognizedUnit. I am not asking to the framework to be able to parse any string, only to honor the pedantic=False clause. Also, the VOUnits standard, which includes more symbols and different grammars than the current 'cds' one alone, is about to be approved by the IVOA. |
|
The FITS unit format (which is the default in astropy) and the CDS unit format also have different syntaxes. So are you suggesting we use CDS syntax but support more symbols? It's possible, given the direction of VO, that falling back to the VOUnit format would be a better choice, though. I agree that it would be nice if We already have the VOUnit format implemented so we can hit the ground running once that format is approved -- but likely that will only be switched on for VOTable v1.3 files and later (because obviously the unit format change won't be retroactive). |
|
There are two concerns: one is to comply with the standards, the other is to make the library useful for users. I'll tweak my suggestion: it would be nice to provide the user with the ability to use different unit parsers, especially (if not only) with pedantic=False. I had to change the code for being able to parse 'Angstrom', which is quite a common unit string out there in the wild. Being able to specify the format would be much better. Generalizing, it would be probably a good idea to pass a configuration object (a dictionary?) to the votable.parse() method, so that in the future new options might be passed to the parser without having to tweak its interface over and over again, but that's just an idea. Thanks. |
|
BTW, 'Angstrom' (and more generally the OGIP notation, e.g. 'erg cm**(-2) s**(-1) angstrom**(-1)') is used in some of the IVOA RECs, including specific VOTable examples. See for example |
|
Oh, dear. Definitely a case of one hand not knowing what the other is doing ;) Expect a PR to handle this shortly. |
|
@OmarLaurino : Can you let me know if this PR addresses your need? |
|
The code looks great, I'll need to test it later this week, though. Thanks! |
|
@OmarLaurino: Have you had a chance to look at this? |
|
This doesn't seem to work:
Where this is the xml for ID_1:
However:
Am I doing something wrong? |
|
Strange. It works for me. Are you sure you're running the latest version of this branch? If that's the case, can you send me the file so I can have a look? |
|
Did you receive the file? |
|
Yes -- I have the file. I'm looking into it now. |
|
Hmm... I can't reproduce. In your e-mail, you said you were testing 74ce8aa, but the most recent commit on this branch is af4bef4 -- that's what you should be testing with. Can you confirm whether that commit works? |
|
It works, sorry for the mistake. Thank you! |
Relax the VOTable requirements when parsing units
Add a blurb about governance
When reading VOTables, at least in the 'pedantic=False' mode, it would be useful to remove the 'cds' argument when unit strings are parsed using the Units framework, so that unit strings not compliant with the cds 'dialect', but still parseable by the framework, would not result in an UnidentifiedUnit instance.
I modified the astropy/io/votable/tree.py code in my working copy to do so, and it required only very few trivial tweaks.