1 from __future__
import division, absolute_import
6 from .instFromObs
import instFromObs
7 from .gProbeFromObs
import gProbeFromObs
8 from .gImageFromObs
import gImageFromObs
9 from .ptCorrFromObs
import ptCorrFromObs
10 from .rotFromObs
import rotFromObs
11 from .obsFromInst
import obsFromInst
12 from .obsFromGProbe
import obsFromGProbe
13 from .obsFromGImage
import obsFromGImage
14 from .obsFromPtCorr
import obsFromPtCorr
15 from .obsFromRot
import obsFromRot
17 __all__ = [
"coordConvWithFP"]
19 FPNames = set((
"instrument",
"gprobe",
"gimage",
"ptcorr",
"rotator"))
22 def coordConvWithFP(fromCoordSys, fromPVTPair, fromPxPMRadVel, fromDir, toCoordSys, obj, inst, zeroPM, useGSWavelen):
23 """!Convert a coord from one coordinate system to another
25 The conversion is performed at obj.updateTime; you may wish to call computeObj
26 before calling this subroutine to set that to your desired date.
28 @param[in] fromCoordSys from coordinate system; a coordConv.CoordSys
29 if one matches, else an object containing getName() and getDate()
30 (for gimage and gprobe coordinates the date is the guide probe number)
31 @param[in] fromPVTPair from position (equatorial or focal plane x,y, depending on fromSys)
32 @param[in] fromPxPMRadVel from parallax, proper motion and radial velocity
33 @param[in] fromDir from direction as a coordConv.PVT
34 @param[in] toCoordSys to coordinate system (a coordConv.CoordSys)
35 @param[in] obj object block computed at desired desired TAI date of conversion
36 @param[in] inst instrument block
37 @param[in] zeroPM zero proper motion and parallax to the current date?
38 Ignored unless fromCoordSys and toCoordSys are both mean, since otherwise proper motion is always zeroed.
39 @param[in] useGSWavelen use guide star wavelength? else use object wavelength
42 - toPVTPair: resulting pair of PVTs (equatorial or x,y, depending on toSys)
43 - toPxPMRadVel: resulting parallax, proper motion and radial velocity
44 - toDir: angle of fromDir in the "to" system, as a coordConv.PVT
45 - scaleChange: change in scale (a float): output delta sky/input delta sky, measured along the specified direction
47 taiDate = obj.updateTime
50 obj = tcc.base.Obj(obj)
52 if fromCoordSys.isMean()
and toCoordSys.isMean()
and not zeroPM:
56 toDir = coordConv.PVT()
57 toPVTCoord, scaleChange = toCoordSys.convertFrom(toDir, fromCoordSys, fromPVTCoord, fromDir, obj.site)
58 toPVTPair, toPxPMRadVel = tcc.base.pvtPairFromPVTCoord(toPVTCoord)
60 return toPVTPair, toPxPMRadVel, toDir, scaleChange
68 fromSysName = fromCoordSys.getName().lower()
69 if fromSysName
in FPNames:
70 intFromSys = obj.obsSysPtr
72 if fromSysName ==
"instrument":
73 intFromPVTCoord, fromAzIntAng =
obsFromInst(fromPVTPair, obj, taiDate)
74 elif fromSysName ==
"gimage":
75 gProbeNum = int(fromCoordSys.getDate())
76 intFromPVTCoord, fromAzIntAng =
obsFromGImage(fromPVTPair, gProbeNum, obj, inst, taiDate)
77 elif fromSysName ==
"gprobe":
78 gProbeNum = int(fromCoordSys.getDate())
79 intFromPVTCoord, fromAzIntAng =
obsFromGProbe(fromPVTPair, gProbeNum, obj, inst, taiDate)
80 elif fromSysName ==
"ptcorr":
81 intFromPVTCoord, fromAzIntAng =
obsFromPtCorr(fromPVTPair, obj, inst, taiDate)
82 elif fromSysName ==
"rotator":
83 intFromPVTCoord, fromAzIntAng =
obsFromRot(fromPVTPair, obj, inst, taiDate)
85 raise RuntimeError(
"Bug: unknown from focal plane coordinate system %s" % (fromCoordSys,))
86 intFromDir = fromDir - fromAzIntAng
90 intFromSys = fromCoordSys
95 toSysName = toCoordSys.getName().lower()
96 if toSysName
in FPNames:
98 intToSys = obj.obsSysPtr
99 intToDir = coordConv.PVT()
100 intToPVTCoord, scaleChange = intToSys.convertFrom(intToDir, intFromSys, intFromPVTCoord, intFromDir, obj.site)
103 if toSysName ==
"instrument":
104 toPVTPair, targAzToAng =
instFromObs(intToPVTCoord, obj, taiDate)
105 elif toSysName ==
"gprobe":
106 gProbeNum = int(toCoordSys.getDate())
107 toPVTPair, targAzToAng =
gProbeFromObs(intToPVTCoord, gProbeNum, obj, inst, taiDate)
108 elif toSysName ==
"gimage":
109 gProbeNum = int(toCoordSys.getDate())
110 toPVTPair, targAzToAng =
gImageFromObs(intToPVTCoord, gProbeNum, obj, inst, taiDate)
111 elif toSysName ==
"ptcorr":
112 toPVTPair, targAzToAng =
ptCorrFromObs(intToPVTCoord, obj, inst, taiDate)
113 elif toSysName ==
"rotator":
114 toPVTPair, targAzToAng =
rotFromObs(intToPVTCoord, obj, inst, taiDate)
116 raise RuntimeError(
"Bug: unknown to focal plane coordinate system %s" % (toCoordSys,))
118 toPxPMRadVel = tcc.base.PxPMRadVel()
119 toDir = intToDir + targAzToAng
123 toDir = coordConv.PVT()
124 toPVTCoord, scaleChange = toCoordSys.convertFrom(toDir, intFromSys, intFromPVTCoord, intFromDir, obj.site)
125 toPVTPair, toPxPMRadVel = tcc.base.pvtPairFromPVTCoord(toPVTCoord)
127 return toPVTPair, toPxPMRadVel, toDir, scaleChange
def rotFromObs
Compute instrument position from observed coordinates.
def obsFromGProbe
Compute observed coordinates from guide probe coordinates.
def ptCorrFromObs
Compute pointing correction position from observed coordinates.
def obsFromGImage
Compute observed coordinates from guide probe coordinates.
def obsFromPtCorr
Compute observed coordinates from pointing correction coordinates.
def obsFromInst
Compute observed coordinates from instrument coordinates.
def coordConvWithFP
Convert a coord from one coordinate system to another.
def instFromObs
Compute instrument position from observed coordinates.
def gProbeFromObs
Compute guide probe position from observed coordinates.
def gImageFromObs
Compute guide probe position from observed coordinates.
def obsFromRot
Compute observed coordinates from rotator coordinates.