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/Variable.h"
25#include "MEAL/Gain.h"
26#include "MEAL/Axis.h"
27#include "MEAL/Real4.h"
28
29namespace Calibration
30{
31 class VariableBackend;
33
35
47
49 {
51 std::string name;
52
53 public:
54
56 static bool verbose;
57
60
62 void set_name (const std::string& _name) { name = _name; }
63
65 void copy (SignalPath* other);
66
68
69 void share (SignalPath* other);
70
73
75 void reset ();
76
79
82 get_response_variation (unsigned iparam) const;
83
86
89
90 bool has_basis () const { return basis; }
91 MEAL::Complex2* get_basis () { return basis; }
92 const MEAL::Complex2* get_basis () const { return basis; }
93
95 void set_constant_pulsar_gain (bool = true);
96
98 class PulsarPath;
99
101 class PolnCalPath;
102
104 void set_foreach_calibrator (const MEAL::Complex2*);
105
107 void set_stepeach_calibrator (const VariableBackend*);
108
110 void set_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
111
113 void set_diff_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
114
116 void set_diff_phase_variation (MEAL::Univariate<MEAL::Scalar>*);
117
120 { return gain_variation; }
121
124 { return diff_gain_variation; }
125
128 { return diff_phase_variation; }
129
131 void add_calibrator_epoch (const MJD&);
132
134 void add_gain_step (const MJD&);
135
137 void add_diff_gain_step (const MJD&);
138
140 void add_diff_phase_step (const MJD&);
141
143 void add_step (const MJD& mjd,
144 Calibration::VariableBackend* backend = 0);
145
147 void add_observation_epoch (const MJD&);
148
150 void set_reference_epoch (const MJD& epoch);
151
153 void update ();
154
156 void fit_gain (bool flag);
157
159 void equal_ellipticities ();
160
162 bool reduce_nfree ();
163
165 void check_constraints ();
166
168 void solve ();
169
172
175
177 void fix_orientation ();
178
180 unsigned get_cal_path_index (const MJD&) const;
181
183 unsigned get_psr_path_index (const MJD&) const;
184
186 VariableBackendEstimate* get_backend (const MJD& epoch) const;
187
190
192 void integrate_calibrator (const MJD& epoch,
193 const MEAL::Complex2* xform);
194
198
201
204
207
209 const MEAL::Complex2* get_transformation () const;
210
213
216
218 const MEAL::Complex2* get_pulsar_transformation (const MJD&) const;
219
221 void get_covariance( std::vector<double>& covar, const MJD& epoch );
222
225
227 void disengage_time_variations (const MJD& epoch);
228
231
233 bool get_time_variations_engaged () const { return time_variations_engaged; }
234
236 void set_step_after_cal (bool flag = true);
237
239 void set_refcal_through_frontend (bool flag = true);
240
241 void set_valid (bool f, const char* reason = 0);
242 bool get_valid () const { return valid; }
243 std::string get_invalid_reason () const { return invalid_reason; }
244
245 void set_projection (MEAL::Variable<MEAL::Complex2>*);
246 MEAL::Variable<MEAL::Complex2>* get_projection ()
247 { return projection; }
248
249 void set_faraday_rotation (MEAL::Variable<MEAL::Complex2>*);
250 MEAL::Variable<MEAL::Complex2>* get_faraday_rotation ()
251 { return faraday_rotation; }
252
253 protected:
254
256 bool valid;
257
259 std::string invalid_reason;
260
263
266
268
274
276
279
282
285
288
291
294
297 std::map< unsigned, ScalarReference > response_variation;
298
301
303
306 std::vector< Reference::To< VariableBackendEstimate > > backends;
307
310
314
316
320
322
325
327
329
332
333 void integrate_parameter (MEAL::Scalar* function, double value);
334
335 void update_parameter (MEAL::Scalar* function, double value);
336
338 void set_min_step (MEAL::Scalar* function, double minimum);
339
341 void offset_steps (MEAL::Scalar* function, double offset);
342
344 void set_free (unsigned iparam, const MJD& mjd);
345
347 void fix_last_step (MEAL::Scalar* function);
348
349 bool time_variations_engaged;
350 bool step_after_cal;
351 bool constant_pulsar_gain;
352 bool refcal_through_frontend;
353
354 MJD min_epoch, max_epoch;
355
356 private:
357
360
362 bool built;
363
365 bool sharing;
366
368 void build ();
369
371 void const_build () const;
372
373 };
374
375
376
377
378}
379
380#endif
Converts Argument type from MJD to double.
Definition ConvertMJD.h:20
Solve the measurement equation by non-linear least squares minimization.
Definition ReceptionModelSolver.h:22
Models a set of transformations and source polarizations.
Definition ReceptionModel.h:28
Manages multiple signal path transformations in a reception model.
Definition SignalPath.h:49
void set_impurity(MEAL::Real4 *)
Include an impurity transformation.
Definition SignalPath.C:130
Reference::To< MEAL::Complex2 > basis
The basis correction computed by the BasisCorrection class.
Definition SignalPath.h:281
void set_response(MEAL::Complex2 *)
Set the response transformation.
Definition SignalPath.C:96
void share(SignalPath *other)
Share reception model and common transformations of other instance.
Definition SignalPath.C:66
bool valid
validity flag
Definition SignalPath.h:256
const MEAL::Scalar * get_diff_gain_variation() const
Get the differential gain function of time.
Definition SignalPath.h:123
void update()
Update the relevant estimate.
Definition SignalPath.C:490
void add_transformation(MEAL::Complex2 *)
Add a transformation to the ReceptionModel.
Definition SignalPath.C:244
void set_stepeach_calibrator(const VariableBackend *)
Set the VariableBackend step to be cloned for each calibrator.
Definition SignalPath.C:447
Reference::To< Calibration::ReceptionModel > equation
The measurement equation.
Definition SignalPath.h:262
Calibration::ConvertMJD convert
Used to convert MJD to double.
Definition SignalPath.h:300
Reference::To< const MEAL::Complex2 > foreach_pcal
Transformation cloned for each calibrator observation.
Definition SignalPath.h:312
void copy(SignalPath *other)
Copy state of other instance.
Definition SignalPath.C:60
void set_free(unsigned iparam, const MJD &mjd)
Allow specified parameter to vary freely in step that spans mjd.
Definition SignalPath.C:791
std::string invalid_reason
reason for valid == false
Definition SignalPath.h:259
void set_diff_phase_variation(MEAL::Univariate< MEAL::Scalar > *)
Set differential phase to the univariate function of time.
Definition SignalPath.C:468
const MEAL::Complex2 * get_transformation() const
Get the instrumental transformation.
Definition SignalPath.C:222
void set_name(const std::string &_name)
Set the name of this instance.
Definition SignalPath.h:62
VariableBackendEstimate * max_weight_backend()
Get the backend with the maximum weight.
Definition SignalPath.C:962
Reference::To< MEAL::Complex2 > initial_response
Clone of newly created/unmodified respone used to implement reset.
Definition SignalPath.h:278
void set_foreach_calibrator(const MEAL::Complex2 *)
Set the transformation to be cloned for each calibrator.
Definition SignalPath.C:442
void add_step(const MJD &mjd, Calibration::VariableBackend *backend=0)
Insert a step into the instrumental response at the specified time.
Definition SignalPath.C:707
Reference::To< MEAL::Complex2 > solution_response
The instrumental response returned by get_transformation.
Definition SignalPath.h:331
const MEAL::Scalar * get_gain_variation() const
Get the gain function of time.
Definition SignalPath.h:119
void add_diff_gain_step(const MJD &)
Add a step to the differential gain variations.
Definition SignalPath.C:694
unsigned get_cal_path_index(const MJD &) const
Get the index for the signal path experienced by the reference source.
Definition SignalPath.C:431
void solve()
Solve the measurement equation.
Definition SignalPath.C:926
const MEAL::Scalar * get_diff_phase_variation() const
Get the differential phase function of time.
Definition SignalPath.h:127
unsigned get_psr_path_index(const MJD &) const
Get the index for the signal path experienced by the pulsar.
Definition SignalPath.C:437
void add_diff_phase_step(const MJD &)
Add a step to the differential phase variations.
Definition SignalPath.C:701
void disengage_time_variations(const MJD &epoch)
Deactivate time variations and set the Instrument to the given epoch.
Definition SignalPath.C:893
void offset_steps(MEAL::Scalar *function, double offset)
Offset the steps if Scalar is a Steps.
void equal_ellipticities()
Set the receptor ellipticities to a single value.
Definition SignalPath.C:569
void set_diff_gain_variation(MEAL::Univariate< MEAL::Scalar > *)
Set differential gain to the univariate function of time.
Definition SignalPath.C:460
void fix_last_step(MEAL::Scalar *function)
Remove the last step if there is no data there.
void set_reference_epoch(const MJD &epoch)
Set the reference epoch.
Definition SignalPath.C:676
static bool verbose
Verbosity flag.
Definition SignalPath.h:56
void integrate_calibrator(const MJD &epoch, const MEAL::Complex2 *xform)
Integrate a calibrator solution.
Definition SignalPath.C:667
void add_psr_path(VariableBackendEstimate *)
Add a new signal path for pulsar observations.
Definition SignalPath.C:367
Reference::To< Calibration::ReceptionModel::Solver > solver
The algorithm used to solve the measurement equation.
Definition SignalPath.h:265
std::vector< Reference::To< VariableBackendEstimate > > backends
The set of instrumental backend transformations for each epoch.
Definition SignalPath.h:306
MEAL::Axis< MJD > time
The time axis.
Definition SignalPath.h:224
void check_constraints()
Check all relevant constraints.
Definition SignalPath.C:548
void set_step_after_cal(bool flag=true)
Set whether steps occur before or after cals.
Definition SignalPath.C:861
const MEAL::Complex2 * get_pulsar_transformation(const MJD &) const
Get the full signal path experienced by the pulsar.
Definition SignalPath.C:214
Reference::To< MEAL::ChainRule< MEAL::Complex2 > > response_chain
ChainRule used to model response parameter variations.
Definition SignalPath.h:293
SignalPath(Pulsar::Calibrator::Type *)
Default constructor.
Definition SignalPath.C:39
bool reduce_nfree()
Attempt to reduce the number of degrees of freedom in the model.
Definition SignalPath.C:602
void fit_gain(bool flag)
Allow the absolute gain to vary as a free parameter.
Definition SignalPath.C:564
void set_constant_pulsar_gain(bool=true)
Set true when the pulsar Stokes parameters have been normalized.
Definition SignalPath.C:178
Reference::To< MEAL::Variable< MEAL::Complex2 > > projection
The transformation from the celestial sphere to the receptors.
Definition SignalPath.h:287
void add_observation_epoch(const MJD &)
Record the epochs of observations.
Definition SignalPath.C:799
Reference::To< MEAL::Univariate< MEAL::Scalar > > ScalarReference
Temporal variation of response parameters.
Definition SignalPath.h:296
const MEAL::Univariate< MEAL::Scalar > * get_response_variation(unsigned iparam) const
Get the specified response parameter temporal variation function.
Definition SignalPath.C:119
void reset()
Reset the response to its initial/unmodified value.
Definition SignalPath.C:333
void fix_orientation()
Fix the rotation about the line of sight.
Definition SignalPath.C:476
VariableBackendEstimate * new_backend(MEAL::Complex2 *response=0)
Return a newly constructed and initialized backend.
Definition SignalPath.C:339
void add_cal_path(VariableBackendEstimate *)
Add a new signal path for poln calibrator observations.
Definition SignalPath.C:401
Reference::To< MEAL::Complex2 > response
The common instrumental response to be modelled.
Definition SignalPath.h:275
Calibration::ReceptionModel * get_equation()
Get the measurement equation.
Definition SignalPath.C:187
void engage_time_variations()
Activate time varations.
Definition SignalPath.C:874
void copy_transformation(const MEAL::Complex2 *)
Copy the parameters for the signal path experienced by the pulsar.
Definition SignalPath.C:627
bool get_time_variations_engaged() const
Return true if time-variations are engaged.
Definition SignalPath.h:233
void set_response_variation(unsigned iparam, MEAL::Univariate< MEAL::Scalar > *)
Allow the specified response parameter to vary as a function of time.
Definition SignalPath.C:106
void get_covariance(std::vector< double > &covar, const MJD &epoch)
Get the covariance vector at the specified epoch.
Definition SignalPath.C:983
void add_calibrator_epoch(const MJD &)
Add a step if any of the above functions require it.
Definition SignalPath.C:813
void set_refcal_through_frontend(bool flag=true)
e.g. true if noise diode illuminates feed; false if coupled after OMT
Definition SignalPath.C:866
void set_gain_variation(MEAL::Univariate< MEAL::Scalar > *)
Set gain to the univariate function of time.
Definition SignalPath.C:452
void set_equation(Calibration::ReceptionModel *)
Set the measurement equation.
Definition SignalPath.C:201
Reference::To< MEAL::Variable< MEAL::Complex2 > > faraday_rotation
Ionospheric and interstellar Faraday rotation.
Definition SignalPath.h:290
void add_gain_step(const MJD &)
Add a step to the gain variations.
Definition SignalPath.C:687
Reference::To< MEAL::ProductRule< MEAL::Complex2 > > instrument
The instrumental response multiplied by the basis.
Definition SignalPath.h:284
void set_min_step(MEAL::Scalar *function, double minimum)
Set the minimum step if Scalar is a Steps.
Reference::To< MEAL::Real4 > impurity
The (optional) common instrumental impurity to be modelled.
Definition SignalPath.h:326
void set_solver(Calibration::ReceptionModel::Solver *)
Set the algorithm used to solve the measurement equation.
Definition SignalPath.C:170
VariableBackendEstimate * get_backend(const MJD &epoch) const
Get the backend that spans the specified epoch.
Definition SignalPath.C:654
void set_basis(MEAL::Complex2 *)
Set the transformation to the receptor basis.
Definition SignalPath.C:139
Manages a variable backend and its best estimate.
Definition VariableBackendEstimate.h:41
Physical parameterization of the instrumental response.
Definition VariableBackend.h:31
Definition CalibratorType.h:26

Generated using doxygen 1.14.0