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

Поисковые слова: запрещенные спектральные линии
lsst.tcc: python/tcc/axis/oneSlewIter.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
oneSlewIter.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 import sys
4 
5 import tcc.base
6 import tcc.mov
7 
8 __all__ = ["oneSlewIter"]
9 
10 MinPVTSep = 0.05 # minimum separation between PVTs, in sec
11  # Warning: this only controls whether a final PVT is added to the slew;
12  # for other PVTs the separation is controlled by other factors, such as the jerk limit.
13  # The value should be significantly less than the track advance time.
14 
15 def oneSlewIter(doAxis, oldMount, newMount, begTime, minTime, axeLim):
16  """!Compute a slew for all axes, given the starting and target paths.
17 
18  @param[in] doAxis slew this axis? A sequence of NAxes bools
19  @param[in] oldMount initial position, as a list of NAxes PVTs
20  @param[in] newMount target coordinates, as a list of NAxes PVTs
21  @param[in] begTime start time (TAI, MJD sec)
22  @param[in] minTime minimum slew duration (sec)
23  @param[in] axeLim axes limits, as an tcc.base.AxeLim
24  where NAxes = tcc.base.NAxes
25 
26  @return two items:
27  - pathList: a list of NAxes pvtLists, where each pvtList is a list of PVTs describing the motion of that axis;
28  if doAxis[axis] is false then pathList[axis] is an empty list
29  - endTime: end time of slew (TAI, MJD sec)
30 
31  @throw RuntimeError if the slew ends too soon or cannot be computed
32 
33  If no axes are to be slewed (slew not requested, or beginning or ending
34  position is unknown), then endTime = begTime + minTime. No warning is given.
35 
36  History:
37  2013-12-06 ROwen Converted from doSlew.for
38  """
39  def formatArgs():
40  return "tcc.mov.oneSlewIter(doAxis=%s, oldMount=%s, newMount=%s, begTime=%r, minTime=%r)" % \
41  (doAxis, oldMount, newMount, begTime, minTime)
42 
43  def reportBug(msgStr):
44  """!Write a detailed message to stderr and raise RuntimeError"""
45  sys.stderr.write("%s failed:\n%s\n" % (formatArgs(), msgStr))
46  raise RuntimeError(msgStr)
47 
48  # begin
49  # set endTime and nNodes to the values they'll have
50  # if no axes are to be slewed.
51  pathList = [[]]*tcc.base.NAxes
52 
53  # Compute a slew for each axis (skip those with unknown beginning
54  # or ending positions), and find out when the longest slew ends
55  endTime = 0
56  for axis in range(tcc.base.NAxes):
57  oldPVT = oldMount[axis]
58  newPVT = newMount[axis]
59  if doAxis[axis] and oldPVT.isfinite() and newPVT.isfinite():
60  # compute the slew
61  # note that tcc.mov.slew wants both pA and pB at the start time,
62  # and it returns a path whose times are shifted so the start time is 0
63  try:
64  pvtList = tcc.mov.slew(
65  pA = oldPVT.getPos(begTime),
66  vA = oldPVT.vel,
67  pB = newPVT.getPos(begTime),
68  vB = newPVT.vel,
69  tMin = minTime,
70  axisLim = axeLim[axis],
71  )
72  except Exception:
73  sys.stderr.write("%s failed on axis %s when calling tcc.mov.slew\n" % (formatArgs(), axis))
74  raise
75 
76  # shift the times of the path PVTs to start at begTime instead of 0
77  for pvt in pvtList:
78  pvt.t += begTime
79 
80  endTime = max(endTime, pvtList[-1].t)
81  pathList[axis] = list(pvtList)
82 
83  # Add a new node to the slew for each axis except the longest,
84  # so that all axes end their slew at the same time (endTime).
85  for axis in range(tcc.base.NAxes):
86  pvtList = pathList[axis]
87  if len(pvtList) > 0:
88  lastPVT = pvtList[-1]
89  if lastPVT.t < endTime - MinPVTSep:
90  endPVT = newMount[axis].copy(endTime)
91  pvtList.append(endPVT)
92 
93  # if any axis is being slewed, make sure the slew takes long enough
94  if (endTime > 0.0) and (endTime < begTime + minTime):
95  reportBug("Bug! Computed slew ended too soon; endTime=%s" % (endTime,))
96 
97  return pathList, endTime
def oneSlewIter
Compute a slew for all axes, given the starting and target paths.
Definition: oneSlewIter.py:15