FACT++  1.0
PointingData PointingModel::CalcPointingPos ( const PointingSetup setup,
double  _mjd,
const Weather weather,
uint16_t  timeout,
bool  tpoint = false 
)
inline

Definition at line 365 of file drivectrl.cc.

References PointingData::apparent, Local::az, Connection::Connection(), RaDec::dec, Source::dec, RaDecHa::ha, height, hum, Weather::hum, kENone, lat, PointingData::mjd, PointingData::mount, PointingSetup::orbit_period, Nova::ORM(), palAmpqk(), palAoppa(), palAopqk(), palDtt(), palMappa(), palMapqkz(), palRdplan(), PointingSetup::planet, PointingData::pointing, Weather::press, RaDec::ra, Source::ra, PointingData::sky, PointingSetup::source, PointingData::source, PointingSetup::start, temp, Weather::temp, Weather::time, valid(), PointingSetup::wobble_angle, PointingSetup::wobble_offset, and Local::zd.

Referenced by StateMachineDrive< T, S >::CalcPointingPos(), and StateMachineDrive< T, S >::HandleTPoint().

366  {
367  PointingData out;
368  out.mjd = _mjd;
369 
370  const double elong = Nova::ORM().lng * M_PI/180;
371  const double lat = Nova::ORM().lat * M_PI/180;
372  const double height = 2200;
373 
374  const bool valid = weather.time+boost::posix_time::seconds(timeout) > Time();
375 
376  const double temp = valid ? weather.temp : 10;
377  const double hum = valid ? weather.hum : 0.25;
378  const double press = valid ? weather.press : 780;
379 
380  const double dtt = palDtt(_mjd); // 32.184 + 35
381 
382  const double tdb = _mjd + dtt/3600/24;
383  const double dut = 0;
384 
385  // prepare calculation: Mean Place to geocentric apperent
386  // (UTC would also do, except for the moon?)
387  double fAmprms[21];
388  palMappa(2000.0, tdb, fAmprms); // Epoche, TDB
389 
390  // prepare: Apperent to observed place
391  double fAoprms[14];
392  palAoppa(_mjd, dut, // mjd, Delta UT=UT1-UTC
393  elong, lat, height, // long, lat, height
394  0, 0, // polar motion x, y-coordinate (radians)
395  273.155+temp, press, hum, // temp, pressure, humidity
396  0.40, 0.0065, // wavelength, tropo lapse rate
397  fAoprms);
398 
399  out.source.ra = setup.source.ra * M_PI/ 12;
400  out.source.dec = setup.source.dec * M_PI/180;
401 
402  if (setup.planet!=kENone)
403  {
404  // coordinates of planet: topocentric, equatorial, J2000
405  // One can use TT instead of TDB for all planets (except the moon?)
406  double ra, dec, diam;
407  palRdplan(tdb, setup.planet, elong, lat, &ra, &dec, &diam);
408 
409  // ---- apparent to mean ----
410  palAmpqk(ra, dec, fAmprms, &out.source.ra, &out.source.dec);
411  }
412 
413  if (setup.wobble_offset<=0 || tpoint)
414  {
415  out.pointing.dec = out.source.dec;
416  out.pointing.ra = out.source.ra;
417  }
418  else
419  {
420  const double dphi =
421  setup.orbit_period==0 ? 0 : 2*M_PI*(_mjd-setup.start)/setup.orbit_period;
422 
423  const double phi = setup.wobble_angle + dphi;
424 
425  const double cosdir = cos(phi);
426  const double sindir = sin(phi);
427  const double cosoff = cos(setup.wobble_offset);
428  const double sinoff = sin(setup.wobble_offset);
429  const double cosdec = cos(out.source.dec);
430  const double sindec = sin(out.source.dec);
431 
432  const double sintheta = sindec*cosoff + cosdec*sinoff*cosdir;
433 
434  const double costheta = sintheta>1 ? 0 : sqrt(1 - sintheta*sintheta);
435 
436  const double cosdeltara = (cosoff - sindec*sintheta)/(cosdec*costheta);
437  const double sindeltara = sindir*sinoff/costheta;
438 
439  out.pointing.dec = asin(sintheta);
440  out.pointing.ra = atan2(sindeltara, cosdeltara) + out.source.ra;
441  }
442 
443  // ---- Mean to apparent ----
444  double r=0, d=0;
445  palMapqkz(out.pointing.ra, out.pointing.dec, fAmprms, &r, &d);
446 
447  //
448  // Doesn't work - don't know why
449  //
450  // slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
451  // 0, 0, (double*)fAmprms, &r, &d);
452  //
453 
454  // -- apparent to observed --
455  palAopqk(r, d, fAoprms,
456  &out.sky.az, // observed azimuth (radians: N=0,E=90) [-pi, pi]
457  &out.sky.zd, // observed zenith distance (radians) [-pi/2, pi/2]
458  &out.apparent.ha, // observed hour angle (radians)
459  &out.apparent.dec, // observed declination (radians)
460  &out.apparent.ra); // observed right ascension (radians)
461 
462  // ----- fix ambiguity -----
463  if (out.sky.zd<0)
464  {
465  out.sky.zd = -out.sky.zd;
466  out.sky.az += out.sky.az<0 ? M_PI : -M_PI;
467  }
468 
469  // Star culminating behind zenith and Az between ~90 and ~180deg
470  if (out.source.dec<lat && out.sky.az>0)
471  out.sky.az -= 2*M_PI;
472 
473  out.mount = SkyToMount(out.sky);
474 
475  return out;
476  }
float press
Definition: drivectrl.cc:111
float hum
Definition: drivectrl.cc:109
const LnLatPosn & ORM()
Definition: nova.h:66
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
RaDec pointing
Definition: drivectrl.cc:165
RaDecHa apparent
Definition: drivectrl.cc:166
double zd
Definition: drivectrl.cc:51
RaDec source
Definition: drivectrl.cc:164
float temp
Definition: HeadersPFmini.h:56
float temp
Definition: drivectrl.cc:110
void palAmpqk(double ra, double da, double amprms[21], double *rm, double *dm)
Definition: palAmpqk.c:85
double start
Definition: drivectrl.cc:153
double az
Definition: drivectrl.cc:52
double palDtt(double dju)
Definition: palDtt.c:75
void palMappa(double eq, double date, double amprms[21])
Definition: palMappa.c:94
void palAopqk(double rap, double dap, const double aoprms[14], double *aob, double *zob, double *hob, double *dob, double *rob)
Definition: palAopqk.c:179
double dec
Definition: drivectrl.cc:37
double ha
Definition: drivectrl.cc:44
float lat
Definition: HeadersGPS.h:23
double wobble_angle
Definition: drivectrl.cc:156
bool valid() const
Definition: HeadersFTM.h:271
double dec
Definition: drivectrl.cc:125
Encoder mount
Definition: drivectrl.cc:168
float hum
Definition: HeadersPFmini.h:55
Source source
Definition: drivectrl.cc:151
float height
Definition: HeadersGPS.h:26
double ra
Definition: drivectrl.cc:124
double wobble_offset
Definition: drivectrl.cc:155
Time time
Definition: drivectrl.cc:112
Encoder SkyToMount(AltAz p)
Definition: drivectrl.cc:271
void palRdplan(double date, int np, double elong, double phi, double *ra, double *dec, double *diam)
Definition: palRdplan.c:101
Planets_t planet
Definition: drivectrl.cc:152
double orbit_period
Definition: drivectrl.cc:154
void palAoppa(double date, double dut, double elongm, double phim, double hm, double xp, double yp, double tdk, double pmb, double rh, double wl, double tlr, double aoprms[14])
Definition: palAoppa.c:172
void palMapqkz(double rm, double dm, double amprms[21], double *ra, double *da)
Definition: palMapqkz.c:97
double ra
Definition: drivectrl.cc:36
double mjd
Definition: drivectrl.cc:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function: