HOPS
HOPS class reference
MHO_DiFXPCalProcessor.hh
Go to the documentation of this file.
1 #ifndef MHO_DiFXPCalProcessor_HH__
2 #define MHO_DiFXPCalProcessor_HH__
3 
4 #include <complex>
5 #include <string>
6 #include <utility>
7 #include <vector>
8 
10 #include "MHO_DiFXTimeUtilities.hh"
11 #include "MHO_Tokenizer.hh"
12 
13 namespace hops
14 {
15 
28 {
29  public:
31  virtual ~MHO_DiFXPCalProcessor();
32 
38  void SetFilename(std::string filename);
39 
45  void SetAccumulationPeriod(double ap_sec) { fAPLength = ap_sec; }
46 
52  void SetScanStartMJD(double mjd)
53  {
54  fScanStartMJD = mjd;
55  fHaveScanStart = true;
56  }
57 
63  std::string GetStationCode() const { return fStationCode; }
64 
68  void ReadPCalFile();
69 
73  void Organize();
74 
80  multitone_pcal_type* GetPCalData() { return &fPCal; }
81 
82  private:
88  bool IsComment();
89 
93  void TokenizeLine();
94 
98  void ProcessTokens();
99 
107  bool AssignAPIndices(int& first_ap, int& last_ap);
108 
112  void BuildToneAxis();
113 
117  std::size_t FindToneIndex(double tone_freq) const;
118 
124  void FillPCalTable(int first_ap);
125 
129  void FillMissingPhasors();
130 
134  std::size_t ValidIndex(std::size_t pol, std::size_t ap, std::size_t tone) const
135  {
136  return (pol * fPCal.GetDimension(MTPCAL_TIME_AXIS) + ap) * fToneFreqs.size() + tone;
137  }
138 
139  std::string fFilename;
140  std::string fLine;
141  MHO_Tokenizer fTokenizer;
142  std::vector< std::string > fTokens;
143  double fAPLength;
144  double fScanStartMJD;
145  bool fHaveScanStart;
146  double fGridStartMJD; //start of AP 0 of the pcal AP grid
147  bool fValid;
148 
149  std::string fType;
150  std::string fMJD_day;
151  std::string fMJD_frac;
152  std::string fStationCode;
153 
154  //TODO this constant isn't used directly for conversion
155  //(just a tolerance check), but we should put this somewhere sensible
156  double fSecondsPerDay;
157  double fTolerance;
158 
159  //single pcal tone
160  struct pcal_phasor
161  {
162  double tone_freq;
164  };
165 
166  //container for pcal data from a single AP
167  struct pcal_period
168  {
169  std::string station;
170  double mjd;
171  double mjd_period;
172  int ap;
173  std::map< std::string, std::vector< pcal_phasor > > pc_phasors;
174  };
175 
176  //pcal data in various forms on the way to getting it organized
177  std::vector< pcal_period > fPCalData;
178  std::set< std::string > fPolSet;
179  std::vector< double > fToneFreqs;
180  std::vector< char > fPresent; //flags (pol, ap, tone) table entries present in the pcal records
181 
182  //fully organized pcal data
183  multitone_pcal_type fPCal;
184 };
185 
186 } // namespace hops
187 
188 #endif
#define MTPCAL_TIME_AXIS
Definition: MHO_StationContainers.hh:22
Class MHO_DiFXPCalProcessor.
Definition: MHO_DiFXPCalProcessor.hh:28
multitone_pcal_type * GetPCalData()
Getter for (organized) pcal data.
Definition: MHO_DiFXPCalProcessor.hh:80
MHO_DiFXPCalProcessor()
Definition: MHO_DiFXPCalProcessor.cc:15
void Organize()
Organizes p-cal data by merging tone/phasor data from the same time period and stores them in a table...
Definition: MHO_DiFXPCalProcessor.cc:159
void SetScanStartMJD(double mjd)
Setter for the scan start time, if not set, the first pcal record is assumed to be AP 0.
Definition: MHO_DiFXPCalProcessor.hh:52
void SetFilename(std::string filename)
Setter for (PCAL) filename.
Definition: MHO_DiFXPCalProcessor.cc:31
std::string GetStationCode() const
Getter for station code.
Definition: MHO_DiFXPCalProcessor.hh:63
void SetAccumulationPeriod(double ap_sec)
Setter for pcal accumulation period.
Definition: MHO_DiFXPCalProcessor.hh:45
void ReadPCalFile()
Reads and processes a PCal file.
Definition: MHO_DiFXPCalProcessor.cc:62
virtual ~MHO_DiFXPCalProcessor()
Definition: MHO_DiFXPCalProcessor.cc:28
std::size_t GetDimension(std::size_t idx) const
Getter for dimension.
Definition: MHO_NDArrayWrapper.hh:154
Definition: MHO_AdhocFlagging.hh:18
MHO_TableContainer< pcal_phasor_type, multitone_pcal_axis_type > multitone_pcal_type
Definition: MHO_StationContainers.hh:30
std::complex< PCFP_TYPE > pcal_phasor_type
Definition: MHO_ElementTypes.hh:32
Definition: type_212.h:10