1 from __future__
import division, absolute_import
3 from twistedActor
import CommandError
6 __all__ = [
"getCoordSys",
"makeCoordSys",
"OldCoordSysCodeNameDict",
"CoordCmdNameDict"]
8 SecPerYear = coordConv.SecPerDay * coordConv.DaysPerYear
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),
24 _OtherCoordSysSet = set((
"mount",
"instrument",
"gimage",
"gprobe",
"ptcorr",
"rotator"))
27 CoordCmdNameDict = dict((key, val[0])
for key, val
in _CoordSysDict.iteritems())
28 for name
in _OtherCoordSysSet:
29 CoordCmdNameDict[name] = name
32 """!Obtain a coordinate system from a parsed parameter
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)
38 @throw twistedActor.CommandError if the coordinate system is unrecognized
40 if not param.boolValue:
43 if len(param.valueList) != 1:
44 raise RuntimeError(
"Bug: expected one coordSys keyword for /%s but got %s" % (param.name, param.valueList))
46 val = param.valueList[0]
50 date = val.valueList[0]
58 """!Make a coordinate system from its name and date
60 Unlike coordConv.makeCoordSys this supports focal plane coordinate systems
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
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()
71 ccName, defDate = _CoordSysDict[lcName]
73 raise RuntimeError(
"Unrecognized coordSys %r" % (name,))
76 return coordConv.makeCoordSys(ccName, date)
80 OldCoordSysCodeNameDict = {
def getCoordSys
Obtain a coordinate system from a parsed parameter.
def makeCoordSys
Make a coordinate system from its name and date.