VariableBackendEstimate.h
1 //-*-C++-*-
2 
3 /***************************************************************************
4  *
5  * Copyright (C) 2021 by Willem van Straten
6  * Licensed under the Academic Free License version 2.1
7  *
8  ***************************************************************************/
9 
10 // psrchive/More/Polarimetry/Pulsar/VariableBackendEstimate.h
11 
12 #ifndef __Pulsar_VariableBackendEstimate_H
13 #define __Pulsar_VariableBackendEstimate_H
14 
15 #include "Pulsar/BackendEstimate.h"
16 #include "Pulsar/VariableBackend.h"
17 #include "Pulsar/VariableGain.h"
18 #include "Pulsar/ConvertMJD.h"
19 
20 #include "MEAL/Scalar.h"
21 #include "MEAL/Univariate.h"
22 
23 #include <map>
24 
25 namespace Calibration
26 {
27  class IndexedProduct : public MEAL::ProductRule<MEAL::Complex2>
28  {
29  int index;
30 
31  public:
32  IndexedProduct () { index = -1; }
33 
34  bool has_index () const { return index >= 0; }
35  void set_index (unsigned _index) { index = _index; }
36  unsigned get_index () const { return index; }
37 
38  };
39 
41  class VariableBackendEstimate : public BackendEstimate
42  {
45 
48 
50  Reference::To<VariableBackend> variable_backend;
51 
53  bool cal_backend_only;
54 
56 
61 
63  Reference::To< MEAL::Scalar > gain_variation;
64  Reference::To< MEAL::Scalar > diff_gain_variation;
65  Reference::To< MEAL::Scalar > diff_phase_variation;
66 
69  std::vector< unsigned > gain_imap;
70  std::vector< unsigned > diff_gain_imap;
71  std::vector< unsigned > diff_phase_imap;
72  std::vector< unsigned > backend_imap;
73 
74  public:
75 
78 
80  void set_response (MEAL::Complex2* xform);
81 
83  void add_model (MEAL::Complex2* xform);
84 
86  IndexedProduct* get_psr_response () { return psr_response; }
87 
89  IndexedProduct* get_cal_response () { return cal_response; }
90 
92  SingleAxis* get_backend () { return variable_backend->get_backend(); }
93 
95  void set_psr_constant_gain (bool = true);
96 
98  void set_cal_backend_only (bool = true);
99 
100  void set_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
101  void set_diff_gain_variation (MEAL::Univariate<MEAL::Scalar>*);
102  void set_diff_phase_variation (MEAL::Univariate<MEAL::Scalar>*);
103 
106 
108  void update ();
109 
111  void update (MEAL::Scalar* function, double value);
112 
114 
115  bool reduce_nfree ();
116 
118  void update_reference_epoch ();
119 
121  void engage_time_variations ();
122  void disengage_time_variations ();
123 
124  void unmap_variations (std::vector<unsigned>& imap,
125  MEAL::Complex2* composite);
126 
127  void compute_covariance (std::vector<unsigned>& imap,
128  std::vector< std::vector<double> >& Ctotal);
129 
130 
131  };
132 }
133 
134 #endif
135 
Calibration::ConvertMJD convert
Used to convert MJD to double.
Definition: VariableBackendEstimate.h:110
void covariance(Scalar *function, unsigned index, std::vector< unsigned > &imap, std::vector< std::vector< double > > &covar)
Estimate< double > get_gain() const
Get the instrumental gain, , in calibrator flux units.
Definition: SingleAxis.C:84
Physical parameterization of the instrumental response.
Definition: VariableGain.h:33
void set_response(MEAL::Complex2 *xform)
Set the response that contains the backend.
Definition: VariableBackendEstimate.C:43
unsigned get_nparam() const
const SingleAxis * get_backend() const
Provide access to the SingleAxis model.
Definition: VariableBackend.C:127
Estimate< double > get_gain() const
Get the instrumental gain, , in calibrator flux units.
Definition: VariableBackend.C:71
void set_diff_phase_variation(MEAL::Scalar *)
Set the differential phase variation.
Definition: VariableBackend.C:176
void set_gain(const Estimate< double > &gain)
Set the instrumental gain, , in calibrator flux units.
Definition: VariableGain.C:64
void update_reference_epoch()
Update the reference epoch.
Definition: VariableBackendEstimate.C:194
void set_psr_constant_gain(bool=true)
Set true when the pulsar Stokes parameters have been normalized.
Definition: VariableBackendEstimate.C:235
IndexedProduct * get_cal_response()
Get the response for calibrator observations.
Definition: VariableBackendEstimate.h:94
Estimate< double > get_diff_phase() const
Get the differential phase, , in radians.
Definition: SingleAxis.C:96
void add_model(MEAL::Complex2 *xform)
Multiply psr_response by xform and cal_response by backend.
Definition: VariableBackendEstimate.C:97
Estimate< double > get_diff_gain() const
Get the differential gain, , in hyperbolic radians.
Definition: SingleAxis.C:90
Instrumental gain, differential gain, and differential phase.
Definition: SingleAxis.h:38
void resize(unsigned ncoef)
bool reduce_nfree()
Attempt to reduced the number of degrees of freedom.
Definition: VariableBackendEstimate.C:219
Converts Argument type from MJD to double.
Definition: ConvertMJD.h:25
SingleAxis * get_backend()
Get the backend component.
Definition: VariableBackendEstimate.h:97
void set_gain(const Estimate< double > &gain)
Set the instrumental gain, , in calibrator flux units.
Definition: VariableBackend.C:98
T get_value() const
virtual std::string get_name() const=0
void set_diff_gain(const Estimate< double > &gamma)
Set the differential gain, , in hyperbolic radians.
Definition: VariableBackend.C:108
void set_diff_phase(const Estimate< double > &phi)
Set the differential phase, , in radians.
Definition: VariableBackend.C:118
void set_diff_gain_variation(MEAL::Scalar *)
Set the differential gain variation.
Definition: VariableBackend.C:153
VariableBackendEstimate(MEAL::Complex2 *response=0)
Construct using the supplied response.
Definition: VariableBackendEstimate.C:22
Physical parameterization of the instrumental response.
Definition: VariableBackend.h:35
void update()
Update the transformation with the current estimate, if possible.
Definition: VariableBackendEstimate.C:108
void set_gain(const Estimate< double > &gain)
Set the instrumental gain, , in calibrator flux units.
Definition: SingleAxis.C:110
void set_gain_variation(MEAL::Scalar *)
Set the instrumental gain variation.
Definition: VariableBackend.C:138
IndexedProduct * get_psr_response()
Get the response for pulsar observations.
Definition: VariableBackendEstimate.h:91
void set_cal_backend_only(bool=true)
Set true when the cal signal is coupled after the feed.
Definition: VariableBackendEstimate.C:265

Generated using doxygen 1.8.17