Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/tcs_shim_8cc_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 01:16:12 2016
Кодировка:
lsst.tcc: src/tcsShim.cc Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tcsShim.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <sstream>
3 #include <stdexcept>
4 #include <slalib.h>
5 #include "coordConv/physConst.h"
6 #include "tcc/telConst.h"
7 #include "tcc/tcsShim.h"
8 
9 namespace tcc {
10  namespace tcspk {
11 
12  bool tcsFromPVT(double &pos, double &vel, coordConv::PVT const &pvt, double tai, bool isAz) {
13  bool isfinite = pvt.isfinite();
14  if (isfinite) {
15  pos = pvt.getPos(tai) * coordConv::RadPerDeg;
16  vel = pvt.vel * coordConv::RadPerDeg * coordConv::SecPerDay;
17  } else {
18  pos = 0;
19  vel = 0;
20  }
21  if (isAz) {
22  pos = coordConv::Pi - pos;
23  vel = -vel;
24  }
25  return isfinite;
26  }
27 
28  void pvtFromTCS(coordConv::PVT &pvt, double posArr[2], double tai, double deltaTAI, bool isAz) {
29  // slaDrange wraps an angle into the range [-pi, pi]
30  double locPosArr[2];
31  for (int i = 0; i < 2; ++i) {
32  if (isAz) {
33  locPosArr[i] = coordConv::Pi - posArr[i];
34  } else {
35  locPosArr[i] = posArr[i];
36  }
37  }
38  pvt.pos = locPosArr[0] / coordConv::RadPerDeg;
39  pvt.vel = slaDrange(locPosArr[1] - locPosArr[0]) / (coordConv::RadPerDeg * deltaTAI);
40  pvt.t = tai;
41  }
42  }
43 
44  std::ostream &operator<<(std::ostream &os, ASTROM const &astrom) {
45  os << "astrom.cosys " << astrom.cosys << " # Type of sky reference system; AZEL_TOPO=" << AZEL_TOPO << std::endl;
46  os << "astrom.eqx " << astrom.eqx << " # Equinox (for mean RA,Dec systems)" << std::endl;
47  os << "astrom.wavel " << astrom.wavel << " # Wavelength (micrometers)" << std::endl;
48  os << "astrom.refa " << astrom.refa << " # Refraction coefficient A" << std::endl;
49  os << "astrom.refb " << astrom.refb << " # Refraction coefficient B" << std::endl;
50  os << "astrom.sth " << astrom.sth << " # Sine of intermediate z-rotation" << std::endl;
51  os << "astrom.cth " << astrom.cth << " # Cosine of intermediate z-rotation" << std::endl;
52  os << "astrom.spm1 # Sky-patch matrix #1" << std::endl;
53  os << formatCMat<double, 3, 3>(astrom.spm1) << std::endl;
54  os << "astrom.spm1_i # Inverse sky-patch matrix #1" << std::endl;
55  os << formatCMat<double, 3, 3>(astrom.spm1_i) << std::endl;
56  os << "astrom.spm2 # Sky-patch matrix #2" << std::endl;
57  os << formatCMat<double, 3, 3>(astrom.spm2) << std::endl;
58  os << "astrom.spm2_i # Inverse sky-patch matrix #2" << std::endl;
59  os << formatCMat<double, 3, 3>(astrom.spm2_i) << std::endl;
60  return os;
61  }
62 
63  std::ostream &operator<<(std::ostream &os, FLDOR const &fldor) {
64  os << "fldor.sia cia " << fldor.sia << " " << fldor.cia << " # Sine and cosine of IAA" << std::endl;
65  os << "fldor.pai " << fldor.pai << " # Instrument Position-Angle" << std::endl;
66  os << "fldor.jf " << fldor.jf << " # Optimization: SLITO = " << SLITO << " = 1D (slit), FIELDO = " << FIELDO << " or else 2D (field)" << std::endl;
67  return os;
68  }
69 
70  std::ostream &operator<<(std::ostream &os, PORIG const &porig) {
71  os << "porig.p0 " << formatCArr(porig.p0, 2) << " # (x,y) position (user units)" << std::endl;
72  os << "porig.ob # Offset from base (user units)" << std::endl;
73  os << formatCMat<double, 3, 2>(porig.ob) << std::endl;
74  os << "porig.p " << formatCArr(porig.p, 2) << " # Current pointing-origin including offsets (user units)" << std::endl;
75  return os;
76  }
77 
78  std::ostream &operator<<(std::ostream &os, SITE const &site) {
79  os << "site.tlongm, tlatm " << site.tlongm << ", " << site.tlatm << " # Telescope longitude and latitude (radians)" << std::endl;
80  os << "site.tlong, tlat " << site.tlong << ", " << site.tlat << " # Telescope longitude and latitude (polar motion adjusted, radians)" << std::endl;
81  os << "site.slat, clat " << site.slat << ", " << site.clat << " # Functions of latitude" << std::endl;
82  os << "site.hm " << site.hm << " # Site elevation, metres above sea-level" << std::endl;
83  os << "site.diurab " << site.diurab << " # Diurnal aberration amplitude (radians)" << std::endl;
84  os << "site.daz " << site.daz << " # Azimuth correction (terrestrial-celestial, radians)" << std::endl;
85  os << "site.temp " << site.temp << " # Ambient temperature (K)" << std::endl;
86  os << "site.press " << site.press << " # Pressure (mB=hPa)" << std::endl;
87  os << "site.humid " << site.humid << " # Relative humidity (0-1)" << std::endl;
88  os << "site.tlr " << site.tlr << " # Tropospheric lapse rate (K per metre)" << std::endl;
89  os << "site.wavelr " << site.wavelr << " # Reference wavelength (micron) or minus frequency (GHz)" << std::endl;
90  os << "site.refar, refbr " << site.refar << ", " << site.refbr << " # Refraction coefficients for wavelr (radians)" << std::endl;
91  os << "site.rfun " << site.rfun << " # Optional refraction function" << std::endl;
92  os << "site.t0 " << site.t0 << " # Raw clock time at reference time" << std::endl;
93  os << "site.st0 " << site.st0 << " # LAST at reference time (radians)" << std::endl;
94  os << "site.tt0 " << site.tt0 << " # TT at reference time (MJD)" << std::endl;
95  os << "site.ttj " << site.ttj << " # TT at reference time (Julian Epoch)" << std::endl;
96  return os;
97  }
98 
99  std::ostream &operator<<(std::ostream &os, TARG const &targ) {
100  os << "targ.p0 " << formatCArr(targ.p0, 2) << " # Position at reference time (spherical coordinates, radians)" << std::endl;
101  os << "targ.dt " << formatCArr(targ.dt, 2) << " # Differential rates (radians/day)" << std::endl;
102  os << "targ.t0 " << targ.t0 << " # Reference time (TAI MJD days)" << std::endl;
103  os << "targ.ob # Offsets from base (radians, additive)" << std::endl;
104  os << formatCMat<double, 3, 2>(targ.ob) << std::endl;
105  os << "targ.op0 " << formatCArr(targ.op0, 2) << " # Position at reference time including offsets from base" << std::endl;
106  os << "targ.op " << formatCArr(targ.p, 2) << " # Current position including offsets and differential tracking" << std::endl;
107  return os;
108  }
109 
110  std::ostream &operator<<(std::ostream &os, TIMEO const &timeo) {
111  os << "timeo.ttmtai " << timeo.ttmtai << " # TT-TAI (day)" << std::endl;
112  os << "timeo.delat " << timeo.delat << " # TAI-UTC (day)" << std::endl;
113  os << "timeo.delut " << timeo.delut << " # UT1-UTC (day)" << std::endl;
114  os << "timeo.xpmr, ypmr " << timeo.xpmr << " " << timeo.ypmr << " # Polar motion angle in x, y (radians)" << std::endl;
115  return os;
116  }
117 
118  std::ostream &operator<<(std::ostream &os, TSCOPE const &tscope) {
119  os << "tscope.fl " << tscope.fl << " # Telescope focal length (user units)" << std::endl;
120  os << "tscope.mount " << tscope.mount << " # Mount type; ALTAZ=" << ALTAZ << std::endl;
121  os << "tscope.rotl " << tscope.rotl << " # Location of instrument rotator:"
122  << " OTA=" << OTA
123  << " NASMYTH_L=" << NASMYTH_L
124  << " NASMYTH_R=" << NASMYTH_R
125  << std::endl;
126  os << "tscope.rnogo " << tscope.rnogo << " # Mount pole avoidance distance (radians)" << std::endl;
127  os << "tscope.ae2nm # Rotation matrix, [Az,El] to nominal mount" << std::endl;
128  os << formatCMat<double, 3, 3>(tscope.ae2nm) << std::endl;
129  os << "tscope.ae2mt # Rotation matrix, [Az,El] to actual mount" << std::endl;
130  os << formatCMat<double, 3, 3>(tscope.ae2mt) << std::endl;
131  os << "tscope.ia " << tscope.ia << " # Roll zero point (radians)" << std::endl;
132  os << "tscope.ib " << tscope.ib << " # Pitch zero point (radians)" << std::endl;
133  os << "tscope.np " << tscope.np << " # Mount axes nonperpendicularity (radians)" << std::endl;
134  os << "tscope.xt " << tscope.xt << " # Telescope vector, x" << std::endl;
135  os << "tscope.yt " << tscope.yt << " # Telescope vector, y" << std::endl;
136  os << "tscope.zt " << tscope.zt << " # Telescope vector, z" << std::endl;
137  return os;
138  }
139 
140  template <typename T>
141  std::string formatCArr(T const*arr, int n) {
142  std::ostringstream os;
143  os << std::setprecision(12);
144  for (int i = 0; i < n; ++i) {
145  if (i > 0) {
146  os << " ";
147  }
148  os << arr[i];
149  }
150  return os.str();
151  }
152 
153  template <typename T, int ROWS, int COLS>
154  std::string formatCMat(T const mat[ROWS][COLS]) {
155  std::ostringstream os;
156  for (int r = 0; r < ROWS; ++r) {
157  os << " " << formatCArr(mat[r], COLS);
158  if (r < ROWS-1) {
159  os << std::endl;
160  }
161  }
162  return os.str();
163  }
164 
165 }
bool tcsFromPVT(double &pos, double &vel, coordConv::PVT const &pvt, double tai, bool isAz=false)
Definition: tcsShim.cc:12
void pvtFromTCS(coordConv::PVT &pvt, double posArr[2], double tai, double deltaTAI, bool isAz=false)
Definition: tcsShim.cc:28
std::string formatCArr(T const arr[], int n)
std::ostream & operator<<(std::ostream &os, ChebyshevPolynomial const &cheby)
Definition: cheby.cc:12
double tai()
Definition: tai.cc:7
std::string formatCMat(T const mat[ROWS][COLS])
Definition: tcsShim.cc:154