VOUnit encodings
Markus Demleitner
msdemlei at ari.uni-heidelberg.de
Thu Jul 26 10:12:15 CEST 2018
Hi Stuart,
On Wed, Jul 25, 2018 at 06:00:04PM +0000, Chalk, Stuart wrote:
> I am using the VOUnit encoding specification and wondering if there
> are list of units encoded in the VOUnit spec anywhere.
> If anyone has any info on available lists of units please send me
> an email directly.
VOUnit has a grammar to generate unit strings, and the way that
grammar is written, you can generate infinitely many valid units
strings. So, there can be no exhaustive list of VOUnits.
On the other hand, there is a reasonably simple way to obtain a list
of valid VOUnit strings that are out in the wild. First, you'll need
a VOUnit parser; unity (https://bitbucket.org/nxg/unity) has parsers
in a couple of languages, and
http://svn.ari.uni-heidelberg.de/svn/gavo/python/trunk/gavo/base/unitconv.py
contains a pyparsing-based grammar relatively easily lifted for
python use (I'll happily assist removing the minor DaCHS dependencies
if there's interest).
Second, the wide majority of unit strings used in VO metadata[1] is
available from the registry -- try
select distinct unit from rr.table_column
on RegTAP mirror (if you don't have a TAP client, just retrieving
http://reg.g-vo.org/tap/sync?FORMAT=text/plain&LANG=ADQL&QUERY=select+distinct+unit+from+rr.table_column
will do as well).
Now, people are naughty, and so many of these units are
non-compliant. That's why you want the parser.
As usual, things become complicated when you encounter the real
world. VOUnit -- IMHO unfortunately -- encourages parsers to accept
"unknown units". You'll want to filter them out in some way.
Based on DaCHS and pyVO (both are Debian-packaged), you can write
this:
import pyvo
from gavo import api
for row in pyvo.dal.TAPService("http://dc.g-vo.org/tap"
).run_sync("select distinct unit from rr.table_column").table:
unit = row["unit"]
try:
tree = api.parseUnit(unit)
if "U?(" in repr(tree): # Filter "unknown units"
raise api.BadUnit("Unknown unit used")
except api.BadUnit:
pass
else:
print(unit)
I'm surprised myself that the output is just a measly 2.5k, so I'm
attaching what I just got.
Some of the units get me curious, though. m/ms, for instance, begs
the question why they didn't go for the much more common km/s...
-- Markus
[1] Well, people might disagree here, because I'm sure there's lots
of FITS files you can pull through VO facilities that contain a
plethora of unit strings; but it was fun stating it this way.
-------------- next part --------------
0.0001nm
0.001mag
0.001s
0.01 arcsec/yr
0.01arcmin/yr
0.01arcsec
0.01arcsec/yr
0.01d
0.01deg
0.01mag
0.01min/yr
0.01ms/yr
0.01nm
0.01s/a
0.01s/yr
0.01solRad
0.1 J/(m**2.s.m)
0.1 arcmin
0.125pix/yr
0.1GHz
0.1K
0.1MJy/sr
0.1Pa
0.1T
0.1W/m
0.1arcmin
0.1arcsec
0.1ct/s
0.1km/s
0.1m
0.1mT
0.1mas/yr
0.1nT
0.1nm
0.1nm/mm
0.1nm/pix
0.1pc
0.1pm
0.1s/a
0.1um
0.2km/s
0.2pix/yr
0.3631uJy
0.363mJy
0.36uJy
0.5arcsec
0.75Jy
1.46pix
10**(-15)m**(1/3)
10**-10 m
1000K
1000au
1000km/s
1000yr
100K
100K.km/s
100Mbarn
100W/sr
100ks
100mas
100pc
100pc/arcsec
100solLum
10K.km/s
10arcsec
10kJy
10kJy/sr
10m/s
10mas
10mas/a
10mas/ha
10mas/yr
10ms/yr
10solLum/nm
10uJy
10us/yr
15arcsec
173AU
1e-19 J/(s.m**2.Angstrom)
1e-22 W.m**-2
1e-23 J/(s.cm**2.Angstrom)
1e9 s**-1
2.17pix
2.54cm
20arcsec
20ct/ms
20mas
28Mbarn
2Ry
3.63uJy
30kV/m
30mas
363nJy
363uJy
3deg
45arcsec
4kct/s
8um
A
AU
AU/Myr
AU/d
Angstrom
C
D
EeV
G
GHz
GHz.u
GK
GPa
GV
Ga
GeV
GeV/m
Gm
Gpc
Gyr
Hz
Hz/s
J
J/mol
J/sr
Jy
Jy.km/s
Jy/K
Jy/beam
Jy/sr
K
K**-1
K.km/s
K.sr/MJy
K/Jy
K/arcmin
K/m
K/pc
MG
MHz
MHz/barn
MHz/nm
MHz/s
MJy/sr
MK
MV
Ma
Mbarn
Mbyte
MeV
Mm
Mm/s
Mpc
Mpc**3
Mpc.s/km
Mpc/h
Myr
Pa
Ry
T
TeV
V
W
W.m**-2
W/GHz
W/Hz
W/s
ZW
ZW/Hz
a
adu
angstrom/pixel
arcmin
arcmin**-2
arcmin/pc
arcmin/pix
arcsec
arcsec/a
arcsec/d
arcsec/h
arcsec/ha
arcsec/hyr
arcsec/kpc
arcsec/min
arcsec/mm
arcsec/pix
arcsec/s
arcsec/yr
au
beam
byte
cJy
cK
carcsec
carcsec/ha
carcsec/yr
cm
cm/mol
cm/s
cm/s**2
cmag
count
cs/yr
ct
ct.s**-1
ct/h
ct/ks
ct/pix
ct/pixel
ct/s
ct/yr
cyr
d
d/Myr
d/yr
dPa
dT
deg
deg**-1
deg**2
deg/a
deg/d
deg/h
deg/pix
deg/yr
dm
dmag
eV
erg
erg.cm**-2.s**-1.Angstrom**-1.arcsec**-2
erg/s
fs/s
g
g.m**(-2)
g/s
h
hJy
hPa
hT
hs
kG
kHz
kJ/g
kJ/mol
kJy
kJy/sr
kK
kT
kbyte
kct
kct/s
keV
kg
kg.m/s
km
km.s
km/S
km/h
km/mol
km/s
kpc
kpc.km/s
kpc/arcmin
kpc/arcsec
kpc/h
ks
kyr
log(Hz)
log(a)
log(cm/(s**2))
log(deg**-2)
log(erg.cm**-2.s**-1)
log(solMass)
log(yr)
m
m**(7/3)
m.s**(-1)
m/ms
m/s
m/yr
mA
mA/W
mG
mJ
mJy
mJy.km/s
mJy/beam
mJy/ct
mJy/pix
mJy/yr
mK
mK.km/s
mT
mag
mag/arcsec
mag/arcsec**2
mag/d
mag/deg
mag/h
mag/kpc
mag/pix
mag/rad
mag/s
mag/yr
marcsec
marcsec/a
mas
mas**-2
mas/a
mas/cyr
mas/pc
mas/pix
mas/s
mas/yr
mbarn
mct/s
mg
min
min/d
mm
mmag
mmag/arcsec
mol/s
mpc
mrad
ms
ms/a
ms/ha
ms/yr
myr
nHz
nJy
nT
nm
nm/mm
nm/pix
ns
ns/yr
pJy
pPa
pc
pc**-2
pc.GHz
pc/Myr
pc/arcmin
pc/arcsec
pc/mas
pc/pix
pct
ph
ph/ks
ph/pix
ph/s
photon
pix
pixel
pixel**2
pm
ps
rad
rad/d
rad/s
rad/yr
s
s**-1
s/a
s/ha
s/hyr
s/km
s/pix
s/s
s/yr
solLum
solMass
solMass.km/s
solMass/Myr
solMass/solLum
solMass/yr
solRad
sr
uG
uHz
uJ
uJy
uJy/beam
uJy/pix
uK
uW/nm
uarcsec
uarcsec/yr
um
um**-1
um.mag
urad
us
us/yr
yr
zW
More information about the semantics
mailing list