HOPS
HOPS class reference
MHO_ComputePlotData.hh
Go to the documentation of this file.
1 #ifndef MHO_ComputePlotData_HH__
2 #define MHO_ComputePlotData_HH__
3 
5 #include "MHO_TableContainer.hh"
6 
7 #include "MHO_BinaryOperator.hh"
9 #include "MHO_CyclicRotator.hh"
10 #include "MHO_FringeRotation.hh"
12 #include "MHO_MathUtilities.hh"
13 #include "MHO_NaNMasker.hh"
14 #include "MHO_SubSample.hh"
15 
16 #include "MHO_ContainerStore.hh"
17 #include "MHO_OperatorToolbox.hh"
18 #include "MHO_ParameterStore.hh"
19 
20 #ifdef HOPS_USE_FFTW3
21  #include "MHO_FFTWTypes.hh"
23 #else
25 #endif
26 
28 
29 #include "MHO_JSONHeaderWrapper.hh"
30 
31 namespace hops
32 {
33 
46 {
47  public:
49  virtual ~MHO_ComputePlotData(){};
50 
55 
60 
66  void SetMBDAnchor(std::string flag) { fMBDAnchor = flag; }
67 
73  void SetOperatorToolbox(MHO_OperatorToolbox* toolbox) { fToolbox = toolbox; }
74 
81 
87  void SetParameterStore(MHO_ParameterStore* pStore) { fParamStore = pStore; }
88 
94  void SetVexInfo(const mho_json& vex_info) { fVexInfo = vex_info; }
95 
99  void Initialize();
100 
106  void DumpInfoToJSON(mho_json& plot_dict);
107 
117  void DumpSpectralLineInfoToJSON(mho_json& plot_dict);
118 
119  //protected:
120 
121  TODO_FIXME_MSG("TODO FIXME, temporary kludge to pass sbd amp data for test")
152 
153  // visibility_type* calc_corrected_vis();
157  void correct_vis();
158 
164  double calc_phase();
165 
178  void calc_freqrms(phasor_type& phasors, double coh_avg_phase, double fringe_amp, double total_summed_weights,
179  double snr, double& freqrms_phase, double& freqrms_amp, double& inc_avg_amp_freq);
180 
195  void calc_timerms(phasor_type& phasors, std::size_t nseg, std::size_t apseg, double coh_avg_phase, double fringe_amp,
196  double total_summed_weights, double snr, double& timerms_phase, double& timerms_amp,
197  double& inc_avg_amp);
198 
199  //exports the multitone pcal data (if it was applied)
200  //to the plot dictionary
201  void dump_multitone_pcmodel(mho_json& plot_dict,
202  int station_flag, //0 = reference station, 1 = remote station,
203  std::string pol, //single char string
204  std::string key_suffix = "" //appended to PLOT_INFO keys, e.g. "2" for second pol
205  );
206 
207  //exports the manual pcal data (pc_phases)
208  //to the plot dictionary
209  void dump_manual_pcmodel(mho_json& plot_dict,
210  int station_flag, //0 = reference station, 1 = remote station,
211  std::string pol, //single char string
212  std::string key_suffix = "" //appended to PLOT_INFO keys, e.g. "2" for second pol
213  );
214 
218  std::string calc_quality_code(); //quality only, not error
219 
225 
234  void precompute_vr_tables();
235 
244  void calc_sbd_and_xpower_spec(xpower_amp_type& sbd_amp, xpower_type& cp_spectrum);
245 
255  xpower_amp_type calc_dr_segs_phase(double& coh_avg_phase, phasor_type& phasor_segs);
256 
260  std::string calc_error_code(const mho_json& plot_dict);
261 
270  void smooth_dr_spectrum_tcohere(std::size_t drsp_size, double ap_delta);
271 
272  double fRefFreq;
274  double fMBDelay;
275  double fDelayRate;
276  double fFringeRate;
277  double fSBDelay;
278  double fAmp;
279 
280  std::size_t fSBDMaxBin;
281 
282  bool fValid;
286 
289 
292 
294 
299 
302 
303  //class which implements vrot
305 
306  //flag for mbd anchor
307  std::string fMBDAnchor;
308 
309  //space for xpower spectrum and sbdbox
310  std::vector< double > fSBDBox;
311  std::vector< int > fNUSBAP;
312  std::vector< int > fNLSBAP;
313 
314  //constants
315  std::complex< double > fImagUnit;
316 
317  // Pre-computed per-channel metadata (populated by precompute_chan_metadata)
318  std::size_t fNChan;
319  std::size_t fNAP;
320  std::vector< double > fChanFreq; // sky frequency per channel
321  std::vector< int > fChanSideband; // sideband sign per channel: +1=USB, 0=DSB, -1=LSB
322  std::vector< double > fChanBandwidth; // bandwidth per channel
323 
324  // Pre-computed vrot tables indexed as [ch * fNAP + ap] (populated by precompute_vr_tables)
325  std::vector< std::complex< double > > fVRTable; // default SBD params + fMBDelay
326  std::vector< std::complex< double > > fVRMBD0Table; // default SBD params + MBD=0
327  std::vector< std::complex< double > > fVRPhaseTable; // proper SBD params + fMBDelay
328 
329  //lsb/usb validity segments
330  std::vector< std::vector< double > > seg_frac_usb;
331  std::vector< std::vector< double > > seg_frac_lsb;
332 };
333 
334 } // namespace hops
335 
336 #endif
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
#define TODO_FIXME_MSG(x)
Definition: MHO_Message.hh:35
Class MHO_ComputePlotData.
Definition: MHO_ComputePlotData.hh:46
void calc_sbd_and_xpower_spec(xpower_amp_type &sbd_amp, xpower_type &cp_spectrum)
Merged computation of SBD amplitude spectrum and cross-power spectrum. Single ch->ap->bin pass replac...
Definition: MHO_ComputePlotData.cc:823
visibility_type * fSBDArray
Definition: MHO_ComputePlotData.hh:284
xpower_amp_type fDRAmpWorkspace
Definition: MHO_ComputePlotData.hh:288
double calc_phase()
Calculates fringe phase using weighted sum and fitted (delay, delay-rate) rotation.
Definition: MHO_ComputePlotData.cc:537
double fRefFreq
Definition: MHO_ComputePlotData.hh:272
std::string fMBDAnchor
Definition: MHO_ComputePlotData.hh:307
xpower_amp_type calc_dr_segs_phase(double &coh_avg_phase, phasor_type &phasor_segs)
Merged computation of delay-rate spectrum, phasor segments, and fringe phase. Single ch->ap pass over...
Definition: MHO_ComputePlotData.cc:1048
std::vector< std::complex< double > > fVRTable
Definition: MHO_ComputePlotData.hh:325
std::string calc_quality_code()
calcuates the fringe quality code
Definition: MHO_ComputePlotData.cc:1818
MHO_OperatorToolbox * fToolbox
Definition: MHO_ComputePlotData.hh:297
void smooth_dr_spectrum_tcohere(std::size_t drsp_size, double ap_delta)
Applies the t_cohere box-car smoothing to fDRAmpWorkspace in-place, replicating the make_plotdata....
Definition: MHO_ComputePlotData.cc:1194
void DisableOptimizeClosure()
Disables optimize closure by setting underlying MHO_FringeRotation (fRot) optimizeClosure to false.
Definition: MHO_ComputePlotData.hh:59
MHO_CyclicRotator< xpower_type > fCyclicRotator
Definition: MHO_ComputePlotData.hh:301
xpower_type fFringe
Definition: MHO_ComputePlotData.hh:293
MHO_ContainerStore * fContainerStore
Definition: MHO_ComputePlotData.hh:295
std::vector< std::vector< double > > seg_frac_lsb
Definition: MHO_ComputePlotData.hh:331
std::vector< std::complex< double > > fVRPhaseTable
Definition: MHO_ComputePlotData.hh:327
double fMBDelay
Definition: MHO_ComputePlotData.hh:274
std::vector< std::vector< double > > seg_frac_usb
Definition: MHO_ComputePlotData.hh:330
std::vector< int > fNUSBAP
Definition: MHO_ComputePlotData.hh:311
virtual ~MHO_ComputePlotData()
Definition: MHO_ComputePlotData.hh:49
void precompute_vr_tables()
Pre-computes vrot lookup tables indexed as [ch * fNAP + ap]. Three tables are built to match the fRot...
Definition: MHO_ComputePlotData.cc:124
void dump_multitone_pcmodel(mho_json &plot_dict, int station_flag, std::string pol, std::string key_suffix="")
Definition: MHO_ComputePlotData.cc:2045
xpower_amp_type calc_dr()
Calculates delay-rate (dr) function (amplitude vs delay rate)
Definition: MHO_ComputePlotData.cc:462
std::size_t fNChan
Definition: MHO_ComputePlotData.hh:318
std::size_t fSBDMaxBin
Definition: MHO_ComputePlotData.hh:280
double fFringeRate
Definition: MHO_ComputePlotData.hh:276
void calc_freqrms(phasor_type &phasors, double coh_avg_phase, double fringe_amp, double total_summed_weights, double snr, double &freqrms_phase, double &freqrms_amp, double &inc_avg_amp_freq)
Calculates frequency root mean square (phase and amplitude) for given phasors.
Definition: MHO_ComputePlotData.cc:1628
std::vector< int > fChanSideband
Definition: MHO_ComputePlotData.hh:321
double fSBDelay
Definition: MHO_ComputePlotData.hh:277
void SetVexInfo(const mho_json &vex_info)
Setter for vex info.
Definition: MHO_ComputePlotData.hh:94
void precompute_chan_metadata()
Pre-computes per-channel metadata (freq, sideband sign, bandwidth) into flat arrays,...
Definition: MHO_ComputePlotData.cc:78
xpower_type fMBDWorkspace
Definition: MHO_ComputePlotData.hh:290
mho_json fVexInfo
Definition: MHO_ComputePlotData.hh:298
MHO_FringeRotation fRot
Definition: MHO_ComputePlotData.hh:304
std::vector< double > fChanFreq
Definition: MHO_ComputePlotData.hh:320
xpower_amp_type calc_mbd()
Calculates Multi-Band Delay (MBD) function (amplitude vs. mbd)
Definition: MHO_ComputePlotData.cc:172
std::vector< int > fNLSBAP
Definition: MHO_ComputePlotData.hh:312
void DumpInfoToJSON(mho_json &plot_dict)
Dumps fringe plot data into a JSON object for visualization/consumption by plotting routine.
Definition: MHO_ComputePlotData.cc:1226
weight_type * fWeights
Definition: MHO_ComputePlotData.hh:285
void SetOperatorToolbox(MHO_OperatorToolbox *toolbox)
Setter for operator toolbox.
Definition: MHO_ComputePlotData.hh:73
void SetContainerStore(MHO_ContainerStore *cStore)
Setter for container store.
Definition: MHO_ComputePlotData.hh:80
double fDelayRate
Definition: MHO_ComputePlotData.hh:275
std::complex< double > fImagUnit
Definition: MHO_ComputePlotData.hh:315
double fAmp
Definition: MHO_ComputePlotData.hh:278
void DumpSpectralLineInfoToJSON(mho_json &plot_dict)
Dumps spectral-line fringe plot data into a JSON object. Uses the 'spec_dr' container (stored by MHO_...
Definition: MHO_ComputePlotData.cc:2260
std::vector< double > fSBDBox
Definition: MHO_ComputePlotData.hh:310
void correct_vis()
Corrects visibility data by applying fringe solution.
Definition: MHO_ComputePlotData.cc:378
xpower_type fDRWorkspace
Definition: MHO_ComputePlotData.hh:287
MHO_ParameterStore * fParamStore
Definition: MHO_ComputePlotData.hh:296
void SetMBDAnchor(std::string flag)
Setter for mbd anchor (either: 'sbd' or 'model')
Definition: MHO_ComputePlotData.hh:66
xpower_amp_type fMBDAmpWorkspace
Definition: MHO_ComputePlotData.hh:291
std::vector< std::complex< double > > fVRMBD0Table
Definition: MHO_ComputePlotData.hh:326
void calc_timerms(phasor_type &phasors, std::size_t nseg, std::size_t apseg, double coh_avg_phase, double fringe_amp, double total_summed_weights, double snr, double &timerms_phase, double &timerms_amp, double &inc_avg_amp)
Calculates time-domain measurements (phase, amplitude, average) from phasors data.
Definition: MHO_ComputePlotData.cc:1698
std::string calc_error_code(const mho_json &plot_dict)
calcuates the fringe error code
Definition: MHO_ComputePlotData.cc:1875
bool fValid
Definition: MHO_ComputePlotData.hh:282
xpower_type calc_xpower_spec()
Calculates and returns the cross-power spectrum for a given SBD array.
Definition: MHO_ComputePlotData.cc:589
xpower_amp_type calc_sbd()
Calculates Single Band Delay (SBD) function (amplitude vs. sbd)
Definition: MHO_ComputePlotData.cc:265
void dump_manual_pcmodel(mho_json &plot_dict, int station_flag, std::string pol, std::string key_suffix="")
Definition: MHO_ComputePlotData.cc:2218
phasor_type calc_segs()
Calculates and returns time-averaged phasor segments for each channel.
Definition: MHO_ComputePlotData.cc:314
void EnableOptimizeClosure()
Sets optimize closure to true in underlying MHO_FringeRotation (fRot) object.
Definition: MHO_ComputePlotData.hh:54
std::vector< double > fChanBandwidth
Definition: MHO_ComputePlotData.hh:322
void Initialize()
Initializes member variables by retrieving values from parameter and container stores.
Definition: MHO_ComputePlotData.cc:43
std::size_t fNAP
Definition: MHO_ComputePlotData.hh:319
MHO_ComputePlotData()
Definition: MHO_ComputePlotData.cc:28
double fTotalSummedWeights
Definition: MHO_ComputePlotData.hh:273
visibility_type * fVisibilities
Definition: MHO_ComputePlotData.hh:283
MHO_MultidimensionalFastFourierTransform< xpower_type > fFFTEngine
Definition: MHO_ComputePlotData.hh:300
void SetParameterStore(MHO_ParameterStore *pStore)
Setter for parameter store.
Definition: MHO_ComputePlotData.hh:87
Class MHO_ContainerStore.
Definition: MHO_ContainerStore.hh:32
Class MHO_CyclicRotator.
Definition: MHO_CyclicRotator.hh:29
Class MHO_FringeRotation.
Definition: MHO_FringeRotation.hh:22
void SetOptimizeClosureTrue()
Setter for optimize closure true.
Definition: MHO_FringeRotation.hh:78
void SetOptimizeClosureFalse()
Setter for optimize closure false.
Definition: MHO_FringeRotation.hh:83
Class MHO_MultidimensionalFastFourierTransform.
Definition: MHO_MultidimensionalFastFourierTransform.hh:35
Class MHO_OperatorToolbox.
Definition: MHO_OperatorToolbox.hh:28
Class MHO_ParameterStore.
Definition: MHO_ParameterStore.hh:52
Definition: MHO_AdhocFlagging.hh:18