| 1 |
""" |
| 2 |
Arnold Rots' "library" of standard systems. |
| 3 |
|
| 4 |
There's a dictionary of STC-S definitions of the systems that are compiled |
| 5 |
and memoized on demand. Thus, use the getLibrarySystem function below |
| 6 |
exclusively to access this content. |
| 7 |
|
| 8 |
If and when there are additional library systems, you need to amend sysdefs. |
| 9 |
""" |
| 10 |
|
| 11 |
#c Copyright 2008-2025, the GAVO project <[email protected]> |
| 12 |
#c |
| 13 |
#c This program is free software, covered by the GNU GPL. See the |
| 14 |
#c COPYING file in the source distribution. |
| 15 |
|
| 16 |
|
| 17 |
import functools |
| 18 |
|
| 19 |
from gavo import utils |
| 20 |
|
| 21 |
|
| 22 |
STC_IVOID = "ivo://STClib/CoordSys" |
| 23 |
|
| 24 |
|
| 25 |
SYSDEFS = { |
| 26 |
"TT-ICRS-TOPO": |
| 27 |
"Time TT TOPOCENTER Position ICRS TOPOCENTER", |
| 28 |
"TT-FK5-TOPO": |
| 29 |
"Time TT TOPOCENTER Position FK5 TOPOCENTER", |
| 30 |
"UTC-ICRS-TOPO": |
| 31 |
"Time UTC TOPOCENTER Position ICRS TOPOCENTER", |
| 32 |
"UTC-FK5-TOPO": |
| 33 |
"Time UTC TOPOCENTER Position FK5 TOPOCENTER", |
| 34 |
"TT-ICRS-GEO": |
| 35 |
"Time TT GEOCENTER Position ICRS GEOCENTER", |
| 36 |
"TT-FK5-GEO": |
| 37 |
"Time TT GEOCENTER Position FK5 GEOCENTER", |
| 38 |
"UTC-ICRS-GEO": |
| 39 |
"Time UTC GEOCENTER Position ICRS GEOCENTER", |
| 40 |
"UTC-ICRS-HELIO": |
| 41 |
"Time UTC GEOCENTER Position ICRS HELIOCENTER", |
| 42 |
"UTC-FK5-GEO": |
| 43 |
"Time UTC GEOCENTER Position FK5 GEOCENTER", |
| 44 |
"TDB-ICRS-BARY": |
| 45 |
"Time TDB BARYCENTER Position ICRS BARYCENTER", |
| 46 |
"TDB-FK5-BARY": |
| 47 |
"Time TDB BARYCENTER Position FK5 BARYCENTER", |
| 48 |
"TT-ICRS-BARY": |
| 49 |
"Time TT BARYCENTER Position ICRS BARYCENTER", |
| 50 |
"UTC-HPC-TOPO": |
| 51 |
"Time UTC TOPOCENTER Position HPC TOPOCENTER CART2", |
| 52 |
"UTC-HPR-TOPO": |
| 53 |
"Time UTC TOPOCENTER Position HPR TOPOCENTER SPHER2", |
| 54 |
"UTC-HGS-TOPO": |
| 55 |
"Time UTC TOPOCENTER Position HGS TOPOCENTER SPHER2", |
| 56 |
"UTC-HGC-TOPO": |
| 57 |
"Time UTC TOPOCENTER Position HGC TOPOCENTER SPHER2", |
| 58 |
"TT-ICRS-HZ-TOPO": |
| 59 |
"Time TT TOPOCENTER Position ICRS TOPOCENTER SPHER2 Spectral" |
| 60 |
" TOPOCENTER unit Hz", |
| 61 |
"TT-ICRS-OPT-BARY-TOPO": |
| 62 |
"Time TT TOPOCENTER Position ICRS TOPOCENTER Redshift BARYCENTER OPTICAL", |
| 63 |
"TT-ICRS-RADIO-LSR-TOPO": |
| 64 |
"Time TT TOPOCENTER Position ICRS TOPOCENTER Redshift LSR RADIO", |
| 65 |
} |
| 66 |
|
| 67 |
@functools.lru_cache() |
| 68 |
def getLibrarySystem(sysId): |
| 69 |
"""returns a dm.CoordSys instance for sysId. |
| 70 |
|
| 71 |
sysId may be the full IVOID or just the fragment. |
| 72 |
Unknown sysIds result in NotFoundErrors. Results are memoized, so |
| 73 |
make sure you do not mess with what you are returned. |
| 74 |
""" |
| 75 |
sysId = stripIVOID(sysId) |
| 76 |
try: |
| 77 |
sDef = SYSDEFS[sysId] |
| 78 |
except KeyError: |
| 79 |
raise utils.NotFoundError(sysId, "STC library system", |
| 80 |
"IVOA defined systems", hint="The systems available are defined" |
| 81 |
" in an appendix of the STC recommendation") |
| 82 |
from gavo.stc import stcsast |
| 83 |
system = stcsast.parseSTCS(sDef).astroSystem |
| 84 |
system.libraryId = "%s#%s"%(STC_IVOID, sysId) |
| 85 |
return system |
| 86 |
|
| 87 |
|
| 88 |
def stripIVOID(sysId): |
| 89 |
"""returns sysId with the STC IVOID root removed. |
| 90 |
|
| 91 |
If sysId does not start with the STC IVOID, it is returned unchanged. |
| 92 |
""" |
| 93 |
if sysId.startswith(STC_IVOID): |
| 94 |
sysId = sysId[len(STC_IVOID)+1:] |
| 95 |
return sysId |