PolnProfileFit.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2003-2009 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Polarimetry/Pulsar/PolnProfileFit.h
10 
11 #ifndef __Pulsar_PolnProfileFit_h
12 #define __Pulsar_PolnProfileFit_h
13 
14 #include "Pulsar/CoherencyMeasurementSet.h"
15 #include "Pulsar/PhaseWeight.h"
16 
17 #include "MEAL/Axis.h"
18 #include "Matrix.h"
19 #include "Estimate.h"
20 #include "Stokes.h"
21 #include "FTransformAgent.h"
22 #include "toa.h"
23 
24 // forward declarations
25 namespace MEAL
26 {
27  class Complex2;
28  template<typename T> class PhaseGradients;
29 }
30 
31 namespace Calibration
32 {
33  class ReceptionModel;
34  class TemplateUncertainty;
35  class StandardSpectra;
36 }
37 
38 namespace Pulsar
39 {
40  class PolnProfile;
41  class Profile;
42 
44 
51  {
52 
53  public:
54 
56  static bool verbose;
57 
59  class Analysis;
60 
62  PolnProfileFit ();
63 
66 
69 
71  ~PolnProfileFit ();
72 
74  PolnProfileFit* clone () const;
75 
77  void set_maximum_harmonic (unsigned max);
78 
80  unsigned get_maximum_harmonic () const { return maximum_harmonic; }
81 
83  unsigned get_nharmonic () const { return n_harmonic; }
84 
86  void set_regions (const PhaseWeight& pulse, const PhaseWeight& baseline);
87 
89  void set_standard (const PolnProfile* standard);
90 
92  const PolnProfile* get_standard () const;
93 
96  const PolnProfile* );
97 
99  void add_observation ( const PolnProfile* );
100 
102  void set_observation ( const PolnProfile* );
103 
105  void delete_observations ();
106 
109 
111  void set_transformation (MEAL::Complex2* xform);
112 
115 
117  void set_fit_debug (bool flag = true);
118 
120  void set_normalize_by_invariant (bool set = true);
121 
123  void fit (const PolnProfile* observation);
124 
126  void solve ();
127 
129  void set_plan (FTransform::Plan*);
130 
134 
136  Estimate<double> get_phase () const;
137 
139  double get_reduced_chisq () const;
140 
142  void set_phase (const Estimate<double>& phase);
143 
145  void set_phase_lock (bool locked);
146 
148  void share_phase ();
149 
151  void remove_phase ();
152 
154  Tempo::toa get_toa (const PolnProfile* observation,
155  const MJD& mjd, double period,
156  const std::string& nsite);
157 
159  float ccf_max_phase (const Profile* std, const Profile* obs) const;
160 
163 
166 
169 
170  protected:
171 
172  friend class ScalarProfileFitAnalysis;
173 
176 
178  unsigned n_harmonic;
179 
182 
185 
188 
191 
194 
197 
200 
202  std::vector< Reference::To<Calibration::TemplateUncertainty> > uncertainty;
203 
206 
209 
212 
215 
217  bool fit_debug;
218 
220  void init ();
221 
222  Stokes< std::complex<double> > standard_variance;
223 
224  private:
225 
227  bool regions_set;
228 
229  };
230 
231 }
232 
233 #endif
234 
void phase(Profile *input)
Compute the phase of the input complex-valued Profile.
Definition: Fourier.C:135
void add_observation(Calibration::CoherencyMeasurementSet &, const PolnProfile *)
Add the specified observation to the measurement set.
Definition: PolnProfileFit.C:372
void set_plan(FTransform::Plan *)
Set the fourier transform plan.
Definition: PolnProfileFit.C:110
bool fit_debug
The fit debug flag.
Definition: PolnProfileFit.h:217
Reference::To< Calibration::StandardSpectra > standard_data
Normalization by total invariant interval with error propagation.
Definition: PolnProfileFit.h:196
double get_centre_frequency() const
get the centre frequency (in MHz)
Definition: Profile.h:202
const PolnProfile * get_standard() const
Get the standard to which observations will be fit.
Definition: PolnProfileFit.C:121
void set_standard(const PolnProfile *standard)
Set the standard to which observations will be fit.
Definition: PolnProfileFit.C:148
bool choose_maximum_harmonic
Set true when set_standard should choose the maximum harmonic.
Definition: PolnProfileFit.h:162
void set_phase_lock(bool locked)
Lock pulse phase; i.e., do not allow pulse phase to vary in fit.
Definition: PolnProfileFit.C:294
void delete_observations()
Delete any previously added observations.
Definition: PolnProfileFit.C:332
float ccf_max_phase(const Profile *std, const Profile *obs) const
Return the phase shift based on the cross correlation function.
Definition: PolnProfileFit.C:590
void set_regions(const PhaseWeight &pulse, const PhaseWeight &baseline)
Set the on-pulse and baseline regions.
Definition: PolnProfileFit.C:141
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
Analysis of the matrix template matching algorithm.
Definition: PolnProfileFitAnalysis.h:30
PolnProfileFit()
Default constructor.
Definition: PolnProfileFit.C:36
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
unsigned n_harmonic
The number of harmonics in the fit.
Definition: PolnProfileFit.h:178
void set_transformation(MEAL::Complex2 *xform)
Set the transformation between the standard and observation.
Definition: PolnProfileFit.C:270
bool manage_equation_transformation
Manage the equation transformation.
Definition: PolnProfileFit.h:165
Models a set of transformations and source polarizations.
Definition: ReceptionModel.h:32
bool phase_lock
Lock the phase to the initial estimate.
Definition: PolnProfileFit.h:184
Reference::To< MEAL::PhaseGradients< MEAL::Complex2 > > phases
The phase gradient model for each observation added.
Definition: PolnProfileFit.h:205
Type * get() const
void share_phase()
Share a single phase shift between all input observations.
Definition: PolnProfileFit.C:307
void set_observation(const PolnProfile *)
Set the only observation to be fit to the standard.
Definition: PolnProfileFit.C:342
Solve the measurement equation by non-linear least squares minimization.
Definition: ReceptionModelSolver.h:26
std::vector< Reference::To< Calibration::TemplateUncertainty > > uncertainty
Least-squares normalization includes variable template contribution.
Definition: PolnProfileFit.h:202
unsigned maximum_harmonic
The maximum number of harmonics to include in the fit.
Definition: PolnProfileFit.h:175
unsigned get_nharmonic() const
Get the number of harmonics to be included in fit.
Definition: PolnProfileFit.h:83
Calibration::ReceptionModel * get_equation()
Get the measurement equation used to model the fit.
Definition: PolnProfileFit.C:516
unsigned get_nbin() const
Get the number of bins.
Definition: PolnProfile.C:139
void fit(const PolnProfile *observation)
Fit the specified observation to the standard.
Definition: PolnProfileFit.C:322
A CoherencyMeasurement set and their coordinates.
Definition: CoherencyMeasurementSet.h:26
void init()
Construtor helper.
Definition: PolnProfileFit.C:88
virtual void set_transformation(Complex2 *xform)
Set the transformation, ,where =get_transformation_index.
Definition: MeasurementEquation.C:74
static bool verbose
Verbosity flag.
Definition: PolnProfileFit.h:56
Reference::To< Calibration::ReceptionModel > equation
The measurement equation used to model the fit.
Definition: PolnProfileFit.h:199
Polarimetric pulse profile transformations and derivations.
Definition: PolnProfile.h:34
Analysis of the scalar template matching algorithm.
Definition: PolnProfileFitAnalysis.h:185
Combines the uncertainty of the template and the observation.
Definition: TemplateUncertainty.h:25
void set_phase(const Estimate< double > &phase)
Set the phase offset between the observation and the standard.
Definition: PolnProfileFit.C:548
Tempo::toa get_toa(const PolnProfile *observation, const MJD &mjd, double period, const std::string &nsite)
Get the arrival time estimate.
Definition: PolnProfileFit.C:564
void set_maximum_harmonic(unsigned max)
Set the maximum number of harmonics to include in fit.
Definition: PolnProfileFit.C:115
bool shared_phase
Share a single phase shift between all input observations.
Definition: PolnProfileFit.h:181
PolnProfileFit & operator=(const PolnProfileFit &fit)
Assignment operator.
Definition: PolnProfileFit.C:50
void set_fit_debug(bool flag=true)
Set the debug mode in the ReceptionModel.
Definition: PolnProfileFit.C:286
PolnProfileFit * clone() const
Clone.
Definition: PolnProfileFit.C:78
void set_normalize_by_invariant(bool set=true)
Normalize each Stokes vector by the mean on-pulse invariant.
Definition: PolnProfileFit.C:83
Estimate< double > get_phase() const
Get the phase offset between the standard and the observation.
Definition: PolnProfileFit.C:535
Calibration::CoherencyMeasurementSet measurement_set
The template from which measurement sets are constructed.
Definition: PolnProfileFit.h:214
double get_reduced_chisq() const
Get the statistical goodness of fit.
Definition: PolnProfileFit.C:508
unsigned get_transformation_index() const
Get the transformation through which the measurements are made.
Definition: CoherencyMeasurementSet.C:30
A coherency matrix measurement and its estimated error.
Definition: CoherencyMeasurement.h:32
void set_stokes(const Stokes< Estimate< double > > &stokes)
Set the measured Stokes parameters.
Definition: CoherencyMeasurement.C:43
void set_measurement_set(const Calibration::CoherencyMeasurementSet &)
Set the template from which measurment sets will be constructed.
Definition: PolnProfileFit.C:357
Computes the normalized complex Stokes parameters in each harmonic.
Definition: StandardSpectra.h:30
float get_chisq() const
unsigned get_maximum_harmonic() const
Get the maximum number of harmonics to include in fit.
Definition: PolnProfileFit.h:80
void bcc1d(size_t nfft, float *into, const float *from)
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void add_coordinate(MEAL::Argument::Value *abscissa)
Add an independent variable.
Definition: CoherencyMeasurement.C:188
void solve()
Fit all observations to the standard.
Definition: PolnProfileFit.C:486
MEAL::Complex2 * get_transformation() const
Get the transformation between the standard and the observation.
Definition: PolnProfileFit.C:281
Reference::To< MEAL::Complex2 > transformation
The transformation between the standard and observation.
Definition: PolnProfileFit.h:193
~PolnProfileFit()
Destructor.
Definition: PolnProfileFit.C:74
Calibration::StandardSpectra * get_spectra()
Get the statistical interface to the data.
Definition: PolnProfileFit.C:529
Definition: PolnProfileFit.h:33
The matrix template matching algorithm.
Definition: PolnProfileFit.h:50
MEAL::Axis< double > phase_axis
The phase axis.
Definition: PolnProfileFit.h:208
unsigned get_nfree() const
const Profile * get_Profile(unsigned ipol) const
Get the specifed constant profile.
Definition: PolnProfile.C:147
MEAL::Axis< unsigned > index_axis
The gradient index axis.
Definition: PolnProfileFit.h:211
Reference::To< const PolnProfile > standard
The standard to which observations will be fit.
Definition: PolnProfileFit.h:187
Reference::To< const PolnProfile > standard_fourier
The Fourier transform of the standard.
Definition: PolnProfileFit.h:190
void remove_phase()
Remove pulse phase from model (may be more efficient, but irreversible)
Definition: PolnProfileFit.C:299

Generated using doxygen 1.8.17