1 from __future__
import division, absolute_import
6 from twistedActor
import CommandError
9 from tcc.axis import computeObj, coordConvWithFP, obsFromRot
10 from tcc.parse import getPVTPairPxPMRadVel, getCoordSys
14 _BadCoordSysNameList = (
"mount",
"none")
15 _BadCoordSysNameLCSet = set(csName.lower()
for csName
in _BadCoordSysNameList)
16 _BadCoordSysDescr =
" or ".join(_BadCoordSysNameList)
17 del _BadCoordSysNameList
20 """Implement the ptCorr command
22 @param[in,out] tccActor tcc actor
23 @param[in,out] userCmd user command
25 parsedCmd = userCmd.parsedCmd
26 qualDict = parsedCmd.qualDict
28 currTAI = tcc.base.tai()
32 obj = tcc.base.Obj(tccActor.obj)
36 useGSWavelen = qualDict[
"usegswavelength"].boolValue
38 predPVTPair, predPxPMRadVel =
getPVTPairPxPMRadVel(parsedCmd=parsedCmd, coordName=
"predcoords", defTAI=currTAI)
39 if predPVTPair
is None:
40 raise CommandError(
"Must specify star's predicted position")
41 predCoordSys =
getCoordSys(param=parsedCmd.paramDict[
"predcoordsys"])
42 if predCoordSys
is None:
43 raise CommandError(
"Must specify coordinate system of star's predicted position")
45 measPVTPair, measPxPMRadVel =
getPVTPairPxPMRadVel(parsedCmd=parsedCmd, coordName=
"meascoords", defTAI=currTAI)
46 if measPVTPair
is None:
47 raise CommandError(
"Must specify star's measured position")
48 measTAI = measPVTPair[0].t
49 measCoordSys =
getCoordSys(param=parsedCmd.paramDict[
"meascoordsys"])
50 if measCoordSys
is None:
51 raise CommandError(
"Must specify coordinate system of star's measured position")
53 if predCoordSys.getName().lower()
in _BadCoordSysNameLCSet:
54 raise CommandError(
"Invalid fromSys=%r: cannot convert from %s" % (predCoordSys.getName(), _BadCoordSysDescr))
55 if measCoordSys.getName().lower()
in _BadCoordSysNameLCSet:
56 raise CommandError(
"Invalid toSys=%r: cannot convert to %s" % (measCoordSys.getName(), _BadCoordSysDescr))
62 doRestart = [
True]*tcc.base.NAxes,
64 earth = tccActor.earth,
66 telMod = tccActor.telMod,
67 axeLim = tccActor.axeLim,
73 zeroPVT = coordConv.PVT(0, 0, currTAI)
74 toSys = coordConv.OtherCoordSys(
"ptcorr", 0)
76 fromCoordSys = predCoordSys,
77 fromPVTPair = predPVTPair,
78 fromPxPMRadVel = predPxPMRadVel,
84 useGSWavelen = useGSWavelen,
87 measPtCorrXY, dumPxPMRadVel, measToFromAng, dumScaleChange =
coordConvWithFP(
88 fromCoordSys = measCoordSys,
89 fromPVTPair = measPVTPair,
90 fromPxPMRadVel = measPxPMRadVel,
96 useGSWavelen = useGSWavelen,
99 ptCorrXY = [pred - meas
for pred, meas
in itertools.izip(predPtCorrXY, measPtCorrXY)]
102 rotCtrXY = (coordConv.PVT(0, 0, currTAI), coordConv.PVT(0, 0, currTAI))
103 currPhysCoord, dumAzRotAng =
obsFromRot(rotCtrXY, obj, tccActor.inst, currTAI)
104 currPhysXY = tcc.base.ArrayPVT2()
105 currPhysCoord.getSphPVT(currPhysXY[0], currPhysXY[1])
106 desPhysXY = [currPhys + corr
for currPhys, corr
in itertools.izip(currPhysXY, ptCorrXY)]
107 currMountXY = obj.targetMount[0:2]
110 "ptCorr=%0.3f, %0.3f, %0.3f, %0.3f" % \
111 tuple(pvt.getPos(currTAI)
for pvt
in itertools.chain(ptCorrXY, predPtCorrXY)),
112 "ptData=%0.6f, %0.6f, %0.6f, %0.6f, %0.6f" % \
113 tuple(pvt.getPos(currTAI)
for pvt
in itertools.chain(desPhysXY, currMountXY, (obj.rotPhys,)),
117 msgStr =
"; ".join(msgStrList)
118 userCmd.setState(userCmd.Done, hubMsg=msgStr)
def getPVTPairPxPMRadVel
Obtain object data from a parsed command, and perform some sanity checks.
def getCoordSys
Obtain a coordinate system from a parsed parameter.
def coordConvWithFP
Convert a coord from one coordinate system to another.
def computeObj
Compute all computed obj fields from user-specified fields except path generator outputs.
def obsFromRot
Compute observed coordinates from rotator coordinates.