1 from __future__
import division, absolute_import
4 from twistedActor
import CommandError
6 from .getPVTList
import getPVTList
9 __all__ = [
"getPVTPairPxPMRadVel"]
12 """!Obtain object data from a parsed command, and perform some sanity checks
14 Read one parameter that contains pos1, pos2, [vel1, [vel2, [tai]]]
15 and the following qualifiers: /Distance /Px /PM /RV.
17 @param[in] parsedCmd the parsed command
18 @param[in] coordName name of coord parameter
19 @param[in] defTAI TAI date to use if time not specified (MJD, seconds)
21 - pvtPair: a pair of PVTs (tcc.base.ArrayPVT2), or None if the pvt parameter is absent
22 - pxPMRadVel: parallax, proper motion and radial velocity, as a tcc.base.PxPMRadVel
24 @throw twistedActor.CommandError under the following circumstances:
25 - /Distance and /Px are both specified
26 - Any of /Distance /Px /PM /RV is specified and no position is provided
28 pvtParam = parsedCmd.paramDict[coordName]
29 if pvtParam.defaulted:
31 if not parsedCmd.qualDict[
"distance"].boolValueDefaulted:
32 raise CommandError(
"Must specify new position to specify /Distance")
33 if not parsedCmd.qualDict[
"px"].boolValueDefaulted:
34 raise CommandError(
"Must specify new position to specify /Px")
35 if not parsedCmd.qualDict[
"pm"].boolValueDefaulted:
36 raise CommandError(
"Must specify new position to specify /PM")
37 if not parsedCmd.qualDict[
"rv"].boolValueDefaulted:
38 raise CommandError(
"Must specify new position to specify /RV")
40 return None, tcc.base.PxPMRadVel()
42 if not parsedCmd.qualDict[
"distance"].boolValueDefaulted
and not parsedCmd.qualDict[
"px"].boolValueDefaulted:
43 raise CommandError(
"Cannot specify both /Distance and /Px")
45 numVals = len(pvtParam.valueList)
46 if numVals
not in (2, 4, 5):
47 raise CommandError(
"Must specify one of pos, pos + vel or pos + vel + tai")
49 pvtPair = tcc.base.ArrayPVT2()
50 (equatPVT, polarPVT) =
getPVTList(pvtParam, numAxes=2, defTAI=defTAI)[0]
51 pvtPair[:] = equatPVT, polarPVT
52 if parsedCmd.qualDict[
"distance"].boolValueDefaulted:
53 parallax = parsedCmd.qualDict[
"px"].valueList[0]
55 distList = parsedCmd.qualDict[
"distance"].valueList
56 if len(distList) == 0:
59 parallax = coordConv.parallaxFromDistance(distList[0])
60 equatPM, polarPM = parsedCmd.qualDict[
"pm"].valueList[0:2]
61 radVel = parsedCmd.qualDict[
"rv"].valueList[0]
62 pxPMRadVel = tcc.base.PxPMRadVel(parallax, equatPM, polarPM, radVel)
64 return pvtPair, pxPMRadVel
def getPVTPairPxPMRadVel
Obtain object data from a parsed command, and perform some sanity checks.
def getPVTList
Obtain a list of PVTs from a PVT list parameter.