Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/get_coord_sys_8py_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 02:40:11 2016
Кодировка:

Поисковые слова: п п п п п п п п п п п п п п п
lsst.tcc: python/tcc/parse/getCoordSys.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
getCoordSys.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 from twistedActor import CommandError
4 import coordConv
5 
6 __all__ = ["getCoordSys", "makeCoordSys", "OldCoordSysCodeNameDict", "CoordCmdNameDict"]
7 
8 SecPerYear = coordConv.SecPerDay * coordConv.DaysPerYear
9 
10 # dict of lowercase TCC coordsys name: (coordConv coordsys name, default date)
11 # for coordinate systems supported by coordConv (see _OtherCoordSysSet for the others)
12 _CoordSysDict = dict(
13  icrs = ("icrs", 0),
14  fk5 = ("fk5", 2000.0),
15  fk4 = ("fk4", 1950.0),
16  galactic = ("gal", 0),
17  geocentric = ("appgeo", 0),
18  topocentric = ("apptopo", 0),
19  observed = ("obs", 0),
20  none = ("none", 0),
21 )
22 
23 # set of acceptable other TCC coordinate system names (lowercase)
24 _OtherCoordSysSet = set(("mount", "instrument", "gimage", "gprobe", "ptcorr", "rotator"))
25 
26 # dict of coordSys TCC command name (lowercase): coordConv coordSys name
27 CoordCmdNameDict = dict((key, val[0]) for key, val in _CoordSysDict.iteritems())
28 for name in _OtherCoordSysSet:
29  CoordCmdNameDict[name] = name
30 
31 def getCoordSys(param):
32  """!Obtain a coordinate system from a parsed parameter
33 
34  @param[in] param the parsed parameter
35  @return a coordinate system as a shared_ptr to a subclass of coordConv.CoordSys, or None if not present
36  (returning a shared_ptr allows the result to be used to set Obj.userSys)
37 
38  @throw twistedActor.CommandError if the coordinate system is unrecognized
39  """
40  if not param.boolValue:
41  # no coordinate system specified
42  return None
43  if len(param.valueList) != 1:
44  raise RuntimeError("Bug: expected one coordSys keyword for /%s but got %s" % (param.name, param.valueList))
45 
46  val = param.valueList[0]
47  name = val.keyword
48 
49  if val.valueList:
50  date = val.valueList[0]
51  else:
52  date = 0
53 
54  name = val.keyword
55  return makeCoordSys(name=name, date=date)
56 
57 def makeCoordSys(name, date):
58  """!Make a coordinate system from its name and date
59 
60  Unlike coordConv.makeCoordSys this supports focal plane coordinate systems
61 
62  @param[in] name coordinate system name used by the command parser (case insensitive)
63  @param[in] date coordinate system date, or None for default date
64  """
65  lcName = name.lower()
66  if lcName in _OtherCoordSysSet:
67  if name.lower() in ("gimage", "gprobe") and date is None:
68  raise CommandError("Must specify guide probe number for %s coordinates" % (name,))
69  return coordConv.OtherCoordSys(lcName, date or 0).clone() # clone to get shared_ptr
70  try:
71  ccName, defDate = _CoordSysDict[lcName]
72  except KeyError:
73  raise RuntimeError("Unrecognized coordSys %r" % (name,))
74  if date is None:
75  date = defDate
76  return coordConv.makeCoordSys(ccName, date)
77 
78 # dict of old TCC coordinate system code: coordinate system name used by the command parser
79 # warning: the new TCC does not have Physical coordinates and the old TCC does not have PtCorr coordinates
80 OldCoordSysCodeNameDict = {
81  -9: "GImage",
82  -8: "GProbe",
83  -7: "Rotator",
84  -6: "Instrument",
85 
86  -5: "Mount",
87  #-4: "Physical", # the new TCC does not support physical coordinates
88 
89  -3: "Observed",
90  -2: "Topocentric",
91  -1: "Geocentric",
92 
93  0: "None",
94 
95  1: "FK4",
96  2: "FK5",
97  3: "Galactic",
98  4: "ICRS",
99 }
100 
def getCoordSys
Obtain a coordinate system from a parsed parameter.
Definition: getCoordSys.py:31
def makeCoordSys
Make a coordinate system from its name and date.
Definition: getCoordSys.py:57