toa.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 1999 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Util/tempo/toa.h
10
11#ifndef __TOA_H
12#define __TOA_H
13
14#include <vector>
15#include <string>
16
17#include "residual.h"
18#include "MJD.h"
19#include "Estimate.h"
20
21namespace Tempo {
22
23 class toaInfo;
24
25 // //////////////////////////////////////////////////////////////////////////
26 //
27 // toa - class that encapsulates TEMPO data format
28 //
29 // //////////////////////////////////////////////////////////////////////////
30
32 class toa
33 {
34
35 public:
36
37 static const float UNSET;
38
40 enum Format
41 {
42 Unspecified,
43 Comment,
44 Princeton,
45 Parkes,
46 ITOA,
47 Psrclock,
48 Command,
49 Tempo2
50 };
51
52 enum State
53 {
54 Undefined = -2, // point will never be plotted or used
55 Deleted = -1, // point will not be plotted unless an undelete happens
56 Hidden = 0, // point is temporarily outside of viewing region
57 Normal = 1, // point is in viewing region and plotted
58 Selected = 2 // like Normal, but highlighted selection
59 };
60
61 static bool verbose;
62
63 protected:
64
65 // Fundamental TOA LINE as described here:
66 // http://pulsar.princeton.edu/tempo/ref_man_sections/toa.txt
67
69 double frequency = 0.0;
70
73
75 float error = 0.0;
76
78 float reduced_chisq = 0.0;
79
81 double phase_shift = 0;
82
84 std::string telescope;
85
87 unsigned channel = 0;
88
90 unsigned subint = 0;
91
93
94 float phs = 0;
95
97 char observatory[2];
98
100 std::string auxinfo;
101
104
107
109 float bandwidth = 0;
110
112 float duration = 0;
113
116
118
120
123
124 Estimate<float> flux;
125
126 bool phase_info;
127
128 // one of the available formats on loading
129
130 Format format;
131 State state;
132
133 public:
134
135 // residual for this toa as calculated by tempo
136 residual resid;
137
138 // Basic constructors and destructors
139 toa (Format fmt = Psrclock);
140 virtual ~toa () { destroy(); };
141
142 // copy constructor
143 toa (const toa & in_toa);
144 toa& operator = (const toa & in_toa);
145
146 // construct from an open file
147 toa (FILE* instream);
148
149 // construct from a string
150 toa (char* indata);
151
152 // methods for setting/getting things (may eventually check validity)
153 void set_format (Format fmt) { format = fmt; };
154 void set_StoN (float sn) { signal_to_noise = sn; };
155 void set_pa (float p) { parallactic_angle = p; };
156 void set_bw (float b) { bandwidth = b; };
157 void set_dur (float d) { duration = d; };
158 void set_dm (float d) { dispersion_measure = d; };
159 void set_state (State st) { state = st; };
160
161 void set_frequency (double freq) { frequency = freq; };
162 void set_arrival (const MJD& arrived) { arrival = arrived; };
163 void set_error (float err) { error = err; };
164 void set_reduced_chisq (float x) { reduced_chisq = x; }
165 void set_flux (const Estimate<float>& x) { flux = x; }
166 void set_dispersion_measure_estimate (const Estimate<double>& x) { dispersion_measure_estimate = x; }
167 void set_telescope (const std::string& telcode);
168 void set_auxilliary_text (const std::string& text) { auxinfo = text; };
169 void set_channel (unsigned chan) { channel = chan; };
170 void set_subint (unsigned sub) { subint = sub; };
171 void set_phase_shift (double shift) { phase_shift = shift; };
172 void set_phase_info (bool info) { phase_info = info; };
173
174 Format get_format () const { return format; };
175 float get_StoN () const { return signal_to_noise; };
176 float get_pa () const { return parallactic_angle; };
177 float get_bw () const { return bandwidth; };
178 float get_dur () const { return duration; };
179 float get_dm () const { return dispersion_measure; };
180 State get_state () const { return state; };
181
182 double get_frequency () const { return frequency; };
183 MJD get_arrival () const { return arrival; };
184 float get_error () const { return error; };
185 float get_reduced_chisq () const { return reduced_chisq; }
186 Estimate<float> get_flux () const { return flux; }
187 Estimate<double> get_dispersion_measure_estimate() const { return dispersion_measure_estimate; }
188
189 std::string get_telescope () const { return telescope; };
190 std::string get_auxilliary_text () const { return auxinfo; };
191 double get_phase_shift () const { return phase_shift; };
192 unsigned get_channel () const { return channel; };
193 unsigned get_subint () const { return subint; };
194
195
196 // loading and unloading to/from file and string
197 int load (FILE* instream);
198 int load (const char* instring);
199 int unload (FILE* outstream, Format fmt = Unspecified) const;
200 int unload (char* outstring, Format fmt = Unspecified) const;
201
202 int parkes_parse (const char* instring);
203 int parkes_out (char* outstring) const;
204 int Parkes_load (const char* instring);
205 int Parkes_unload (FILE* outstream) const;
206 int Parkes_unload (char* outstring) const;
207
208 int Princeton_load (const char* instring);
209 int Princeton_unload (FILE* outstream) const;
210 int Princeton_unload (char* outstring) const;
211
212 int Psrclock_load (const char* instring);
213 int Psrclock_unload (FILE* outstream) const;
214 int Psrclock_unload (char* outstring) const;
215
216 std::string Psrclock_unload () const;
217
218 int Command_load (const char* instring);
219 int Command_unload (FILE* outstream) const;
220 int Command_unload (char* outstring) const;
221
222 int Comment_unload (FILE* outstream) const;
223 int Comment_unload (char* outstring) const;
224
225 // -----------
226
227 int Tempo2_unload (FILE* outstream) const;
228 int Tempo2_unload (char* outstring) const;
229
230 int Tempo_unload (FILE* outstream) const;
231 int Tempo_unload (char* outstring) const;
232
233 // comparison operators
234 friend int operator < (const toa& t1, const toa& t2)
235 { return (t1.arrival < t2.arrival); };
236
237 // operations on vectors of toas
238 static int load (const char* filename, std::vector<toa>* toas);
239 static int load (FILE* instream, std::vector<toa>* toas);
240
241 static int unload (const char* filename, const std::vector<toa>& toas,
242 Format fmt = Unspecified);
243 static int unload (FILE* outstream, const std::vector<toa>& toas,
244 Format fmt = Unspecified);
245
246 private:
247 // low-level stuff
248 void init();
249 void destroy();
250 bool valid();
251
252 static void sizebuf (size_t length);
253 static char* buffer;
254 static size_t bufsz;
255 static char datestr [25];
256 };
257
258 std::ostream& operator << (std::ostream&, toa::Format format);
259 std::istream& operator >> (std::istream&, toa::Format& format);
260
261}
262
263#endif
264
265
266
Class for representing modified Julian dates with high precision.
Definition MJD.h:23
Describes a pulse Time of Arrival (TOA)
Definition toa.h:33
std::string auxinfo
Typically the name of the data file.
Definition toa.h:100
float duration
Duration (s) aka integration length.
Definition toa.h:112
unsigned subint
Sub-integration index in data file.
Definition toa.h:90
float error
TOA uncertainty in microseconds.
Definition toa.h:75
float bandwidth
Bandwidth (MHz)
Definition toa.h:109
char observatory[2]
Observatory (two-letter code)
Definition toa.h:97
float parallactic_angle
Parallactic angle ???
Definition toa.h:106
double frequency
Observing frequency (MHz)
Definition toa.h:69
double phase_shift
Phase shift (turns) computed by the phase shift estimator.
Definition toa.h:81
float dispersion_measure_correction
Dispersion measure correction (pc cm^-3)
Definition toa.h:119
unsigned channel
Frequency channel index in data file.
Definition toa.h:87
float phs
Phase offset (turns, added to TOA)
Definition toa.h:94
MJD arrival
Time of arrival, TOA.
Definition toa.h:72
float reduced_chisq
Goodness-of-fit (reduced chisq) reported by the phase shift estimator.
Definition toa.h:78
double dispersion_measure
Dispersion measure, DM (pc cm^-3)
Definition toa.h:115
std::string telescope
Observatory code.
Definition toa.h:84
Format
TOA output format.
Definition toa.h:41
Estimate< double > dispersion_measure_estimate
Estimated dispersion measure (pc cm^-3)
Definition toa.h:122
float signal_to_noise
Signal-to-noise ratio estimate.
Definition toa.h:103
void shift(unsigned npts, float *arr, double shift)
Use the Fourier transform to cyclically shift the elements in array.
Definition shift.C:16
Interface to Tempo.
Definition fit.C:22

Generated using doxygen 1.14.0