ScalarTemplateMatching.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2003 - 2023 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/Polarimetry/Pulsar/ScalarTemplateMatching.h
10
11#ifndef __Pulsar_ScalarTemplateMatching_h
12#define __Pulsar_ScalarTemplateMatching_h
13
14#include "Pulsar/PhaseWeight.h"
15#include "FTransformAgent.h"
16#include "toa.h"
17
18namespace Pulsar
19{
20 class Profile;
22
24
38
39 class ScalarTemplateMatching : public Reference::Able
40 {
42 ScalarTemplateMatching (const ScalarTemplateMatching& fit);
43
45 ScalarTemplateMatching& operator = (const ScalarTemplateMatching& fit);
46
48 ScalarTemplateMatching* clone () const;
49
50 public:
51
53 static bool verbose;
54
57
60
62 void set_standard (const Profile* standard);
63
65 const Profile* get_standard () const;
66
68 void add_observation ( const Profile* );
69
71 void set_observation ( const Profile* );
72
74 void delete_observations ();
75
77 void fit (const Profile* observation);
78
80 void solve ();
81
84
87
89 void set_maximum_harmonic (unsigned max);
90
92 unsigned get_maximum_harmonic () const { return maximum_harmonic; }
93
95 void set_choose_maximum_harmonic (bool flag);
96
99
101 unsigned get_nharmonic () const { return n_harmonic; }
102
104 void set_regions (const PhaseWeight& pulse, const PhaseWeight& baseline);
105
108
111
113 double get_reduced_chisq () const;
114
115 protected:
116
119
122
125
127 unsigned n_harmonic;
128
130
132
134 class Data;
135
137 std::vector<Data> data;
138
140 void init ();
141
143 void model_profile ();
144
145 Estimate<double> best_shift;
146 Estimate<double> best_scale;
147
148 double chisq;
149 unsigned nfree;
150
151 private:
152
154 bool regions_set;
155
156 };
157
158 class ScalarTemplateMatching::Data
159 {
160 public:
161 void set_stats (FluctuationSpectrumStats*);
162 FluctuationSpectrumStats* get_stats ();
163
164 void set_standard (const Profile*);
165 const Profile* get_standard () const;
166 const Profile* get_standard_fourier () const;
167
168 void set_observation (const Profile*);
169 const Profile* get_observation () const;
170 const Profile* get_observation_fourier () const;
171
173 double get_residual_variance (double scale) const;
174
175 protected:
176
179
180 class ProfileData
181 {
182 public:
184 ProfileData() { variance = 0.0; }
185
188
191
193 double variance;
194
195 }; // class ProfileData
196
197 ProfileData standard;
198 ProfileData observation;
199
200 }; // class ScalarTemplateMatching::Data
201
202} // namespace Pulsar
203
204#endif
205
Computes statistics of the fluctuation spectrum (Fourier transform of pulse profile)
Definition FluctuationSpectrumStats.h:22
Stores a weight for each Profile phase bin.
Definition PhaseWeight.h:24
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
void model_profile()
Implement the solve method using the original model_profile algorithm.
Definition model_profile.C:106
void set_plan(FTransform::Plan *)
Set the fourier transform plan.
Definition ScalarTemplateMatching.C:71
Reference::To< FluctuationSpectrumStats > stats
Used to compute the variance of the off-pulse harmonics.
Definition ScalarTemplateMatching.h:118
void delete_observations()
Delete any previously added observations.
Definition ScalarTemplateMatching.C:158
void init()
Construtor helper.
Definition ScalarTemplateMatching.C:60
unsigned maximum_harmonic
The maximum number of harmonics to include in the fit.
Definition ScalarTemplateMatching.h:121
bool compute_reduced_chisq
Compute the reduced chisq (using the expected variance of the residual profile)
Definition ScalarTemplateMatching.h:131
~ScalarTemplateMatching()
Destructor.
Definition ScalarTemplateMatching.C:51
static bool verbose
Verbosity flag.
Definition ScalarTemplateMatching.h:53
const Profile * get_standard() const
Get the standard to which observations will be fit.
Definition ScalarTemplateMatching.C:87
Estimate< double > get_phase() const
Get the phase offset between the standard and the observation in radians.
Definition ScalarTemplateMatching.C:210
void set_observation(const Profile *)
Set the only profile to be fit to the standard/template.
Definition ScalarTemplateMatching.C:163
void set_maximum_harmonic(unsigned max)
Set the maximum number of harmonics to include in fit.
Definition ScalarTemplateMatching.C:76
void solve()
Fit all observations to the standard.
Definition ScalarTemplateMatching.C:184
void set_compute_reduced_chisq(bool flag)
When true, compute the reduced chisq; when false, assume it is unity.
Definition ScalarTemplateMatching.h:110
void set_regions(const PhaseWeight &pulse, const PhaseWeight &baseline)
Set the on-pulse and baseline regions.
Definition ScalarTemplateMatching.C:95
unsigned get_nharmonic() const
Get the number of harmonics to be included in fit.
Definition ScalarTemplateMatching.h:101
void add_observation(const Profile *)
Add the specified profile to be fit to the standard/template.
void fit(const Profile *observation)
Fit the specified observation to the standard.
Definition ScalarTemplateMatching.C:148
double get_reduced_chisq() const
Get the statistical goodness of fit.
Definition ScalarTemplateMatching.C:204
ScalarTemplateMatching()
Default constructor.
Definition ScalarTemplateMatching.C:26
void set_choose_maximum_harmonic(bool flag)
Set the maximum number of harmonics to include in fit.
Definition ScalarTemplateMatching.C:81
unsigned n_harmonic
The number of harmonics in the fit.
Definition ScalarTemplateMatching.h:127
void set_standard(const Profile *standard)
Set the standard to which observations will be fit.
Definition ScalarTemplateMatching.C:102
unsigned get_maximum_harmonic() const
Get the maximum number of harmonics to include in fit.
Definition ScalarTemplateMatching.h:92
bool get_choose_maximum_harmonic() const
Get the maximum number of harmonics to include in fit.
Definition ScalarTemplateMatching.h:98
bool choose_maximum_harmonic
Set true when set_standard should choose the maximum harmonic.
Definition ScalarTemplateMatching.h:124
std::vector< Data > data
Standards and observations.
Definition ScalarTemplateMatching.h:137
Estimate< double > get_scale() const
Get the scale factor between the standard and the observation.
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0