psrParameter.h
1 /***************************************************************************
2  *
3  * Copyright (C) 1999 by Willem van Straten
4  * Licensed under the Academic Free License version 2.1
5  *
6  ***************************************************************************/
7 /* ///////////////////////////////////////////////////////////////////////
8  The PsrParameters
9 
10  PsrParameter - base class from which each element of the
11  PsrParams class is derived.
12 
13  The following derived classes are defined:
14  psrString
15  psrDouble
16  psrMJD
17  psrAngle
18 
19  Philosophy: It might have been neater to make a number of virtual member
20  functions such as getMJD, getAngle, etc. in the base class
21  and allow derived classes to over-ride. However, the whole
22  point to this exercise was to make a light-weight, typed
23  placeholder of information, not a huge vtbl. So, static
24  member functions are provided that do dynamic casting to
25  get information in-out in a type-safe manner.
26 
27  Author: Willem van Straten
28 
30 
31 #ifndef __PSRPARAMETER_H
32 #define __PSRPARAMETER_H
33 
34 #include <string>
35 
36 #include "MJD.h"
37 #include "Angle.h"
38 
39 class psrParameter
40 {
41  friend class psrParams;
42 
43  public:
44  static bool verbose;
45  static psrParameter null; // null value returned in some instances
46 
47  // constructor used by derived classes only
48  psrParameter (int ephio_index, bool infit = false, double error = 0.0);
49 
50  virtual ~psrParameter () {};
51 
52  // verifies the index given, throws an exception if invalid, otherwise
53  // returns the index given.
54  static int check (int ephio_index);
55 
56  // return true if this psrParameter may have an associated error
57  bool has_error();
58  // return the error in this parameter
59  double getError () { return error; };
60 
61  // return true if this psrParameter is fitable
62  bool fitable ();
63  // return true if the flag is set to fit for this element
64  bool getFit () const { return infit; };
65 
66  // return true if this psrParameter is valid
67  bool valid() const { return ephio_index != -1; }
68 
69  // return the index as in ephio.h
70  int get_ephind () const { return ephio_index; };
71 
72  // set the fit flag to 'infit'
73  void setFit (bool fit) { infit = fit && fitable(); };
74 
75  // return the value
76  std::string getString ();
77  double getDouble ();
78  MJD getMJD ();
79  Angle getAngle ();
80  int getInteger();
81 
82  // set value
83  void setString (const std::string&);
84  void setDouble (double );
85  void setMJD (const MJD&);
86  void setAngle (const Angle&);
87  void setInteger(int);
88 
89  protected:
90  int ephio_index; // where in the ephio.h of things this element fits in
91  double error; // the error in the value
92  bool infit; // the 'fit' flag is set for this element
93 
94  // basically a dynamic copy constructor
95  psrParameter* duplicate ();
96 
97  // null constructor is protected
98  psrParameter () { ephio_index = -1; error = 0.0; infit = false; };
99 };
100 
101 // //////////////////////////////////////////////////////////////////////////
102 // //////////////////////////////////////////////////////////////////////////
103 //
104 // psrString
105 //
106 // Class defines the appearance/behaviour of psrParams text elements.
107 //
108 // //////////////////////////////////////////////////////////////////////////
109 // //////////////////////////////////////////////////////////////////////////
110 
111 class psrString : public psrParameter
112 {
113  public:
114  psrString (int ephind, const std::string& val, bool in_fit=false) :
115  psrParameter (ephind, false, in_fit),
116  value (val) { };
117 
118  std::string getString () { return value; };
119  void setString (const std::string& str) { value = str; };
120 
121  protected:
122  std::string value;
123 };
124 
125 // //////////////////////////////////////////////////////////////////////////
126 // //////////////////////////////////////////////////////////////////////////
127 //
128 // psrDouble
129 //
130 // Class defines the appearance/behaviour of psrParams real valued elements.
131 //
132 // //////////////////////////////////////////////////////////////////////////
133 // //////////////////////////////////////////////////////////////////////////
134 class psrDouble : public psrParameter
135 {
136  public:
137  psrDouble (int ephind, double val,
138  double err = 0.0, bool in_fit = false) :
139  psrParameter (ephind, in_fit, err),
140  value (val) { };
141 
142  double getDouble () { return value; };
143  void setDouble (double val, double err)
144  { value = val; error = err; };
145  void setDouble (double val)
146  { value = val; };
147 
148  protected:
149  double value;
150 };
151 
152 // //////////////////////////////////////////////////////////////////////////
153 // //////////////////////////////////////////////////////////////////////////
154 //
155 // psrInteger
156 //
157 // Class defines the appearance/behaviour of psrParams real valued elements.
158 //
159 // //////////////////////////////////////////////////////////////////////////
160 // //////////////////////////////////////////////////////////////////////////
161 class psrInteger : public psrParameter
162 {
163  public:
164  psrInteger (int ephind, int val, int err = 0, bool in_fit = false) :
165  psrParameter (ephind, in_fit, err),
166  value (val) { };
167 
168  int getInteger () { return value; };
169  void setInteger (int val, int err)
170  { value = val; error = err; };
171  void setInteger (int val)
172  { value = val; };
173 
174  protected:
175  int value;
176 };
177 
178 // //////////////////////////////////////////////////////////////////////////
179 // //////////////////////////////////////////////////////////////////////////
180 //
181 // psrMJD
182 //
183 // Class defines the appearance/behaviour of psrParams MJD elements.
184 //
185 // //////////////////////////////////////////////////////////////////////////
186 // //////////////////////////////////////////////////////////////////////////
187 class psrMJD : public psrParameter
188 {
189  public:
190  psrMJD (int ephind, const MJD& mjd, double err=0, bool in_fit=false) :
191  psrParameter (ephind, in_fit, err),
192  value (mjd) { };
193 
194  psrMJD (int ephind, int days, double fracdays,
195  double err=0, bool in_fit=false) :
196  psrParameter (ephind, in_fit, err),
197  value (days, fracdays) { };
198 
199  MJD getMJD () { return value; };
200  void setMJD (const MJD& val, double err)
201  { value = val; error = err; };
202  void setMJD (const MJD& val)
203  { value = val; };
204 
205  protected:
206  MJD value;
207 };
208 
209 // //////////////////////////////////////////////////////////////////////////
210 // //////////////////////////////////////////////////////////////////////////
211 //
212 // psrAngle
213 //
214 // Class defines the appearance/behaviour of psrParams angular elements.
215 //
216 // //////////////////////////////////////////////////////////////////////////
217 // //////////////////////////////////////////////////////////////////////////
218 class psrAngle : public psrParameter
219 {
220  public:
221  psrAngle (int ephind, const Angle& angle, double err=0, bool in_fit=false, bool RA=false) :
222  psrParameter (ephind, in_fit, err),
223  value (angle) { };
224 
225  psrAngle (int ephind, double turns, double err=0, bool in_fit=false) :
226  psrParameter (ephind, in_fit, err),
227  value (turns * 2.0 * M_PI) { };
228 
229  Angle getAngle () { return value; };
230  void setAngle (const Angle& val, double err)
231  { value = val; error = err; };
232  void setAngle (const Angle& val)
233  { value = val; };
234 
235  void is_RA () {
236  value.setWrapPoint(2*M_PI);
237  if (value.getRadians() < 0) {
238  value.setRadians(value.getRadians()+2*M_PI);
239  };
240  };
241  protected:
242  Angle value;
243 };
244 
245 #endif
Jones< double > evaluate(std::vector< Jones< double > > *grad=0) const
const ScalarMath exp(const ScalarMath &x)
Application with basic command line options.
Definition: Application.h:30
void fit(const Pulsar::Parameters *model, std::vector< toa > &data, Pulsar::Parameters *postfit=NULL, bool track=false, Tempo::toa::State min_state=Tempo::toa::Normal)
void baseline_stats(std::vector< std::vector< Estimate< double > > > *mean, std::vector< std::vector< double > > *variance=0, const PhaseWeight *baseline=0) const
Return the statistics of every profile baseline.
Definition: Integration_remove_baseline.C:54
virtual unsigned get_npol() const =0
Get the number of polarizations.
void set_guess_smooth(unsigned phase_bins)
Set the smoothing window used to stabilize first guess.
Definition: ComplexRVMFit.C:62
static bool no_amps
When true, no memory is allocated for amps.
Definition: ProfileAmps.h:38
Reference::To< GeneralizedChiSquared > gcs
virtual double get_rotation_measure() const =0
Get the rotation measure (in )
void convert_state(Signal::State state)
Convert data to the specified state.
Definition: Archive_convert_state.C:14
Reference::To< ScalarParameter > magnetic_meridian
void remove_baseline()
Remove the baseline from all profiles.
Definition: Archive_remove_baseline.C:17
void diff(const Profile *profile)
subtract profile from this
Definition: Profile.C:341
static void agent_list()
List the successfully loaded plugins.
Definition: Archive.C:125
float min(int bin_start=0, int bin_end=0) const
Returns the minimum amplitude.
Definition: Profile.C:665
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition: ProfileAmps.C:141
Add generic annotations to any SimplePlot.
Definition: PlotAnnotation.h:32
unsigned get_nparam() const
Plot command line options.
Definition: PlotOptions.h:26
virtual Interpreter * get_interpreter()
Provide access to the interpreter.
Definition: StandardOptions.C:79
bool allow_infinite_frequency
allow dedispersion or Faraday rotation correction to infinite frequency
Definition: Interpreter.h:230
virtual unsigned get_nsubint() const =0
Get the number of sub-integrations stored in the file.
void set_fit(bool fit)
Set when model parameters will be varied to search for optimal values.
Definition: RotatingVectorModelOptions.h:44
PlotScale * get_y_scale(bool allow_transpose)
Get the x-scale.
Definition: PlotFrame.C:213
Reference::To< ScalarParameter > reference_position_angle
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
The primary interface to pulsar observational data.
Definition: Archive.h:45
Plots a single pulse profile.
Definition: StokesCylindrical.h:28
static Archive * load(const std::string &name)
Factory returns a new instance loaded from filename.
Definition: Archive_load.C:28
static void set_verbosity(unsigned level)
Set the verbosity level (0 to 3)
Definition: Archive_verbose.C:19
unsigned get_nbin() const
Return the number of bins.
Definition: ProfileAmps.h:50
void scale(double scale)
multiplies each bin of the profile by scale
Definition: Profile.C:311
const ScalarMath pow(const ScalarMath &x, const ScalarMath &y)
U get_error() const
Reference::To< ScalarParameter > magnetic_axis
void set_chan(Index _ichan)
Set the frequency channel to plot (where applicable)
Definition: FluxPlot.h:78
Type * get() const
void set_reference_wavelength(double metres)
Set the reference wavelength in metres.
Definition: ColdPlasma.h:215
void remove_extensions(const std::string &str)
void set_subint(Index _isubint)
Set the sub-integration to plot (where applicable)
Definition: FluxPlot.h:74
static Archive * new_Archive(const std::string &class_name)
Factory returns a null-constructed instance of the named class.
Definition: Archive.C:104
virtual unsigned get_nchan() const =0
Get the number of frequency channels used.
Reference::To< ScalarParameter > kappa
void shift(unsigned npts, float *arr, double shift)
Plots a polarization pulse profile.
Definition: StokesPlot.h:24
void set_threshold(float sigma)
Set the threshold below which data are ignored.
Definition: ComplexRVMFit.C:52
void execute(Archive *)
Apply the current correction to all sub-integrations in an archive.
Definition: FaradayRotation.C:66
float get_weight(unsigned ichan) const
Get the Profile weight attribute of the given channel.
Definition: Integration.C:388
Reference::To< ScalarParameter > line_of_sight
Integration * get_Integration(unsigned subint)
Return pointer to the specified Integration.
Definition: IntegrationManager.C:41
void set_threshold(float t)
will draw only those points with linear > threshold * sigma
Definition: AnglePlot.h:75
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
static Option< bool > rotate_in_phase_domain
When true, Profile::rotate shifts bins in the phase domain.
Definition: Profile.h:56
Computes dynamic spectrum (flux vs time/freq) of an Archive.
Definition: DynamicSpectrum.h:27
Standard interpreter command line options.
Definition: StandardOptions.h:26
static bool verbose
Verbosity flag.
Definition: ComplexRVMFit.h:40
void bscrunch_to_nbin(unsigned new_nbin)
Call bscrunch with the appropriate value.
Definition: Archive_bscrunch.C:16
void set_model(MEAL::RotatingVectorModel *model)
Set the model to be interfaced.
Definition: RotatingVectorModelOptions.h:41
Reference::To< ScalarParameter > impact
float max(int bin_start=0, int bin_end=0) const
Returns the maximum amplitude.
Definition: Profile.C:651
Edit the metadata in a pulsar archive.
Definition: Editor.h:24
RotatingVectorModel command line options.
Definition: RotatingVectorModelOptions.h:25
void add_commands(const std::string &str)
static bool verbose
Verbosity flag.
Definition: Plot.h:33
Archive * total(bool tscrunch=true) const
Return pointer to a new fscrunched, tscrunched and pscrunched clone.
Definition: Archive_total.C:19
void set_measure(double measure)
Set the correction measure.
Definition: ColdPlasma.h:227
Plots an angle and its error as a function of pulse phase.
Definition: AnglePlot.h:28
virtual void add(Item *)
T get_value() const
bool verbose
Definition: timer++.C:25
void add_extensions(const std::string &str)
std::string get_param_name(unsigned index) const
double evaluate(double phi_radians)
Evaluate the model at the specified pulse longitude (in radians)
Definition: ComplexRVMFit.C:698
virtual PlotFrame * get_frame()
Get the frame.
Definition: FramedPlot.C:27
static Option< float > default_duty_cycle
fractional phase window used in most functions
Definition: Profile.h:62
Fit rotating vector model to Stokes Q and U profiles.
Definition: ComplexRVMFit.h:34
Calculates profile shifts by fitting to a template/standard.
Definition: ProfileShiftFit.h:48
virtual void set_very_verbose()
Operate in very verbose mode.
Definition: Application.C:74
Models a pulse profile using multiple components.
Definition: ComponentModel.h:34
virtual void plot(const Archive *)
Plot in the current viewport.
Definition: SimplePlot.C:15
std::string get_filename() const
Get the name of the file to which the archive will be unloaded.
Definition: Archive.h:108
virtual void finish(Archive *)
Unload the archive.
Definition: UnloadOptions.C:95
void set_range_norm(const std::pair< float, float > &f)
Set the world-normalized range on the axis.
Definition: PlotScale.C:98
Computes average flux of a Profile by fitting to a standard.
Definition: StandardFlux.h:26
void fscrunch(unsigned nscrunch=0)
Integrate profiles in frequency.
Definition: Archive_fscrunch.C:17
const std::string get_message() const
virtual void plot(const Calibrator *calibrator)
Plot the Pulsar::Calibrator.
Definition: CalibratorPlotter.C:37
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void pscrunch()
Integrate profiles in polarization.
Definition: Archive_pscrunch.C:16
void add_annotation(PlotAnnotation *a)
Add an annotation.
Definition: SimplePlot.h:60
Profile * get_Profile(unsigned ipol, unsigned ichan)
Returns a pointer to the Profile given by the specified indeces.
Definition: Integration.C:306
virtual unsigned get_nbin() const =0
Get the number of pulsar phase bins used.
The matrix template matching algorithm.
Definition: PolnProfileFit.h:50
void add_options(CommandLine::Menu &)
Add options to the menu.
Definition: RotatingVectorModelOptions.C:24
Unload interpreter command line options.
Definition: UnloadOptions.h:26
PolnProfile * new_PolnProfile(unsigned ichan)
Returns a pointer to a new PolnProfile instance.
Definition: Integration_new_PolnProfile.C:16
Estimate< double > get_Estimate(unsigned index) const
Corrects Faraday rotation.
Definition: FaradayRotation.h:37
Pulsar data processing command language interpreter.
Definition: Interpreter.h:57
void tscrunch(unsigned nscrunch=0)
Integrate profiles in time.
Definition: Archive_tscrunch.C:17
Reference::To< ScalarParameter > lambda

Generated using doxygen 1.8.17