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.";
Ephemerides class definition.
FITS table column abstract base class definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Sky direction class interface definition.
double norm(const GVector &vector)
Computes vector norm.
std::vector< GVector > m_earth_dt
First derivative of Earth vectors.
GTime m_tstart
Ephemerides validity start time.
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.
void free_members(void)
Delete class members.
GFilename m_filename
Ephemerides filename.
std::vector< double > m_tdb2tt
TBD to TT conversion term.
GEphemerides & operator=(const GEphemerides &ephemerides)
Assignment operator.
std::vector< GVector > m_earth_d3t
Third derivative of Earth vectors.
virtual void clear(void)
Clear Ephemerides.
std::vector< GVector > m_sun
Sun vectors.
void fetch_data(void)
Fetch ephemerides data.
virtual GEphemerides * clone(void) const
Clone Ephemerides.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Ephemerides.
void init_members(void)
Initialise class members.
void copy_members(const GEphemerides &ephemerides)
Copy class members.
virtual ~GEphemerides(void)
Destructor.
GEphemerides(void)
Void constructor.
std::vector< GVector > m_earth_d2t
Second derivative of Earth vectors.
std::string m_name
Ephemerides (e.g. DE200)
bool is_empty(void) const
Signals if there are no ephemerides.
GTime m_tstop
Ephemerides validity stop time.
double geo2ssb(const GSkyDir &srcdir, const GTime &time) const
Get time difference between geocentric and SSB (seconds)
std::vector< GVector > m_earth
Earth vectors.
std::vector< GTime > m_times
Times of vectors.
void load(const GFilename &filename)
Load Ephemerides.
int size(void) const
Return number of ephemerides.
bool is_fits(void) const
Checks whether file is a FITS file.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
double real(const std::string &keyname) const
Return card value as double precision.
std::string string(const std::string &keyname) const
Return card value as string.
Abstract interface for FITS table column.
virtual double real(const int &row, const int &inx=0) const =0
Abstract interface for FITS table.
const int & nrows(void) const
Return number of rows in table.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void celvector(const GVector &vector)
Set sky direction from 3D vector in celestial coordinates.
void clear(void)
Clear time.
double mjd(void) const
Return time in Modified Julian Days (TT)
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
double jd(void) const
Return time in Julian Days (TT)
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const double speed_of_light