14#include "Pulsar/Predictor.h"
15#include "Pulsar/Generator.h"
104 int load (std::string* instr);
105 int unload (std::string *outstr)
const;
106 int unload (FILE* fptr)
const;
108 void prettyprint ()
const;
114 Pulsar::Phase
phase (
const MJD &t)
const;
117 MJD iphase (
const Pulsar::Phase& p,
const MJD* = 0)
const;
123 Pulsar::Phase
dispersion (
const MJD &t,
long double MHz)
const;
131 bool is_tempov11 ()
const {
return tempov11; }
132 char get_telescope ()
const {
return telescope; }
133 double get_freq ()
const {
return freq; }
134 MJD get_reftime ()
const {
return ref_time; }
135 Pulsar::Phase get_refphase ()
const {
return ref_phase; }
136 double get_reffrequency ()
const {
return ref_freq; }
137 double get_nspan ()
const {
return nspan_mins; }
138 float get_dm ()
const {
return dm; }
139 int get_ncoeff ()
const {
return (
int)
coefs.size(); }
140 double get_doppler_shift ()
const {
return doppler_shift / 1e4; }
141 std::string get_psrname ()
const {
return psrname; }
142 bool get_binary ()
const {
return binary; }
143 double get_binph ()
const {
return binph; }
146 static double flexibility;
148 MJD start_time(
double f = flexibility )
const
150 MJD end_time(
double f = flexibility )
const
153 Pulsar::Phase start_phase(
double f = flexibility )
const
154 {
return phase (start_time(f)); };
155 Pulsar::Phase end_phase(
double f = flexibility )
const
156 {
return phase (end_time(f)); };
168 void set_tempov11 (
bool v) { instance->
tempov11 = v; }
169 void set_telescope (
char v) { instance->telescope = v; }
170 void set_freq (
double v) { instance->freq = v; }
171 void set_reftime (
const MJD& v) { instance->ref_time = v; }
172 void set_refphase (
const Pulsar::Phase& v) { instance->ref_phase = v; }
173 void set_reffrequency (
double v) { instance->ref_freq = v; }
174 void set_nspan (
double v) { instance->nspan_mins = v; }
175 void set_dm (
float v) { instance->dm = v; }
176 void set_ncoef (
unsigned v) { instance->coefs.resize(v); }
177 void set_doppler_shift (
double v) { instance->doppler_shift = v * 1e4; }
178 void set_psrname (
const std::string& v) { instance->psrname = v; }
179 void set_binary (
bool v) { instance->binary = v; }
180 void set_binph (
double v) { instance->binph = v; }
182 double* get_coefs () {
return &(instance->coefs[0]); }
213 Predictor*
clone ()
const;
219 void insert (
const Predictor*);
222 void keep (
const std::vector<MJD>& epochs);
225 bool matches (
const Predictor*)
const;
235 {
return best(t).phase(t); }
238 Pulsar::Phase
phase (
const MJD& t,
long double MHz)
const
247 {
return best(t).frequency(t); }
251 {
return best(t).dispersion(t,MHz); }
257 void unload (FILE*)
const;
264 polyco (
const std::string&
id);
267 int load (
const std::string& filename);
268 int load (std::string* instr);
271 int unload (
const std::string& filename)
const;
274 int unload (std::string *outstr)
const;
276 void append (
const polyco& poly);
278 void prettyprint ()
const;
283 const polynomial& best (
const Pulsar::Phase &p)
const;
285 int i_nearest (
const MJD &t,
bool throw_exception =
false)
const;
286 int i_nearest (
const Pulsar::Phase &p,
bool throw_exception =
false)
const;
288 double doppler_shift (
const MJD& t)
const
289 {
return best(t).get_doppler_shift(); };
291 double period(
const MJD& t)
const
292 {
return best(t).period(t); };
294 double chirp(
const MJD& t)
const
295 {
return best(t).chirp(t); };
297 double accel(
const MJD& t)
const
298 {
return best(t).accel(t); };
300 char get_telescope ()
const;
301 double get_freq ()
const;
302 MJD get_reftime ()
const;
303 double get_refperiod ()
const;
304 double get_nspan ()
const;
305 float get_dm ()
const;
306 int get_ncoeff ()
const;
307 std::string get_psrname ()
const;
309 bool is_tempov11()
const;
311 MJD start_time ()
const {
return pollys.front().start_time(); };
312 MJD end_time ()
const {
return pollys.back().end_time(); };
314 Pulsar::Phase start_phase ()
const {
return pollys.front().start_phase(); };
315 Pulsar::Phase end_phase ()
const {
return pollys.back().end_phase(); };
317 friend bool operator == (
const polyco &,
const polyco &);
318 friend bool operator != (
const polyco &,
const polyco &);
323 mutable int last_index;
325 mutable MJD last_epoch;
326 mutable double last_span_epoch;
328 mutable Pulsar::Phase last_phase;
329 mutable double last_span_phase;
332 void set_last (
int i)
const;
335inline std::ostream& operator<< (std::ostream& ostr,
const polyco& p)
337 std::string out; p.
unload(&out);
return ostr << out;
Class for representing modified Julian dates with high precision.
Definition MJD.h:23
Generator of functions that predict pulse phase.
Definition Generator.h:26
Functions that predict pulse phase.
Definition Predictor.h:28
Implements Predictor class for Tempo.
Definition polyco.h:188
Pulsar::Phase phase(const MJD &t, long double MHz) const
Return the phase plus the dispersion delay.
Definition polyco.h:238
long double get_observing_frequency() const
Get the observing frequency at which phase and epoch are related.
Definition polyco.C:624
void set_observing_frequency(long double MHz)
Set the observing frequency at which predictions will be made.
Definition polyco.C:620
void load(FILE *)
Load from an open stream.
Definition polyco.C:728
void unload(FILE *) const
Unload to an open stream.
Definition polyco.C:802
void keep(const std::vector< MJD > &epochs)
Keep only the components required to span the given epochs.
Definition polyco.C:863
Pulsar::Phase phase(const MJD &t) const
Return the phase, given the epoch.
Definition polyco.h:234
MJD iphase(const Pulsar::Phase &phase, const MJD *guess=0) const
Return the epoch, given the phase.
Definition polyco.h:242
void insert(const Predictor *)
Add the information from the supplied predictor to self.
Definition polyco.C:597
bool matches(const Predictor *) const
Return true if the Predictor configuration matches this.
Definition polyco.C:607
std::vector< polynomial > pollys
The polynomial sets.
Definition polyco.h:194
~polyco()
Destructor.
Definition polyco.C:568
polyco()
Default constructor.
Definition polyco.C:530
Pulsar::Phase dispersion(const MJD &t, long double MHz) const
Return the phase correction for dispersion delay.
Definition polyco.h:250
const polyco & operator=(const polyco &)
Assignment operator.
Definition polyco.C:547
long double frequency(const MJD &t) const
Return the spin frequency, given the epoch.
Definition polyco.h:246
Pulsar::Generator * generator() const
Return a new Generator set up to produce a new Predictor like self.
Definition polyco.C:588
Predictor * clone() const
Return a new, copy constructed instance of self.
Definition polyco.C:583
Expert interface to polynomial attributes.
Definition polyco.h:163
Describes a single Tempo polyco set.
Definition polyco.h:21
std::string psrname
The pulsar name.
Definition polyco.h:28
std::string utc
The UTC string.
Definition polyco.h:34
bool tempov11
Flag that the polyco was created using TEMPO v.11 or greater.
Definition polyco.h:67
double freq
Observing frequency.
Definition polyco.h:49
MJD iphase(const Pulsar::Phase &p, const MJD *=0) const
Returns the time at the given pulse phase.
Definition polyco.C:411
bool keep
used by polyco::keep to determine if this polynomial is used
Definition polyco.h:82
double doppler_shift
Doppler shift due to Earth's motion along line of sight.
Definition polyco.h:70
double log_rms_resid
log of the r.m.s residual between polynomial and model
Definition polyco.h:73
double period(const MJD &t) const
Returns the pulse period (in seconds) at the given time.
Definition polyco.C:454
double binph
if binary, binary phase
Definition polyco.h:55
std::string date
The calendar date string.
Definition polyco.h:31
bool binary
true if the pulsar is in a binary system
Definition polyco.h:52
void init()
intializes all values to null
Definition polyco.C:47
double chirp(const MJD &t) const
Returns the spin frequency derivative (in Hz/s) at the given time.
Definition polyco.C:436
Pulsar::Phase phase(const MJD &t) const
Returns the pulse phase (in turns) at the given time.
Definition polyco.C:391
static double precision
Determines the precision of iphase (stopping threshold) in seconds.
Definition polyco.h:91
~polynomial()
destructor
Definition polyco.C:100
float dm
dispersion measure
Definition polyco.h:61
polynomial()
default constructor
Definition polyco.C:62
MJD ref_time
The epoch to which the polynomial is referenced.
Definition polyco.h:43
double nspan_mins
number of minutes spanned by polynomial
Definition polyco.h:64
double accel(const MJD &t) const
Returns the apparent acceleration toward observer (m s^-2)
Definition polyco.h:129
double ref_freq
Reference rotation frequency, F0 (Hz)
Definition polyco.h:40
Pulsar::Phase ref_phase
The pulsar phase at reftime.
Definition polyco.h:37
long double frequency(const MJD &t) const
Returns the spin frequency (in Hz) at the given time.
Definition polyco.C:419
char telescope
TEMPO telescope id code.
Definition polyco.h:46
std::vector< double > coefs
polynomial coefficients
Definition polyco.h:76
Pulsar::Phase dispersion(const MJD &t, long double MHz) const
Return the phase correction for dispersion delay.
Definition polyco.C:459
double binfreq
if binary, binary frequency
Definition polyco.h:58