SignalPath.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2005-2009 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Polarimetry/Pulsar/SignalPath.h
10 
11 #ifndef __Calibration_SignalPath_H
12 #define __Calibration_SignalPath_H
13 
14 // Reception Model and its management
15 #include "Pulsar/ReceptionModel.h"
16 #include "Pulsar/ReceptionModelSolver.h"
17 
18 #include "Pulsar/CalibratorType.h"
19 #include "Pulsar/ConvertMJD.h"
20 
21 #include "MEAL/ProductRule.h"
22 #include "MEAL/ChainRule.h"
23 #include "MEAL/Univariate.h"
24 #include "MEAL/Gain.h"
25 #include "MEAL/Axis.h"
26 #include "MEAL/Real4.h"
27 
28 namespace Calibration
29 {
31 
36  class VariableBackendEstimate;
37  class VariableBackend;
38  class BackendEstimate;
39 
40  class SignalPath : public Reference::Able
41  {
42  public:
43 
45  static bool verbose;
46 
48  SignalPath (Pulsar::Calibrator::Type*);
49 
51  void copy (SignalPath*);
52 
54  void set_response (MEAL::Complex2*);
55 
57  void reset ();
58 
60  void set_response_variation (unsigned iparam,
62 
65  get_response_variation (unsigned iparam) const;
66 
68  void set_impurity (MEAL::Real4*);
69 
71  void set_basis (MEAL::Complex2*);
72 
73  bool has_basis () const { return basis; }
74  MEAL::Complex2* get_basis () { return basis; }
75  const MEAL::Complex2* get_basis () const { return basis; }
76 
78  void set_constant_pulsar_gain (bool = true);
79 
81  class PulsarPath;
82 
84  class PolnCalPath;
85 
87  void set_foreach_calibrator (const MEAL::Complex2*);
88 
90  void set_stepeach_calibrator (const VariableBackend*);
91 
93  void set_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
94 
96  void set_diff_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
97 
99  void set_diff_phase_variation (MEAL::Univariate<MEAL::Scalar>*);
100 
102  const MEAL::Scalar* get_gain_variation () const
103  { return gain_variation; }
104 
106  const MEAL::Scalar* get_diff_gain_variation () const
107  { return diff_gain_variation; }
108 
110  const MEAL::Scalar* get_diff_phase_variation () const
111  { return diff_phase_variation; }
112 
114  void add_calibrator_epoch (const MJD&);
115 
117  void add_gain_step (const MJD&);
118 
120  void add_diff_gain_step (const MJD&);
121 
123  void add_diff_phase_step (const MJD&);
124 
126  void add_step (const MJD& mjd,
127  Calibration::VariableBackend* backend = 0);
128 
130  void add_observation_epoch (const MJD&);
131 
133  void set_reference_epoch (const MJD& epoch);
134 
136  void update ();
137 
139  void fit_gain (bool flag);
140 
142  void equal_ellipticities ();
143 
145  bool reduce_nfree ();
146 
148  void check_constraints ();
149 
151  void solve ();
152 
154  void add_psr_path (VariableBackendEstimate*);
155 
157  void add_cal_path (VariableBackendEstimate*);
158 
160  void fix_orientation ();
161 
163  unsigned get_cal_path_index (const MJD&) const;
164 
166  unsigned get_psr_path_index (const MJD&) const;
167 
169  VariableBackendEstimate* get_backend (const MJD& epoch) const;
170 
172  VariableBackendEstimate* max_weight_backend ();
173 
175  void integrate_calibrator (const MJD& epoch,
176  const MEAL::Complex2* xform);
177 
179  Calibration::ReceptionModel* get_equation ();
180  const Calibration::ReceptionModel* get_equation () const;
181 
183  void set_equation (Calibration::ReceptionModel*);
184 
186  void set_solver (Calibration::ReceptionModel::Solver*);
187 
189  void copy_transformation (const MEAL::Complex2*);
190 
192  const MEAL::Complex2* get_transformation () const;
193 
195  MEAL::Complex2* get_transformation ();
196 
198  void add_transformation (MEAL::Complex2*);
199 
201  const MEAL::Complex2* get_pulsar_transformation (const MJD&) const;
202 
204  void get_covariance( std::vector<double>& covar, const MJD& epoch );
205 
207  MEAL::Axis<MJD> time;
208 
210  void disengage_time_variations (const MJD& epoch);
211 
213  void engage_time_variations ();
214 
216  void set_step_after_cal (bool flag = true);
217 
219  void set_refcal_through_frontend (bool flag = true);
220 
221  void set_valid (bool f, const char* reason = 0);
222  bool get_valid () const { return valid; }
223  std::string get_invalid_reason () const { return invalid_reason; }
224 
225  MEAL::Axis< Jones<double> >& get_projection () { return projection; }
226 
227  protected:
228 
230  bool valid;
231 
233  std::string invalid_reason;
234 
237 
240 
242 
249 
251  Reference::To< MEAL::Complex2 > initial_response;
252 
255 
258 
261 
263 
264  MEAL::Axis< Jones<double> > projection;
265 
268 
270  typedef Reference::To<MEAL::Univariate<MEAL::Scalar> > ScalarReference;
271  std::map< unsigned, ScalarReference > response_variation;
272 
274  Calibration::ConvertMJD convert;
275 
277 
279  std::vector< Reference::To< VariableBackendEstimate > > backends;
280 
282  VariableBackendEstimate* new_backend (MEAL::Complex2* response = 0);
283 
287 
289 
291  Reference::To< MEAL::Univariate<MEAL::Scalar> > diff_gain_variation;
292  Reference::To< MEAL::Univariate<MEAL::Scalar> > diff_phase_variation;
293 
296 
298 
300  Reference::To< MEAL::Complex2 > solution_response;
301 
302  void integrate_parameter (MEAL::Scalar* function, double value);
303 
304  void update_parameter (MEAL::Scalar* function, double value);
305 
307  void set_min_step (MEAL::Scalar* function, double minimum);
308 
310  void offset_steps (MEAL::Scalar* function, double offset);
311 
313  void set_free (unsigned iparam, const MJD& mjd);
314 
316  void fix_last_step (MEAL::Scalar* function);
317 
318  bool time_variations_engaged;
319  bool step_after_cal;
320  bool constant_pulsar_gain;
321  bool refcal_through_frontend;
322 
323  MJD min_epoch, max_epoch;
324 
325  private:
326 
329 
331  bool built;
332 
334  void build ();
335 
337  void const_build () const;
338 
339  };
340 
341 
342 
343 
344 }
345 
346 #endif
Calibration::ConvertMJD convert
Used to convert MJD to double.
Definition: VariableBackendEstimate.h:110
Phenomenological description of the instrument.
Definition: Instrument.h:31
void covariance(Scalar *function, unsigned index, std::vector< unsigned > &imap, std::vector< std::vector< double > > &covar)
unsigned get_nparam() const
virtual void set_constant_orientation(bool flag=true)=0
Fix the orientation of the frontend.
void equal_ellipticities()
Model the ellipticities of both receptors using the same value.
Definition: Britton2000.C:110
MEAL::ScalarParameter * get_ellipticities()
Return the single model parameter that constrains both ellipticities.
Definition: Instrument.h:57
Univariate< T > * clone() const
Phenomenological description of the instrument.
Definition: Britton2000.h:35
void equal_ellipticities()
Model the ellipticities of both receptors using the same value.
Definition: Instrument.C:118
const MEAL::Complex2 * get_frontend() const
Provide access to the frontend model.
Definition: BackendFeed.h:69
VariableBackend * clone() const
Clone operator.
Definition: VariableBackend.C:52
Models a set of transformations and source polarizations.
Definition: ReceptionModel.h:32
IndexedProduct * get_cal_response()
Get the response for calibrator observations.
Definition: VariableBackendEstimate.h:94
Type * get() const
Solve the measurement equation by non-linear least squares minimization.
Definition: ReceptionModelSolver.h:26
void independent_ellipticities()
Model the ellipticities of the receptors using independent values.
Definition: Instrument.C:128
virtual Complex2 * clone() const
void set_Estimate(unsigned index, const Estimate< double > &param)
void set_epoch(const MJD &)
Set the epoch.
Definition: ConvertMJD.C:16
Manages a single backend and its current best estimate (first guess)
Definition: BackendEstimate.h:54
void add_model(MEAL::Complex2 *xform)
Multiply psr_response by xform and cal_response by backend.
Definition: VariableBackendEstimate.C:97
Instrumental gain, differential gain, and differential phase.
Definition: SingleAxis.h:38
static bool very_verbose
Converts Argument type from MJD to double.
Definition: ConvertMJD.h:25
void set_model(T *model)
SingleAxis * get_backend()
Get the backend component.
Definition: VariableBackendEstimate.h:97
Definition: CalibratorType.h:30
bool verbose
Definition: timer++.C:25
bool get_infit(unsigned index) const
std::string get_param_name(unsigned index) const
MEAL::Complex2 * new_transformation(const PolnCalibratorExtension *, unsigned ichan)
Create a new transformation instance described by the extension.
Definition: PolnCalibratorExt.C:126
const std::string get_message() const
Physical parameterization of the instrumental response.
Definition: VariableBackend.h:35
Physical parameterization of the instrumental response.
Definition: BackendFeed.h:31
unsigned get_ellipticity_index(unsigned receptor) const
Get the index of the ellipticity parameter for the specified receptor.
Definition: Instrument.C:90
Estimate< double > get_Estimate(unsigned index) const
Manages a variable backend and its best estimate.
Definition: VariableBackendEstimate.h:46
bool has_equal_ellipticities() const
Return true if both ellipticities are constrained by a single parameter.
Definition: Instrument.h:60
IndexedProduct * get_psr_response()
Get the response for pulsar observations.
Definition: VariableBackendEstimate.h:91
void set_infit(unsigned index, bool flag)
void set_solver(Solver *)
Set the algorithm used to solve the measurement equation.
Definition: ReceptionModel.C:44

Generated using doxygen 1.8.17