astropy/astropy — pull request #1169 by RayPlante (2013-06-09 04:05:41+00:00)
Title: Units legal under CDS cat standard (e.g. mJy, kbyte, Mpc etc.) not allowed by cds format impl.

The units.format.cds module is a unit string parser that implements the CDS catalog standard for units documented at http://cdsarc.u-strasbg.fr/doc/catstd-3.2.htx. It is the standard used for expressing units in a VOTable. This implementation explicitly disallows the combination of metric prefixes with non-SI base units, making a number of commonly used units, such as mJy, kbyte, and Mpc, unsupported. When a VOTable is parsed which invoke these units, an warning is issued, and the unit is instantiated as an ``UnrecognizedUnit``

The text on above mentioned standard does _not_ actually disallow these units, and they are certainly used within CDS/Vizier tables (according to CDS's Francois Ochenbein). (The text actually makes explicit recommendation of one such unit not supported by the cds module, uarcsec). These units, of course, are supported generally by the units module's core implementation.

I'm attaching a pull request for a fix to the cds module. The cds implementation segregates units that can have metric prefixes from those that can't. In my fix, I moved those units previously in the latter category for which the units module supports prefixes generally into the former category. I augmented the units.tests to check these explicitly.

It's worth noting that as the standard is written, there is really only one unit in the CDS base unit list that cannot be combined with a prefix, and that is "mas" (milli-arcsecs). A strict implementation would follow suit, but my fix does not because of the limits set in the units core module. This is probably reasonable in some cases--I don't think people use, say, "MSun", "MsolLum", or "kmin"; however, people do talk about kilodays and kilocounts, there shouldn't be anything wrong with a kiloDebye, and LSST is building a Gigapixel camera. These are all undefined in the core units module.