39 #define G_AT "GPulsarEphemeris& GPulsar::at(int&)"
40 #define G_EPHEMERIS "GPulsar::ephemeris(GTime&)"
41 #define G_LOAD "GPulsar::load(GFilename&, std::string&)"
42 #define G_LOAD_FITS "GPulsar::load_fits(GFilename&, std::string&)"
43 #define G_LOAD_INTEGRAL "GPulsar::load_integral(GFitsTable*, std::string&)"
44 #define G_LOAD_FERMI "GPulsar::load_fermi(GFitsTable*, std::string&)"
45 #define G_LOAD_PSRTIME "GPulsar::load_psrtime(GFilename&, std::string&)"
46 #define G_LOAD_PARFILE "GPulsar::load_parfile(GFilename&)"
144 if (
this != &pulsar) {
207 #if defined(G_RANGE_CHECK)
208 if (index < 0 || index >=
size()) {
231 #if defined(G_RANGE_CHECK)
232 if (index < 0 || index >=
size()) {
257 for (
int i = 0; i <
size(); ++i) {
267 std::string msg =
"No valid ephemeris found for MJD "+
269 "ephemerides that comprise the time.";
292 for (
int i = 0; i <
size(); ++i) {
333 FILE* fptr = std::fopen(filename.
url().c_str(),
"r");
335 std::string msg =
"Pulsar ephemerides file \""+filename.
url()+
336 "\" not found or readable. Please specify a "
337 "valid and readable ephemerides file.";
342 if (std::fgets(line, n, fptr) != NULL) {
352 if (elements.size() > 10) {
393 result.append(
"=== GPulsar ===");
403 result.append(
" - ");
407 result.append(
" - ");
487 GFits fits(filename);
491 if (fits.
contains(
"GNRL-EPHE-CAT")) {
498 else if (fits.
contains(
"SPIN_PARAMETERS")) {
505 std::string msg =
"Could not recognised format of FITS file \""+
506 filename.
url()+
"\". Please specify either an "
507 "INTEGRAL or a D4 Fermi file.";
533 double ra = table->
real(
"RA_OBJ");
534 double dec = table->
real(
"DEC_OBJ");
539 std::string msg =
"Pulsar \""+
m_name+
"\" found in ephemerides "
540 "file yet pulsar \""+name+
"\" was requested. "
541 "Please check the requested pulsar name.";
560 for (
int i = 0; i < col_mjdstart->
nrows(); ++i) {
565 tstart.
mjd(col_mjdstart->
real(i));
566 tstop.
mjd(col_mjdstop->
real(i));
582 t0.
mjd(
double(
int(col_tref0->
real(i))));
586 double f0 = col_f0->
real(i);
587 double f1 = col_f1->
real(i);
588 double f2 = col_f2->
real(i);
591 const double c1 = 1.0/2.0;
592 const double c2 = 1.0/6.0;
593 double dt = col_t2peak->
real(i);
594 double phase = -((f0 + (f1 * c1 + f2 * dt * c2) * dt) * dt);
595 phase -= floor(phase);
604 ephemeris.
tstop(tstop);
606 ephemeris.
phase(phase);
638 const GFitsTableCol* col_valid_since = (*table)[
"VALID_SINCE"];
639 const GFitsTableCol* col_valid_until = (*table)[
"VALID_UNTIL"];
640 const GFitsTableCol* col_toabary_int = (*table)[
"TOABARY_INT"];
641 const GFitsTableCol* col_toabary_frac = (*table)[
"TOABARY_FRAC"];
647 for (
int i = 0; i < col_psrname->
nrows(); ++i) {
664 tstart.
mjd(col_valid_since->
real(i));
665 tstop.
mjd(col_valid_until->
real(i));
673 double f0 = col_f0->
real(i);
674 double f1 = col_f1->
real(i);
675 double f2 = col_f2->
real(i);
678 const double c1 = 1.0/2.0;
679 const double c2 = 1.0/6.0;
681 double phase = -((f0 + (f1 * c1 + f2 * dt * c2) * dt) * dt);
682 phase -= floor(phase);
691 ephemeris.
tstop(tstop);
693 ephemeris.
phase(phase);
706 std::string msg =
"No pulsar name was specified. Please specify "
707 "the name of the pulsar for which ephemerides "
708 "should be extracted from the file.";
712 std::string msg =
"No pulsar \""+name+
"\" found in ephemerides "
713 "file. Please check the specified file or the "
714 "requested pulsar name.";
750 FILE* fptr = std::fopen(filename.
url().c_str(),
"r");
752 std::string msg =
"Pulsar ephemerides file \""+filename.
url()+
753 "\" not found or readable. Please specify a "
754 "valid and readable ephemerides file.";
762 while (std::fgets(line, n, fptr) != NULL) {
768 std::string psrb = elements[0];
772 std::string psrb_alt =
"PSR B" + psrb;
773 if ((psrb != name) && (psrb_alt !=
name)) {
781 if (!psrname.empty() && (psrb != psrname)) {
782 std::string msg =
"Pulsar ephemerides file \""+filename.
url()+
783 "\" contains several pulsar but not pulsar "
784 "name was specified. Please specify for which "
785 "pulsar you want to load ephemerides.";
809 double ra = (ra_h + ra_m/60.0 + ra_s/3600.0) * 15.0;
810 double dec = (dec_d < 0.0) ? -(-dec_d + dec_m/60.0 + dec_s/3600.0)
811 : (dec_d + dec_m/60.0 + dec_s/3600.0);
820 tstart.
mjd(mjdstart);
824 double t0nom = double(
int(t0geo));
828 t0.
mjd(t0nom,
"UTC");
832 toa.
mjd(t0geo,
"UTC");
837 double geo2ssb = ephemerides.
geo2ssb(dir, toa);
838 double utc2tt = toa.
utc2tt();
840 const double c1 = 1.0/2.0;
841 const double c2 = 1.0/6.0;
842 double phase = ((f0 + (f1 * c1 + f2 * dt * c2) * dt) * dt);
843 phase -= floor(phase);
852 ephemeris.
tstop(tstop);
855 ephemeris.
phase(-phase);
892 FILE* fptr = std::fopen(filename.
url().c_str(),
"r");
894 std::string msg =
"Pulsar ephemeris file \""+filename.
url()+
895 "\" not found or readable. Please specify a "
896 "valid and readable ephemeris file.";
906 while (std::fgets(line, n, fptr) != NULL) {
913 for (; i < elements.size(); ++i) {
914 if (!elements[i].empty()) {
918 if (i >= elements.size()) {
923 if (elements[0] ==
"PSRJ") {
927 else if (elements[0] ==
"RAJ") {
932 ra = (ra_h + ra_m/60.0 + ra_s/3600.0) * 15.0;
934 else if (elements[0] ==
"DECJ") {
939 dec = (dec_d < 0.0) ? -(-dec_d + dec_m/60.0 + dec_s/3600.0)
940 : (dec_d + dec_m/60.0 + dec_s/3600.0);
942 else if (elements[0] ==
"START") {
947 else if (elements[0] ==
"FINISH") {
950 ephemeris.
tstop(tstop);
952 else if (elements[0] ==
"PEPOCH") {
957 else if (elements[0] ==
"F0") {
960 else if (elements[0] ==
"F1") {
963 else if (elements[0] ==
"F2") {
971 if (ra >= 0.0 && ra <= 360.0 && dec >= -90.0 && dec <= 90.0) {
982 "pulsar ephemeris file \""+filename.
url()+
983 "\" are invalid. Please verify the ephemeris file.";
double f2(void) const
Returns pulsar second frequency derivative (s^-3)
std::string replace_segment(const std::string &arg, const std::string &segment, const std::string &replacement)
Replace string segment in string.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
virtual ~GPulsar(void)
Destructor.
void load(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides file.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
void load_fits(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides FITS file.
const std::string & name(void) const
Returns pulsar name.
void free_members(void)
Delete class members.
const GSkyDir & dir(void) const
Returns pulsar sky direction.
GTime t0(void) const
Returns reference epoch of pulsar ephemeris.
void nrows(const int &nrows)
Set number of rows in column.
void copy_members(const GPulsar &pulsar)
Copy class members.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
FITS file class interface definition.
bool is_empty(void) const
Signals if there are no ephemerides for pulsar.
const std::string & timesys(void) const
Returns pulsar ephemeris time system.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
Good time interval class interface definition.
virtual std::string string(const int &row, const int &inx=0) const =0
const GPulsarEphemeris & ephemeris(const GTime &time) const
Return pulsar ephemeris.
std::string m_name
Pulsar name.
double real(const std::string &keyname) const
Return card value as double precision.
Ephemerides class definition.
const GTime & tstop(void) const
Returns validity stop time.
GPulsar(void)
Void constructor.
Abstract interface for FITS table column.
double geo2ssb(const GSkyDir &srcdir, const GTime &time) const
Get time difference between geocentric and SSB (seconds)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Pulsar.
void load_psrtime(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides psrtime file.
GPulsarEphemeris & at(const int &index)
Return reference to ephemeris.
Abstract interface for FITS table.
void load_integral(const GFitsTable *table, const std::string &name="")
Load Pulsar from INTEGRAL ephemerides FITS table.
double f1(void) const
Returns pulsar frequency derivative (s^-2)
Good Time Interval class.
bool is_fits(void) const
Checks whether file is a FITS file.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
void load_fermi(const GFitsTable *table, const std::string &name="")
Load Pulsar from Fermi ephemerides FITS table.
void init_members(void)
Initialise class members.
std::string rstrip_chars(const std::string &arg, const std::string &chars)
Strip trailing character from string.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual int integer(const int &row, const int &inx=0) const =0
double f0(void) const
Returns pulsar frequency (Hz)
void load_parfile(const GFilename &filename)
Load Pulsar from ephemeris par file.
GGti validity(void) const
Return validity intervals of pulsar ephemerides.
virtual double real(const int &row, const int &inx=0) const =0
int size(void) const
Return number of ephemerides for pulsar.
std::string string(const std::string &keyname) const
Return card value as string.
double mjd(void) const
Return time in Modified Julian Days (TT)
const std::string & name(void) const
Return pulsar name.
virtual void clear(void)
Clear Pulsar.
virtual GPulsar * clone(void) const
Clone Pulsar.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GPulsar & operator=(const GPulsar &pulsar)
Assignment operator.
const GTime & tstart(void) const
Returns validity start time.
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
double utc2tt(void) const
Return time difference between UTC and TT (seconds)
Filename class interface definition.
double todouble(const std::string &arg)
Convert string into double precision value.
std::vector< GPulsarEphemeris > m_ephemerides
Pulsar ephemerides.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double phase(void) const
Returns pulse phase.