CARMA C++
Ephemeris.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 
25 #ifndef CARMA_SERVICES_EPHEMERIS_H
26 #define CARMA_SERVICES_EPHEMERIS_H
27 
28 // just in case (novas itself also define _NOVAS_)
29 // but *nobody* should ever need to know this. See also services::novasWrapper
30 #define HAVE_LIBNOVAS
31 
32 
33 // debug also uses some static variables, so don't use this in production mode
34 // where threading is used.
35 //#define EPHEM_DEBUG
36 
37 #include "carma/services/Vector.h"
39 #include "carma/services/Length.h"
41 #include "carma/services/Source.h"
46 #include "carma/services/novasWrapper.h"
47 
49 
50 
51 namespace carma {
52  namespace services {
53 
91  class Ephemeris {
92  public:
93 
104  Ephemeris();
105 
113  Ephemeris(const std::string &sourceName,
114  const std::string &catalogName="");
115 
117  virtual ~Ephemeris();
118 
124  Ephemeris(const Source &source);
125 
130  Ephemeris(const Location& location);
131 
132 
140  void setLocation(const Location &location);
141 
153  void setLocation(const std::string &observatory, bool topocentric=true);
154 
159  Location getLocation(void) const;
160 
161 
179  void setWeather(const double atmPressure, const double airTemp,
180  const double relHumid);
181 
191  void setFreq(const double freq);
192 
196  double getFreq( void ) const;
197 
205  void setRefraction(const bool refract);
206 
210  void setBody(const int type, const int number, const std::string &name);
211 
215  void setBody(const std::string &name);
216 
224  void setMJD(const double mjd=0);
225 
226  double getMJD() const
227  {
228  return mjd_;
229  }
230 
231 
248  void setDeltaT(const double deltat=0);
249 
256  void setSource(const Source &source);
257 
280  void setSource(const std::string& sourceName,
281  const std::string& catalogName = "");
282 
283 
287  void setEphemerisTableSource(const double ra2000, const double dec2000, const double doppler, const double distance);
288 
297  Source getSource();
298 
308  void setRaDecOffsets(const double dra, const double ddec);
309 
318  void setAzElOffsets(const double daz, const double del);
319 
320  // some user friendly things, all in the current epoch, topocentric
321 
326  double getRa(void);
327 
332  double getDec(void);
333 
338  double getAz(void);
339 
349  double getEl(void);
350 
359  double getRefrac(void) const;
360 
373 
387  Vector<double> getRaDec(double mjd, double az, double el);
388 
404  Vector<double> getAzEl(double mjd, double ra, double dec);
405 
406 
421  Vector<Angle> getAzEl(double mjd, const Angle &ra, const Angle &dec);
422 
427  void Debug(void);
428 
434  void planetDebug(void);
435 
446  double angle2000(void);
447 
448 
453  void ShowVector(void);
454 
469  void SetSpinningBodySpot(double majorAxis, double minorAxis, double axisAngle, double tiltAngle,
470  double mjd, double Longitude, double Latitude, double SpinRate);
471 
472 
473 
474  protected:
478  void initialize(void);
479 
492  double refract(const double elevation);
493 
501  void compute(void);
502 
507  void ComputeFixedAzEl(void);
508 
517  bool my_set_body(short int type, short int number, const std::string& sourceName);
518 
523  Vector<double> hms(double angle);
524 
529  Vector<double> dms(double angle);
530 
531 
532 
533 
534 
535 
536  private:
537  novas::body earth_; // novas:: *we* always observe from here body{0,3,'earth'}
538  std::string obs_; // name of the site (via Location)
539  novas::site_info site_; // novas:: where we are (a novas:: struct)
540  Location location_; // copy of the original Location object
541 
542  novas::body body_; // novas:: the 'other' point of interest (or: SolarSystemBody)
543  novas::cat_entry cat_; // novas:: source info (dra/ddec are normally applied to ra/dec)
544  novas::cat_entry fake_; // novas:: fake source for quick ra/dec -> az,al lookup (getAzEl)
545  bool is_cat_; // use body_ or cat_ to look at
546  bool is_eph_; // body to be obtained from an RADEC table ephemeris?
547  EphemerisTable et_; // if is_eph_, this is populated
548 
549  bool fixed_; // source is a fixed position on the planet (e.g. transmitter)
550  Location fixed_object_; // some nearby object that's fixed w.r.t. antennae
551  double fixed_az_; // the computed (az,el) of fixed_object_ as seen from antennae
552  double fixed_el_;
553 
554  double tjd_tt_; // TT time at site [julian date] -- not used at the time --
555  double tjd_; // JD at site [utc]
556  double mjd_; // MJD at site [utc]
557 
558  AstroTime at_; // our timekeeper (we don't use location dependant operations)
559 
560 
561  // things to look up from IERS tables
562  // IERSTable iers_;
563 
564 
565  double deltat_; // TT-UT1 [seconds]
566  double tdbmtdt_; // TDB-TDT [seconds] ** we don't use it **
567  double xpole_; // x-coordinate of celestial ephemeris pole w.r.t. IERS reference pole (arcsec)
568  double ypole_; // y-coordinate
569 
570  double freq_; // Observing frequency [Hz]
571  double relhum_; // Relative humidity [percent]
572  bool do_refract_; // overall boolean that controls if refraction applied
573 
574  Source source_; // alternate for source, if given
575  bool use_source_; // boolean to control what kind of 'source' is used (instead of ra/dec)
576  std::string sourceName_; // The source name
577  double ra2000_; // RA from catalog (J2000) [deg]
578  double dec2000_; // DEC from catalog (J2000) [deg]
579  // Offsets are applied either in Ra,Dec *or* Az,El, not both
580  int offsetMode_; // 0=none 1=ra/dec 2=az/el
581  double dra_; // offet applied to any RA for mosaicing etc. [deg]
582  double ddec_; // offet applied to any DEC for mosaicing etc.[deg]
583  double daz_; // offset in Az [deg]
584  double del_; // offset in El [deg]
585 
586  double ra_; // current RA/DEC, all topocentric [deg]
587  double dec_; // note these also have the DRA/DDEC applied [deg]
588  double dis_; // distance (0 if at infinity) [au]
589  double doppler_; // doppler velocity for this source [km/s]
590  double az_; // current AZ/EL [deg]
591  double el_; // note these have the DRA/DDEC applied [deg]
592  double vearth_; // local earth projection to source [km/s]
593  double vrest_; // LSR projection to source (note sign) [km/s]
594  double vplanet_; // planet projection to earth [km/s]
595 
596  double refr_; // refraction coefficient [deg]
597 
598  // Units units_; // aid for unit conversion
599  std::string jpleph_;// filename of JPL planet ephemeris catalog (usually CARMA/conf/data/ephem/jpl.eph)
600 
601  carma::services::Atmosphere atm_; // the atmosphere, for more sophosticated modeling (see also site_ )
602 
603  bool initialized_; // keep track of overall initialization (since we have a few "constructor" type entry points)
604  bool topocentric_; // topocentric (alternative is geocentric, which we actually don't officially use)
605  static const double deg2rad_; // 180/PI (multiply degrees with this to get to radians)
606  static const double rad2deg_; // PI/180 (multiply radians with this to get to degrees)
607 
608  bool recompute_; // need to call compute() to recompute state ?
609 #ifdef EPHEM_DEBUG
610  static int ncall_; // debugging, keep track how often expensive compute's are done
611 #endif
612 
629  void setSource(const double ra2000,
630  const double dec2000,
631  const double doppler,
632  const double distance = 0.0)
633  __attribute__((deprecated));
634 
635 
648  bool isEphem(const std::string& sourceName);
649 
655  bool isPlanet(const std::string& sourceName);
656 
657 public:
665  bool isFixed(const std::string& sourceName);
666 
671  bool useSource(void) const {
672  return use_source_;
673  }
674 
675 
676  }; // class Ephemeris
677  } // namespace services
678 } // namespace carma
679 
680 
681 #endif
double getRefrac(void) const
get the last used refraction correction.
double getDec(void)
get the topocentric DEC in the current epoch
Representation of Distance in any units.
Vector< double > getAzEl(double mjd, double ra, double dec)
Convert a given current epoch topocentric RA,DEC into AzEl.
void ComputeFixedAzEl(void)
compute the Az,El between two Location&#39;s, used internally
bool useSource(void) const
Was a true Source was used, or should sourcename string be used to re-use an ephemeris (important for...
Definition: Ephemeris.h:671
Vector< double > getRaDec(double mjd, double az, double el)
Convert a given current Az,El into Ra,Dec for the current site This is a somewhat peculiar routine...
double angle2000(void)
Compute the rotation of the coordinate system between the mean equatorial coordinates (ra...
double getEl(void)
get the Elevation, in radians.
This class is used to calculate a variety of quantities related to the earth&#39;s atmosphere, such as refractivity, saturated pressure, and pathlength (refractivity integrated through the atmosphere).
Definition: Atmosphere.h:46
Source is derived from CatalogEntry and is used to hold information for a particular entry from a sou...
Definition: Source.h:23
void setLocation(const Location &location)
Set the site information.
Ephemeris()
Construct a default Ephemeris.
unsigned int frameType
Half second frames since Jan 1, 2000.
Definition: types.h:29
void planetDebug(void)
debug routine to calculate and print parameters for planetary sources.
This class implements various astronomical time computation routines.
Definition: AstroTime.h:32
void Debug(void)
debug routine that dumps out the state of the Ephemeris with lots of human readable verbiage ...
virtual ~Ephemeris()
Destructor.
Representation of Length in any units.
bool isFixed(const std::string &sourceName)
find out if a source is a supported fixed source (e.g.
double getDoppler(velocityFrameType frameType=FRAME_TOPOGRAPHIC)
get the Doppler velocity in a specific frame of reference Note that normally you want the Topocentric...
void initialize(void)
initialize all variables for this class.
Vector< double > hms(double angle)
return a vector with (sign,H,M,S) values for a given angle 0..360 note that H and M will be integers ...
Ephemeris wraps the NOVAS library and any other ephemeris related functions into a simple to use clas...
Definition: Ephemeris.h:91
Astronomical Time routines.
void setFreq(const double freq)
update the observing frequency for refraction computation.
double getFreq(void) const
void setEphemerisTableSource(const double ra2000, const double dec2000, const double doppler, const double distance)
NB: private function.
double getAz(void)
get the Azimuth
double refract(const double elevation)
compute refraction angle.
Location getLocation(void) const
Location specifies a location (observatory if you wish) on planet earth, as longitude, latitude, and altitude above sea-level.
Definition: Location.h:32
void setDeltaT(const double deltat=0)
set the time correction, in seconds, added to the MJD to get dynamical time (TT or TDB)...
The Angle class can represent any angle in any units.
Definition: Angle.h:38
Access to an IERS table.
void ShowVector(void)
experiments with tracking spots on DE405 planets (object type=0)
void setBody(const int type, const int number, const std::string &name)
set a SolarSystemBody not implemented yet
double getRa(void)
get the topocentric RA in the current epoch
Constants and methods having to do with the earth&#39;s atmosphere (e.g.
Tagged: Tue May 4 15:49:11 PDT 2004.
Vector< double > dms(double angle)
return a vector with (sign,D,M,S) values for a given angle 0..360 note that D and M will be integers ...
void setWeather(const double atmPressure, const double airTemp, const double relHumid)
update the weather, such that refraction is more accurate.
void setRefraction(const bool refract)
Turn off refraction explicitly.
void setRaDecOffsets(const double dra, const double ddec)
sky offset in RA and DEC applied, until a new source has been specified.
With respect to a point on the earth&#39;s surface, e.g antenna coordinates.
Definition: Types.h:38
void setMJD(const double mjd=0)
set the time of observation (defaults to the current time) and a few ancillary variables (deltat...
void compute(void)
the internal ephemeris compute engine.
Representation of Velocity in any units.
enum carma::services::velocityFrameEnum velocityFrameType
The Velocity Frame.
Definition: Types.h:25
void setAzElOffsets(const double daz, const double del)
sky offset in AZ and EL applied, until a new source has been specified.
Special Ephemeris Table.
void SetSpinningBodySpot(double majorAxis, double minorAxis, double axisAngle, double tiltAngle, double mjd, double Longitude, double Latitude, double SpinRate)
Set properties to be passed to novas about spinning bodies in order to produce an emphemeris for a sp...
void setSource(const Source &source)
set a source (the catalog entry.
bool my_set_body(short int type, short int number, const std::string &sourceName)
NOVAS helper routine for isPlanet() to construct a NOVAS body for a particular planet sourceName is a...