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

Поисковые слова: regolith
lsst.tcc: python/tcc/cmd/ptCorr.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ptCorr.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 import itertools
4 
5 import coordConv
6 from twistedActor import CommandError
7 
8 import tcc.base
9 from tcc.axis import computeObj, coordConvWithFP, obsFromRot
10 from tcc.parse import getPVTPairPxPMRadVel, getCoordSys
11 
12 __all__ = ["ptCorr"]
13 
14 _BadCoordSysNameList = ("mount", "none")
15 _BadCoordSysNameLCSet = set(csName.lower() for csName in _BadCoordSysNameList)
16 _BadCoordSysDescr = " or ".join(_BadCoordSysNameList)
17 del _BadCoordSysNameList # avoid accidental misuse when _BadCoordSysNameLCSet is wanted
18 
19 def ptCorr(tccActor, userCmd):
20  """Implement the ptCorr command
21 
22  @param[in,out] tccActor tcc actor
23  @param[in,out] userCmd user command
24  """
25  parsedCmd = userCmd.parsedCmd
26  qualDict = parsedCmd.qualDict
27 
28  currTAI = tcc.base.tai()
29 
30  # use a copy of obj so we can safely update it at current time
31  # and even swap obj.site if using GS wavelength
32  obj = tcc.base.Obj(tccActor.obj)
33 
34  # it may seem tempting to make this automatic if toSys is guide (yes) or inst (no),
35  # but the guider may be the inst for ptcorr, so I doubt it's wise
36  useGSWavelen = qualDict["usegswavelength"].boolValue
37 
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")
44 
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")
52 
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))
57 
58  # update object block so focal-plane math is correct
59  computeObj(
60  obj,
61  doWrap = False,
62  doRestart = [True]*tcc.base.NAxes,
63  reportLim = False,
64  earth = tccActor.earth,
65  inst = tccActor.inst,
66  telMod = tccActor.telMod,
67  axeLim = tccActor.axeLim,
68  tai = measTAI,
69  )
70 
71  # convert pred and meas to "PtCorr" coordinates (rotator, but aligned such that x = increasing azimuth)
72 
73  zeroPVT = coordConv.PVT(0, 0, currTAI)
74  toSys = coordConv.OtherCoordSys("ptcorr", 0)
75  predPtCorrXY = coordConvWithFP(
76  fromCoordSys = predCoordSys,
77  fromPVTPair = predPVTPair,
78  fromPxPMRadVel = predPxPMRadVel,
79  fromDir = zeroPVT,
80  toCoordSys = toSys,
81  obj = obj,
82  inst = tccActor.inst,
83  zeroPM = True,
84  useGSWavelen = useGSWavelen,
85  )[0]
86 
87  measPtCorrXY, dumPxPMRadVel, measToFromAng, dumScaleChange = coordConvWithFP(
88  fromCoordSys = measCoordSys,
89  fromPVTPair = measPVTPair,
90  fromPxPMRadVel = measPxPMRadVel,
91  fromDir = zeroPVT,
92  toCoordSys = toSys,
93  obj = obj,
94  inst = tccActor.inst,
95  zeroPM = True,
96  useGSWavelen = useGSWavelen,
97  )
98 
99  ptCorrXY = [pred - meas for pred, meas in itertools.izip(predPtCorrXY, measPtCorrXY)]
100 
101  # compute desired phys (obs at ctr of rot after correction)
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]
108 
109  msgStrList = [
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,)),
114  )
115  ]
116 
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 ptCorr
Definition: ptCorr.py:19
def getCoordSys
Obtain a coordinate system from a parsed parameter.
Definition: getCoordSys.py:31
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.
Definition: computeObj.py:22
def obsFromRot
Compute observed coordinates from rotator coordinates.
Definition: obsFromRot.py:10