ComplexRVMFit.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2009 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/Polarimetry/Pulsar/ComplexRVMFit.h
10
11#ifndef __Pulsar_ComplexRVMFit_h
12#define __Pulsar_ComplexRVMFit_h
13
14#include "MEAL/Axis.h"
15#include "Estimate.h"
16
17#include <complex>
18
19// forward declarations
20namespace MEAL
21{
22 class ComplexRVM;
23 class OrthoRVM;
25}
26
27typedef std::pair<double,double> range;
28
29namespace Pulsar
30{
31 class PolnProfile;
32
35 {
36
37 public:
38
40 static bool verbose;
41
44
46 double get_gate_duty_cycle() const { return gate; }
47
49 virtual void set_gate_duty_cycle (double turns) { gate = turns; }
50
52
53 void add_opm (const range& radians);
54
56 bool is_opm (double phase_in_radians) const;
57
59
60 void add_include (const range& radians);
61
63 bool is_included (double phase_in_radians) const;
64
66
67 void add_exclude (const range& radians);
68
70 bool is_excluded (double phase_in_radians) const;
71
73 void set_observation (const PolnProfile*);
75 const PolnProfile* get_observation () const;
76
78 void set_threshold (float sigma);
80 float get_threshold () const;
81
83 void set_guess_smooth (unsigned phase_bins);
85 unsigned get_guess_smooth () const;
86
89
91 void solve ();
92
93 void set_chisq_map (bool flag) { chisq_map = flag; }
94
95 void set_range_alpha (const range& r) { range_alpha = r; }
96 void set_range_zeta (const range& r) { range_zeta = r; }
97 void set_range_beta (const range& r) { range_beta = r; }
98
99 void search_2D (unsigned nalpha, unsigned nzeta);
100 void search_1D (unsigned nzeta);
101
103 double evaluate (double phi_radians);
104
105 float get_chisq () const { return chisq; }
106 unsigned get_nfree () const { return nfree; }
107
108 // get the post-fit residuals of Stokes Q and U
109 void get_residuals (std::vector<double>& phases,
110 std::vector< std::complex< Estimate<double> > >& res);
111
112 // get the post-fit residuals of position angle
113 void get_psi_residuals (std::vector<double>& phases,
114 std::vector< Estimate<double> >& res);
115
116 protected:
117
118 // fraction of pulse period stored in pulse profile
119 double gate;
120
121 void check_parameters ();
122
123 void init (MEAL::RotatingVectorModel*);
124 void init (MEAL::OrthoRVM*);
125
126 void check_parameters (MEAL::RotatingVectorModel*);
127
128 Reference::To<const PolnProfile> data;
129 Reference::To<MEAL::ComplexRVM> model;
130
131 float threshold;
132
133 // ranges of pulse longitude to include in model
134 std::vector<range> range_include;
135 // ranges of pulse longitude to exclude from model
136 std::vector<range> range_exclude;
137
138 MEAL::Axis<unsigned> state;
139 std::vector< MEAL::Axis<unsigned>::Value > data_x;
140 std::vector< std::complex< Estimate<double> > > data_y;
141
142 // orthogonally polarized mode phase ranges
143 std::vector<range> opm;
144
145 range range_alpha;
146 range range_beta;
147 range range_zeta;
148
149 // length of the first guess ellipse along the sin(alpha) axis
150 float guess_alpha;
151 // length of the first guess ellipse along the sin(beta) axis
152 float guess_beta;
153
154 // number of phase bins in smoothing window used to stabilize first guess
155 unsigned guess_smooth;
156
157 private:
158
159 // used by set_observation method to find the maximum in delpsi/delphi
160 void find_delpsi_delphi_max ();
161
162 // set L of each bin to least-squares best fit
163 void renormalize();
164
165 std::vector< std::complex< Estimate<double> > > linear;
166 double delpsi_delphi;
167
168 float peak_phase;
169 float peak_pa;
170
171 float chisq;
172 unsigned nfree;
173 bool chisq_map;
174
175 double max_L;
176
177 bool auto_detect_opm;
178 };
179}
180
181#endif
182
static bool verbose
Verbosity flag.
Definition ComplexRVMFit.h:40
void add_opm(const range &radians)
Add a range of pulse phase containing an orthogonally polarized mode.
Definition ComplexRVMFit.C:375
MEAL::ComplexRVM * get_model()
Get the model to be fit to the data.
Definition ComplexRVMFit.C:416
void solve()
Fit data to the model.
Definition ComplexRVMFit.C:467
bool is_excluded(double phase_in_radians) const
Return true if pulse phase falls within an excluded range.
Definition ComplexRVMFit.C:400
void set_observation(const PolnProfile *)
Set the data to which model will be fit.
Definition ComplexRVMFit.C:143
bool is_opm(double phase_in_radians) const
Return true if pulse phase falls within an OPM range.
Definition ComplexRVMFit.C:380
unsigned get_guess_smooth() const
Get the smoothing window used to stabilize first guess.
Definition ComplexRVMFit.C:67
virtual void set_gate_duty_cycle(double turns)
Set the fraction of the pulse period modelled (in turns)
Definition ComplexRVMFit.h:49
double get_gate_duty_cycle() const
Get the fraction of the pulse period modelled (in turns)
Definition ComplexRVMFit.h:46
ComplexRVMFit()
Default constructor.
Definition ComplexRVMFit.C:35
float get_threshold() const
Get the threshold below which data are ignored.
Definition ComplexRVMFit.C:57
void set_threshold(float sigma)
Set the threshold below which data are ignored.
Definition ComplexRVMFit.C:52
const PolnProfile * get_observation() const
Get the data to which model will be fit.
Definition ComplexRVMFit.C:406
bool is_included(double phase_in_radians) const
Return true if pulse phase falls within an included range.
Definition ComplexRVMFit.C:390
double evaluate(double phi_radians)
Evaluate the model at the specified pulse longitude (in radians)
Definition ComplexRVMFit.C:698
void add_exclude(const range &radians)
Add a range of pulse phase to be excluded from constraints.
Definition ComplexRVMFit.C:395
void add_include(const range &radians)
Add a range of pulse phase to be included as constraints.
Definition ComplexRVMFit.C:385
void set_guess_smooth(unsigned phase_bins)
Set the smoothing window used to stabilize first guess.
Definition ComplexRVMFit.C:62
Polarimetric pulse profile transformations and derivations.
Definition PolnProfile.h:29
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0