Repository navigation
Description
Problem
Problems might occur when reading in VOTables as QTables. Depending on the formatting of composite units in the data, the unit of some of the Quantities in the QTable might be an instance of UnrecognizedUnit, which means that several useful Quantity methods, e.g. unit conversion, result in an error. This happens with VOTables provided by the Gaia archive, which lists the proper motion units as mas.yr**-1 and radial velocity units as km.s**-1, both of which end up as UnrecognizedUnit instances in a QTable. This motivated the pull request #10786, and even though the changes proposed there allow Gaia VOTables to be read in the expected manner they should be considered to be a workaround rather than a proper solution. The actual problem seems to be caused by unit parsing done while reading a VOTable from a file.
Solution(?)
A likely culprit is the function _get_default_unit_format() that always returns 'cds', meaning that the unit format is expected to be as specified at http://vizier.u-strasbg.fr/doc/catstd-3.2.htx. Indeed, the proper motion and radial velocity units in the Gaia archive do not conform to this standard explaining why unit parsing fails. Astropy documentation states that this unit format was used in VOTable versions up to 1.2. Indeed, the current VOTable version (1.4) has a different unit format specification. The composite units in the Gaia archive do conform to this newer specification and the following code does resolve the problem with reading in Gaia VOTables.
def _get_default_unit_format(config):
if config['version_1_3_or_later']:
return 'vounit'
else:
return 'cds'However, the VOTable version 1.3 seems to have the same unit format specification as version 1.2 and different from the specification in version 1.4. This would suggest that _get_default_unit_format() should check the 'version_1_4_or_later' flag instead, but that conflicts the aforementioned Astropy documentation and also prevents Gaia VOTables from being parsed properly, as they claim their version to be 1.3.
Open questions
Where does the statement in Astropy documentation come from? Could it be that the VOTables from the Gaia archive are actually version 1.4 VOTables despite what they claim to be?
System Details
Linux-5.4.0-48-generic-x86_64-with-glibc2.29
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0]
Numpy 1.19.2
astropy 4.2.dev744+gf57719321
Scipy 1.5.2
Matplotlib 3.3.2
Activity
pllim commentedon Oct 15, 2020
The statement was added way back in #1468 (started 2013-09-20, merged 2013-10-21) and VOTable 1.3 was also dated 2013-09-20. Given the pull request had no mention of 1.3, there is a chance that this docstring should have been updated but was overlooked due to the timing.
Perhaps @tomdonaldson knows if it should be
if config['version_1_3_or_later']orif config['version_1_4_or_later'].This, I am not sure. Are you able to ask Gaia archive developer for clarification?
eerovaher commentedon Oct 20, 2020
I have contacted the Gaia helpdesk, they might indeed know more about VOTable unit format.
Add VOTable unit format recognition test
Make VOTable unit format version-dependent astropy#10791
eerovaher commentedon Nov 12, 2020
The pull request #11032 should make Astropy compliant with VOTable unit specification. This should greatly simplify reading in Gaia archive VOTables as QTables when they start using version 1.4, but currently the best option still seems to be something like
It would be convenient if it were possible to use
QTable.read()with theunit_formatargument, but that would have be implemented in a separate pull request.Add VOTable unit format recognition test
Make VOTable unit format version-dependent astropy#10791
Add VOTable unit format recognition test
Make VOTable unit format version-dependent astropy#10791