HOPS
HOPS class reference
MHO_MK4StationInterfaceReversed.hh
Go to the documentation of this file.
1 #ifndef MHO_MK4StationInterfaceReversed_HH__
2 #define MHO_MK4StationInterfaceReversed_HH__
3 
4 #include <cstdlib>
5 #include <cstring>
6 
7 #include <set>
8 #include <string>
9 #include <vector>
10 
12 #include "MHO_Message.hh"
13 
14 #ifndef HOPS3_USE_CXX
15 extern "C"
16 {
17 #endif
18 
19 //forward declare this struct
20 struct mk4_sdata;
21 
22 #ifndef HOPS3_USE_CXX
23 }
24 #endif
25 
26 namespace hops
27 {
28 
39 {
40  public:
43 
44  //we don't strictly need the vex file data unless we are doing a direct conversion from difx
45  //since in order to fill out the type_309s, we need to know the station channel/freq set-up
46  void SetVexData(const mho_json& vex_data){fVexData = vex_data;};
47 
48  void SetOutputDirectory(const std::string& output_dir);
49  void SetStationCoordData(station_coord_type* coord_data) { fStationCoordData = coord_data; }
50  void SetPCalData(multitone_pcal_type* pcal_data) { fPCalData = pcal_data; }
51  void SetOutputFile(const std::string& output_file) { fOutputFile = output_file; }
52 
54 
55  int WriteStationFile();
56 
57  struct mk4_sdata* GetStationStructure() { return fGeneratedStation; }
58 
59  void FreeAllocated();
60 
61  private:
62 
63  void InitializeStationStructure();
64  void GenerateType000();
65  std::string ConstructType000FileName();
66 
67  void GenerateType300();
68  void GenerateType301Records();
69  void GenerateType303Records();
70  void GenerateType309Records();
71  void setstr(const std::string& str, char* char_array, std::size_t max_size);
72 
73  double ComputeType309Rot(double ap_offset, std::string start_time, double start_time_mjd);
74  double ComputeType309RotFallback(double ap_offset);
75 
85  void ConvertPhasorToCounts(const std::complex<double>& phasor, double acc_period,
86  double sample_period, uint32_t& real_count, uint32_t& imag_count);
87 
91  void ExtractPCalChannelInfo();
92  void ExtractPCalChannelInfoFromVex();
93  double DeterminePCalToneSpacing();
94 
95  double FactorConvertToMHz(std::string units);
96  void DetermineChannelToneIndexes(double lower_freq, double upper_freq, std::size_t& start_idx, std::size_t& ntones);
97 
98  std::string GetStationMode();
99 
100  station_coord_type* fStationCoordData;
101  multitone_pcal_type* fPCalData;
102  struct mk4_sdata* fGeneratedStation;
103  std::string fOutputDir;
104  std::string fOutputFile;
105 
106  //copy of vex data
107  mho_json fVexData;
108  std::string fStationCode;
109  std::string fMode;
110  std::string fFreqSetupName;
111 
112  // Container dimensions
113  std::size_t fNCoord;
114  std::size_t fNIntervals;
115  std::size_t fNCoeffs;
116  std::size_t fNPols;
117  std::size_t fNAPs;
118  std::size_t fNTones;
119 
120  // PCal channel information
121  struct PCalChannelInfo
122  {
123  std::string channel_name;
124  std::string polarization;
125  std::string net_sideband;
126  int tone_start;
127  int ntones;
128  int accumulator_start_index;
129  double sky_freq;
130  double bandwidth;
131  double sample_period;
132  };
133 
134  //the ordering operator for channel info, sort by frequency and pol
135  class chan_predicate
136  {
137  public:
138  chan_predicate(){};
139  virtual ~chan_predicate(){};
140 
141  virtual bool operator()(const PCalChannelInfo& a, const PCalChannelInfo& b)
142  {
143  if(a.sky_freq == b.sky_freq){return a.polarization < b.polarization;}
144  return a.sky_freq < b.sky_freq;
145  }
146  };
147 
148 
149 
150 
151  std::vector<PCalChannelInfo> fPCalChannelList;
152 
153  std::vector< void* > fAllocated;
154 };
155 
156 } // namespace hops
157 
158 #endif
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
MHO_MK4StationInterfaceReversed - Converts HOPS4 station containers back to mk4_sdata format....
Definition: MHO_MK4StationInterfaceReversed.hh:39
MHO_MK4StationInterfaceReversed()
Definition: MHO_MK4StationInterfaceReversed.cc:49
void SetStationCoordData(station_coord_type *coord_data)
Definition: MHO_MK4StationInterfaceReversed.hh:49
void FreeAllocated()
Definition: MHO_MK4StationInterfaceReversed.cc:78
void SetPCalData(multitone_pcal_type *pcal_data)
Definition: MHO_MK4StationInterfaceReversed.hh:50
void SetVexData(const mho_json &vex_data)
Definition: MHO_MK4StationInterfaceReversed.hh:46
void SetOutputDirectory(const std::string &output_dir)
Definition: MHO_MK4StationInterfaceReversed.cc:89
virtual ~MHO_MK4StationInterfaceReversed()
Definition: MHO_MK4StationInterfaceReversed.cc:65
void GenerateStationStructure()
Definition: MHO_MK4StationInterfaceReversed.cc:95
int WriteStationFile()
Definition: MHO_MK4StationInterfaceReversed.cc:688
void SetOutputFile(const std::string &output_file)
Definition: MHO_MK4StationInterfaceReversed.hh:51
struct mk4_sdata * GetStationStructure()
Definition: MHO_MK4StationInterfaceReversed.hh:57
Class MHO_TableContainer.
Definition: MHO_TableContainer.hh:36
Definition: mk4_data.h:108
Definition: MHO_ChannelLabeler.hh:17
Definition: type_212.h:10