Package gavo :: Package stc :: Module syslib
[frames] | no frames]

Source Code for Module gavo.stc.syslib

 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-2019, the GAVO project 
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  from gavo import utils 
18   
19   
20  STC_IVOID = "ivo://STClib/CoordSys" 
21   
22   
23  SYSDEFS = { 
24  "TT-ICRS-TOPO":  
25          "Time TT TOPOCENTER Position ICRS TOPOCENTER", 
26  "TT-FK5-TOPO": 
27          "Time TT TOPOCENTER Position FK5 TOPOCENTER", 
28  "UTC-ICRS-TOPO": 
29          "Time UTC TOPOCENTER Position ICRS TOPOCENTER", 
30  "UTC-FK5-TOPO": 
31          "Time UTC TOPOCENTER Position FK5 TOPOCENTER", 
32  "TT-ICRS-GEO": 
33          "Time TT GEOCENTER Position ICRS GEOCENTER", 
34  "TT-FK5-GEO": 
35          "Time TT GEOCENTER Position FK5 GEOCENTER", 
36  "UTC-ICRS-GEO": 
37          "Time UTC GEOCENTER Position ICRS GEOCENTER", 
38  "UTC-ICRS-HELIO": 
39          "Time UTC GEOCENTER Position ICRS HELIOCENTER", 
40  "UTC-FK5-GEO": 
41          "Time UTC GEOCENTER Position FK5 GEOCENTER", 
42  "TDB-ICRS-BARY": 
43          "Time TDB BARYCENTER Position ICRS BARYCENTER", 
44  "TDB-FK5-BARY": 
45          "Time TDB BARYCENTER Position FK5 BARYCENTER", 
46  "TT-ICRS-BARY": 
47          "Time TT BARYCENTER Position ICRS BARYCENTER", 
48  "UTC-HPC-TOPO": 
49          "Time UTC TOPOCENTER Position HPC TOPOCENTER CART2", 
50  "UTC-HPR-TOPO": 
51          "Time UTC TOPOCENTER Position HPR TOPOCENTER SPHER2", 
52  "UTC-HGS-TOPO":                                       
53          "Time UTC TOPOCENTER Position HGS TOPOCENTER SPHER2", 
54  "UTC-HGC-TOPO":                                       
55          "Time UTC TOPOCENTER Position HGC TOPOCENTER SPHER2", 
56  "TT-ICRS-HZ-TOPO": 
57          "Time TT TOPOCENTER Position ICRS TOPOCENTER SPHER2 Spectral" 
58          " TOPOCENTER unit Hz", 
59  "TT-ICRS-OPT-BARY-TOPO":   
60          "Time TT TOPOCENTER Position ICRS TOPOCENTER Redshift BARYCENTER OPTICAL", 
61  "TT-ICRS-RADIO-LSR-TOPO":  
62          "Time TT TOPOCENTER Position ICRS TOPOCENTER Redshift LSR RADIO", 
63  } 
64 65 @utils.memoized 66 -def getLibrarySystem(sysId):
67 """returns a dm.CoordSys instance for sysId. 68 69 sysId may be the full IVOID or just the fragment. 70 Unknown sysIds result in NotFoundErrors. Results are memoized, so 71 make sure you do not mess with what you are returned. 72 """ 73 sysId = stripIVOID(sysId) 74 try: 75 sDef = SYSDEFS[sysId] 76 except KeyError: 77 raise utils.NotFoundError(sysId, "STC library system", 78 "IVOA defined systems", hint="The systems available are defined" 79 " in an appendix of the STC recommendation") 80 from gavo.stc import stcsast 81 system = stcsast.parseSTCS(sDef).astroSystem 82 system.libraryId = "%s#%s"%(STC_IVOID, sysId) 83 return system
84
85 86 -def stripIVOID(sysId):
87 """returns sysId with the STC IVOID root removed. 88 89 If sysId does not start with the STC IVOID, it is returned unchanged. 90 """ 91 if sysId.startswith(STC_IVOID): 92 sysId = sysId[len(STC_IVOID)+1:] 93 return sysId
94