HOPS
HOPS class reference
MHO_AdhocPhaseCorrection.hh
Go to the documentation of this file.
1 #ifndef MHO_AdhocPhaseCorrection_HH__
2 #define MHO_AdhocPhaseCorrection_HH__
3 
4 #include <complex>
5 #include <string>
6 #include <vector>
7 
8 #include "MHO_Clock.hh"
9 #include "MHO_Constants.hh"
10 #include "MHO_Message.hh"
11 
13 #include "MHO_TableContainer.hh"
14 #include "MHO_UnaryOperator.hh"
15 
16 namespace hops
17 {
18 
60 enum class AdhocPhaseMode
61 {
62  NONE = 0,
63  SINEWAVE = 1,
64  POLYNOMIAL = 2,
65  PHYLE = 3
66 };
67 
71 class MHO_AdhocPhaseCorrection: public MHO_UnaryOperator< visibility_type >
72 {
73  public:
75  virtual ~MHO_AdhocPhaseCorrection();
76 
77  // ---------------------------------------------------------------
78  // Mode
79  // ---------------------------------------------------------------
80 
84  void SetMode(AdhocPhaseMode mode) { fMode = mode; }
85 
89  AdhocPhaseMode GetMode() const { return fMode; }
90 
91  // ---------------------------------------------------------------
92  // SINEWAVE and POLYNOMIAL shared parameter
93  // ---------------------------------------------------------------
94 
102  void SetTRef(double tref_sec_from_scan_start) { fTRef = tref_sec_from_scan_start; }
103 
107  double GetTRef() const { return fTRef; }
108 
109  // ---------------------------------------------------------------
110  // SINEWAVE parameters
111  // ---------------------------------------------------------------
112 
116  void SetPeriod(double period_sec) { fPeriod = period_sec; }
117 
121  double GetPeriod() const { return fPeriod; }
122 
126  void SetAmplitude(double amp_rad) { fAmplitude = amp_rad; }
127 
131  double GetAmplitude() const { return fAmplitude; }
132 
133  // ---------------------------------------------------------------
134  // POLYNOMIAL parameters
135  // ---------------------------------------------------------------
136 
145  void SetPolynomialCoeffs(const std::vector< double >& coeffs);
146 
150  const double* GetPolynomialCoeffs() const { return fPolyCoeffs; }
151 
152  // ---------------------------------------------------------------
153  // PHYLE parameters
154  // ---------------------------------------------------------------
155 
163  void SetRefAdhocFile(const std::string& filename, const std::string& chans);
164 
168  void GetRefAdhocFile(std::string& filename, std::string& chans) const;
169 
177  void SetRemAdhocFile(const std::string& filename, const std::string& chans);
178 
182  void GetRemAdhocFile(std::string& filename, std::string& chans) const;
183 
184  protected:
185  virtual bool InitializeInPlace(visibility_type* in) override;
186  virtual bool InitializeOutOfPlace(const visibility_type* in, visibility_type* out) override;
187  virtual bool ExecuteInPlace(visibility_type* in) override;
188 
189  private:
195  bool LoadAdhocFile(std::size_t stn_idx);
196 
205  double ComputeZeta(const std::string& chan_label, double ap_center_sec) const;
206 
215  double InterpolateFilePhase(std::size_t stn_idx, char fcode, double t_fpday) const;
216 
217  // ---------------------------------------------------------------
218  // Configuration
219  // ---------------------------------------------------------------
220  AdhocPhaseMode fMode;
221 
222  // SINEWAVE / POLYNOMIAL shared reference time (seconds from scan start)
223  double fTRef;
224 
225  // SINEWAVE
226  double fPeriod; // seconds
227  double fAmplitude; // radians
228 
229  // POLYNOMIAL (6 coefficients, units: rad / s^n)
230  double fPolyCoeffs[6];
231 
232  // PHYLE: filenames and channel-code strings for [ref=0, rem=1]
233  std::string fAhFile[2];
234  std::string fAhFileChans[2];
235 
236  // Parsed PHYLE data. fFileData[stn] is a row-major flat vector:
237  // row k occupies indices [k*(nchan+1) .. (k+1)*(nchan+1))
238  // column 0 is the time (fpday); columns 1..nchan are phases (degrees).
239  std::vector< double > fFileData[2];
240  std::size_t fNFileRows[2]; // number of data rows read per station
241  std::size_t fNFileCols[2]; // number of columns per row (= nchan + 1)
242 
243  // ---------------------------------------------------------------
244  // Scan timing (filled during Initialize)
245  // ---------------------------------------------------------------
246  double fScanStartFpDay; // scan start as fractional days since BOY
247  double fScanStartSecPastHour; //scan start in seconds past the most recent hour
248  int fScanYear; // year of scan start
249  double fAccPeriod; // accumulation period duration in seconds
250 
251  // ---------------------------------------------------------------
252  // Constants / key strings
253  // ---------------------------------------------------------------
254  std::complex< double > fImagUnit;
255  std::string fChannelLabelKey; // "channel_label"
256  std::string fStartKey; // "start"
257 };
258 
259 } // namespace hops
260 
261 #endif
Class MHO_AdhocPhaseCorrection.
Definition: MHO_AdhocPhaseCorrection.hh:72
MHO_AdhocPhaseCorrection()
Definition: MHO_AdhocPhaseCorrection.cc:10
void SetPolynomialCoeffs(const std::vector< double > &coeffs)
Set polynomial coefficients for POLYNOMIAL mode.
Definition: MHO_AdhocPhaseCorrection.cc:47
void SetRefAdhocFile(const std::string &filename, const std::string &chans)
Set the adhoc phase file for the reference station.
Definition: MHO_AdhocPhaseCorrection.cc:66
virtual bool InitializeOutOfPlace(const visibility_type *in, visibility_type *out) override
Definition: MHO_AdhocPhaseCorrection.cc:162
void SetPeriod(double period_sec)
Set the sinewave period in seconds.
Definition: MHO_AdhocPhaseCorrection.hh:116
void SetTRef(double tref_sec_from_scan_start)
Set the reference time used in SINEWAVE and POLYNOMIAL modes.
Definition: MHO_AdhocPhaseCorrection.hh:102
AdhocPhaseMode GetMode() const
Get the currently configured correction mode.
Definition: MHO_AdhocPhaseCorrection.hh:89
void SetRemAdhocFile(const std::string &filename, const std::string &chans)
Set the adhoc phase file for the remote station.
Definition: MHO_AdhocPhaseCorrection.cc:78
double GetTRef() const
Get the reference time in seconds from scan start.
Definition: MHO_AdhocPhaseCorrection.hh:107
void GetRefAdhocFile(std::string &filename, std::string &chans) const
Get the adhoc phase file info for the reference station.
Definition: MHO_AdhocPhaseCorrection.cc:72
void SetMode(AdhocPhaseMode mode)
Set the correction mode (NONE, SINEWAVE, POLYNOMIAL, or PHYLE).
Definition: MHO_AdhocPhaseCorrection.hh:84
const double * GetPolynomialCoeffs() const
Get the polynomial coefficients (always 6 entries).
Definition: MHO_AdhocPhaseCorrection.hh:150
double GetPeriod() const
Get the sinewave period in seconds.
Definition: MHO_AdhocPhaseCorrection.hh:121
void GetRemAdhocFile(std::string &filename, std::string &chans) const
Get the adhoc phase file info for the remote station.
Definition: MHO_AdhocPhaseCorrection.cc:84
virtual bool ExecuteInPlace(visibility_type *in) override
Definition: MHO_AdhocPhaseCorrection.cc:265
double GetAmplitude() const
Get the sinewave amplitude in radians.
Definition: MHO_AdhocPhaseCorrection.hh:131
void SetAmplitude(double amp_rad)
Set the sinewave amplitude in radians.
Definition: MHO_AdhocPhaseCorrection.hh:126
virtual bool InitializeInPlace(visibility_type *in) override
Definition: MHO_AdhocPhaseCorrection.cc:90
virtual ~MHO_AdhocPhaseCorrection()
Definition: MHO_AdhocPhaseCorrection.cc:40
Class MHO_UnaryOperator.
Definition: MHO_UnaryOperator.hh:24
Definition: MHO_AdhocFlagging.hh:18
AdhocPhaseMode
Ad hoc phase correction mode, mirrors legacy SINEWAVE/POLYNOMIAL/PHYLE constants.
Definition: MHO_AdhocPhaseCorrection.hh:61