FluxCalibratorPolicy.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2003 - 2018 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Polarimetry/Pulsar/FluxCalibratorPolicy.h
10 
11 #ifndef __Pulsar_FluxCalibratorPolicy_H
12 #define __Pulsar_FluxCalibratorPolicy_H
13 
14 #include "Pulsar/FluxCalibrator.h"
15 #include "MEAL/ScalarMath.h"
16 #include "MEAL/ScalarParameter.h"
17 #include "MEAL/ScalarConstant.h"
18 #include "Types.h"
19 
20 namespace Pulsar {
21 
23  class FluxCalibrator::Policy : public Reference::Able
24  {
25 
26  public:
27 
29  Policy ();
30 
32  virtual Policy* clone () const = 0;
33 
35  virtual void integrate (Signal::Source source, unsigned ireceptor,
36  const Estimate<double>& cal_hi,
37  const Estimate<double>& cal_lo) = 0;
38 
40  void get ( std::vector< Estimate<double> >& S_sys,
41  std::vector< Estimate<double> >& S_cal ) const;
42 
44  void set ( const std::vector< Estimate<double> >& S_sys,
45  const std::vector< Estimate<double> >& S_cal );
46 
48  virtual void set_nreceptor (unsigned);
49 
51  unsigned get_nreceptor () const;
52 
54  void set_S_std (double S_std);
55 
57  double get_S_std () const;
58 
60  void set_valid (bool f = true) { valid = f; }
61 
63  bool get_valid () const { return valid; }
64 
66  bool get_solution_available () const;
67 
69  Estimate<double> get_S_sys () const;
70 
72  Estimate<double> get_S_cal () const;
73 
75  Estimate<double> get_S_sys (unsigned receptor) const;
76 
78  Estimate<double> get_S_cal (unsigned receptor) const;
79 
80  protected:
81 
83  mutable bool valid;
84 
86  double S_std;
87 
89  mutable std::vector< Estimate<double> > S_cal;
90 
92  mutable std::vector< Estimate<double> > S_sys;
93 
95  mutable bool calculated;
96 
98  void calculate () const;
99 
101  virtual void compute (unsigned ireceptor,
103  Estimate<double>& S_sys) = 0;
104 
105  };
106 
109  {
110 
111  public:
112 
114  VariableGain ();
115 
116  VariableGain* clone () const;
117 
118  void integrate (Signal::Source source, unsigned ireceptor,
119  const Estimate<double>& cal_hi,
120  const Estimate<double>& cal_lo);
121 
122  protected:
123 
125  std::vector< MeanEstimate<double> > mean_ratio_on;
126 
128  std::vector< MeanEstimate<double> > mean_ratio_off;
129 
131  void add_ratio_on (unsigned receptor, Estimate<double>& ratio_on);
132 
134  void add_ratio_off (unsigned receptor, Estimate<double>& ratio_on);
135 
137  void compute (unsigned ireceptor,
140 
141  private:
142 
143  /*
144  Use the ScalarMath class to calculate the variances.
145  These are static because they cost a bit during construction.
146  */
147  MEAL::ScalarParameter ratio_on;
148  MEAL::ScalarParameter ratio_off;
149  MEAL::ScalarConstant unity;
150 
151  MEAL::ScalarMath flux_cal;
152  MEAL::ScalarMath flux_sys;
153  };
154 
157  {
158 
159  public:
160 
162  ConstantGain ();
163 
164  ConstantGain* clone () const;
165 
167  void set_nreceptor (unsigned);
168 
169  void integrate (Signal::Source source, unsigned ireceptor,
170  const Estimate<double>& cal_hi,
171  const Estimate<double>& cal_lo);
172 
174  Estimate<double> get_scale (unsigned ireceptor) const;
176  void get_scale ( std::vector< Estimate<double> >& );
177 
179  void set_scale (unsigned ireceptor, const Estimate<double>&);
181  void set_scale ( const std::vector< Estimate<double> >& );
182 
184  Estimate<double> get_gain (unsigned ireceptor) const;
185 
187  Estimate<double> get_gain_ratio (unsigned ireceptor) const;
189  void get_gain_ratio ( std::vector< Estimate<double> >& );
190 
192  void set_gain_ratio (unsigned ireceptor, const Estimate<double>&);
194  void set_gain_ratio ( const std::vector< Estimate<double> >& );
195 
196  Estimate<double> get_scale () const;
197  Estimate<double> get_gain () const;
198 
199  protected:
200 
202  std::vector< MeanEstimate<double> > mean_hi_on;
204  std::vector< MeanEstimate<double> > mean_lo_on;
205 
207  std::vector< MeanEstimate<double> > mean_hi_off;
209  std::vector< MeanEstimate<double> > mean_lo_off;
210 
212  void compute (unsigned ireceptor,
215 
216  void invalidate (unsigned ireceptor);
217 
218  std::vector< Estimate<double> > scale;
219  std::vector< Estimate<double> > gain_ratio;
220 
221  private:
222 
223  /*
224  Use the ScalarMath class to calculate the variances.
225  */
226  MEAL::ScalarParameter ratio_hi;
227  MEAL::ScalarParameter ratio_lo;
228  MEAL::ScalarConstant unity;
229 
230  MEAL::ScalarMath flux_cal;
231  MEAL::ScalarMath flux_sys;
232 
233  };
234 }
235 
236 #endif
std::vector< MeanEstimate< double > > mean_ratio_on
Ratio of cal hi/lo on source in each receptor.
Definition: FluxCalibratorPolicy.h:130
std::vector< MeanEstimate< double > > mean_lo_off
Mean of off-source observations with noise diode off.
Definition: FluxCalibratorPolicy.h:214
double S_std
Flux density of the standard candle.
Definition: FluxCalibratorPolicy.h:96
void integrate(Signal::Source source, unsigned ireceptor, const Estimate< double > &cal_hi, const Estimate< double > &cal_lo)
Integrate an observation of the reference source.
Definition: FluxCalibratorConstantGain.C:29
Estimate< double > get_S_cal() const
Return the total calibrator flux density.
Definition: FluxCalibratorPolicy.C:97
Policy()
Default constructor.
Definition: FluxCalibratorPolicy.C:16
bool valid
Flag set when data are valid.
Definition: FluxCalibratorPolicy.h:93
void set_nreceptor(unsigned)
Set the number of receptors.
Definition: FluxCalibratorConstantGain.C:56
double get_S_std() const
Get the flux density of the standard candle.
Definition: FluxCalibratorPolicy.C:131
void compute(unsigned ireceptor, Estimate< double > &S_cal, Estimate< double > &S_sys)
Compute the fluxes of the reference source and system.
Definition: FluxCalibratorVariableGain.C:66
std::vector< Estimate< double > > S_sys
System equivalent flux density in each receptor.
Definition: FluxCalibratorPolicy.h:102
void compute(unsigned ireceptor, Estimate< double > &S_cal, Estimate< double > &S_sys)
Compute the fluxes of the reference source and system.
Definition: FluxCalibratorConstantGain.C:77
void integrate(Signal::Source source, unsigned ireceptor, const Estimate< double > &cal_hi, const Estimate< double > &cal_lo)
Integrate an observation of the reference source.
Definition: FluxCalibratorVariableGain.C:30
virtual void set_nreceptor(unsigned)
Set the number of receptors.
Definition: FluxCalibratorPolicy.C:47
void set_valid(bool f=true)
Set the data validity flag.
Definition: FluxCalibratorPolicy.h:70
std::vector< MeanEstimate< double > > mean_ratio_off
Ratio of cal hi/lo off source in each receptor.
Definition: FluxCalibratorPolicy.h:133
Estimate< double > get_S_sys() const
Return the total system equivalent flux density.
Definition: FluxCalibratorPolicy.C:88
void set_S_std(double S_std)
Set the flux density of the standard candle.
Definition: FluxCalibratorPolicy.C:124
virtual void integrate(Signal::Source source, unsigned ireceptor, const Estimate< double > &cal_hi, const Estimate< double > &cal_lo)=0
Integrate an observation of the reference source.
virtual Policy * clone() const =0
Return a new default constructed copy of self.
ConstantGain * clone() const
Return a new default constructed copy of self.
Definition: FluxCalibratorConstantGain.C:23
Used when gain varies between FluxCal-On and Off observations.
Definition: FluxCalibratorPolicy.h:113
unsigned get_nreceptor() const
Get the number of receptors.
Definition: FluxCalibratorPolicy.C:54
void add_ratio_on(unsigned receptor, Estimate< double > &ratio_on)
Add to the mean hi/lo ratio on source for the specified receptor.
Definition: FluxCalibratorVariableGain.C:46
unsigned get_nreceptor() const
Get the number of receptors in the calibrator.
Definition: FluxCalibrator.C:765
std::vector< MeanEstimate< double > > mean_hi_on
Mean of on-source observations with noise diode emitting.
Definition: FluxCalibratorPolicy.h:207
std::vector< Estimate< double > > S_cal
Calibrator flux density in each receptor.
Definition: FluxCalibratorPolicy.h:99
void set_scale(unsigned ireceptor, const Estimate< double > &)
Set the scale for the specified receptor.
std::vector< MeanEstimate< double > > mean_lo_on
Mean of on-source observations with noise diode off.
Definition: FluxCalibratorPolicy.h:209
VariableGain()
Default constructor.
Definition: FluxCalibratorVariableGain.C:18
void set_gain_ratio(unsigned ireceptor, const Estimate< double > &)
Set the gain ratio for the specified receptor.
void calculate() const
Calulate S_cal and S_sys for both receptors.
Definition: FluxCalibratorPolicy.C:136
std::vector< MeanEstimate< double > > mean_hi_off
Mean of off-source observations with noise diode emitting.
Definition: FluxCalibratorPolicy.h:212
Calibrates flux using standard candles and artificial sources.
Definition: FluxCalibrator.h:29
void add_ratio_off(unsigned receptor, Estimate< double > &ratio_on)
Add to the mean hi/lo ratio off source for the specified receptor.
Definition: FluxCalibratorVariableGain.C:57
const std::string get_message() const
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void set(const std::vector< Estimate< double > > &S_sys, const std::vector< Estimate< double > > &S_cal)
Set the flux densities for each receptor.
Definition: FluxCalibratorPolicy.C:22
Used when gain remains constant between FluxCal-On and Off observations.
Definition: FluxCalibratorPolicy.h:161
Flux calibration data for each receptor.
Definition: FluxCalibratorPolicy.h:28
void get(std::vector< Estimate< double > > &S_sys, std::vector< Estimate< double > > &S_cal) const
Get the flux densities for each receptor.
Definition: FluxCalibratorPolicy.C:31
bool get_valid() const
Get the data validity flag.
Definition: FluxCalibratorPolicy.h:73
Estimate< double > get_gain_ratio(unsigned ireceptor) const
Get the gain ratio for the specified receptor.
bool calculated
Flag set when S_cal and S_sys have been computed.
Definition: FluxCalibratorPolicy.h:105
bool get_solution_available() const
Return true when a solution is available.
Definition: FluxCalibratorPolicy.C:59
VariableGain * clone() const
Return a new default constructed copy of self.
Definition: FluxCalibratorVariableGain.C:25
ConstantGain()
Default constructor.
Definition: FluxCalibratorConstantGain.C:16
virtual void compute(unsigned ireceptor, Estimate< double > &S_cal, Estimate< double > &S_sys)=0
Compute the fluxes of the reference source and system.

Generated using doxygen 1.8.17