38 #define G_EPHEMERIS "GEphemerides::ephemeris(GTime&, GVector*, GVector*, "\
40 #define G_FETCH_DATA "GEphemerides::fetch_data()"
115 if (
this != &ephemerides) {
179 GFits fits(filename);
185 int num = ephem->
nrows();
200 double tstart = ephem->
real(
"TSTART");
210 for (
int i = 0; i < num; ++i) {
214 time.
jd(tstart +
double(i));
218 ptr_earth->
real(i,1),
219 ptr_earth->
real(i,2));
221 ptr_earth->
real(i,4),
222 ptr_earth->
real(i,5));
224 ptr_earth->
real(i,7),
225 ptr_earth->
real(i,8));
227 ptr_earth->
real(i,10),
228 ptr_earth->
real(i,11));
234 double tbd2tt = ptr_tbd2tt->
real(i);
242 m_sun.push_back(sun);
284 double jd = time.
jd(
"UTC");
285 int jd_utc = int(jd);
292 double dt = time.
jd(
"TT") - double(
int(time.
jd(
"TT")));
304 std::string msg =
"Time JD "+
gammalib::str(jd_utc)+
" is before "
306 "ephemerides. Please specify a time later than "
307 "the validity start.";
310 else if (jd_utc > jd1) {
311 std::string msg =
"Time JD "+
gammalib::str(jd_utc)+
" is after "
313 "ephemerides. Please specify a time earlier than "
319 int index = jd_utc - jd0;
327 const double c1 = 1.0/2.0;
328 const double c2 = 1.0/6.0;
345 *etut =
m_tdb2tt[index] + dt * tbd2tt_dot;
363 const double t_sun = 4.92549089483e-6;
364 const double r_sun = 2.315;
371 ephemeris(time, &rce, &rcs, &vce, &etut);
377 double light_travel_time = dir * rce;
382 double sundis =
norm(rsa);
384 double cos_theta = (dir * rsa) / sundis;
394 double shapiro_delay = -2.0 * t_sun *
std::log(1.0 + cos_theta);
398 double geo2ssb = light_travel_time - shapiro_delay + etut;
422 const double t_sun = 4.92549089483e-6;
423 const double r_sun = 2.315;
431 ephemeris(time, &rce, &rcs, &vce, &etut);
434 GVector rca = rce + obs * inv_c;
440 double light_travel_time = dir * rca;
445 double sundis =
norm(rsa);
447 double cos_theta = (dir * rsa) / sundis;
457 double shapiro_delay = -2.0 * t_sun *
std::log(1.0 + cos_theta);
461 double geo2ssb = light_travel_time - shapiro_delay + etut;
483 result.append(
"=== GEphemerides ===");
493 result.append(
" - ");
497 result.append(
" - ");
587 GFilename filename(
"$GAMMALIB/share/refdata/ephem_jpl_de200.fits");
600 GFilename src_filename(
"$TEST_SRCDIR/refdata/ephem_jpl_de200.fits");
609 std::string msg =
"Could not find ephemerides file in \""+
610 filename.
url()+
"\" or in \""+
611 src_filename.
url()+
"\". Unable to return "
612 "information based on ephemerides.";
GFilename m_filename
Ephemerides filename.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void copy_members(const GEphemerides &ephemerides)
Copy class members.
double norm(const GVector &vector)
Computes vector norm.
Sky direction class interface definition.
std::string m_name
Ephemerides (e.g. DE200)
bool is_empty(void) const
Signals if there are no ephemerides.
void clear(void)
Clear time.
FITS file class interface definition.
FITS table column abstract base class definition.
double jd(void) const
Return time in Julian Days (TT)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Ephemerides.
virtual GEphemerides * clone(void) const
Clone Ephemerides.
GEphemerides & operator=(const GEphemerides &ephemerides)
Assignment operator.
double real(const std::string &keyname) const
Return card value as double precision.
Ephemerides class definition.
GEphemerides(void)
Void constructor.
const double speed_of_light
Abstract interface for FITS table column.
double geo2ssb(const GSkyDir &srcdir, const GTime &time) const
Get time difference between geocentric and SSB (seconds)
void celvector(const GVector &vector)
Set sky direction from 3D vector in celestial coordinates.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
void init_members(void)
Initialise class members.
Abstract interface for FITS table.
virtual void clear(void)
Clear Ephemerides.
bool is_fits(void) const
Checks whether file is a FITS file.
std::vector< GTime > m_times
Times of vectors.
void ephemeris(const GTime &time, GVector *rce, GVector *rcs, GVector *vce, double *etut) const
Get ephemeris vector and TBD->TT value for a given time.
std::vector< GVector > m_earth_dt
First derivative of Earth vectors.
void load(const GFilename &filename)
Load Ephemerides.
const int & nrows(void) const
Return number of rows in table.
std::vector< double > m_tdb2tt
TBD to TT conversion term.
std::vector< GVector > m_earth_d3t
Third derivative of Earth vectors.
GTime m_tstop
Ephemerides validity stop time.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual ~GEphemerides(void)
Destructor.
void clear(void)
Clear file name.
virtual double real(const int &row, const int &inx=0) const =0
std::vector< GVector > m_earth
Earth vectors.
void fetch_data(void)
Fetch ephemerides data.
void free_members(void)
Delete class members.
std::string string(const std::string &keyname) const
Return card value as string.
GTime m_tstart
Ephemerides validity start time.
double mjd(void) const
Return time in Modified Julian Days (TT)
std::vector< GVector > m_earth_d2t
Second derivative of Earth vectors.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
int size(void) const
Return number of ephemerides.
std::vector< GVector > m_sun
Sun vectors.
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.