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 
50  void SetStationCoordData(station_coord_type* coord_data) { fStationCoordData = coord_data; }
51 
52  void SetPCalData(multitone_pcal_type* pcal_data) { fPCalData = pcal_data; }
53 
54  void SetOutputFile(const std::string& output_file) { fOutputFile = output_file; }
55 
57 
58  int WriteStationFile();
59 
60  struct mk4_sdata* GetStationStructure() { return fGeneratedStation; }
61 
62  void FreeAllocated();
63 
64  private:
65  void InitializeStationStructure();
66  void GenerateType000();
67  std::string ConstructType000FileName();
68 
69  void GenerateType300();
70  void GenerateType301Records();
71  void GenerateType303Records();
72  void GenerateType309Records();
73  void setstr(const std::string& str, char* char_array, std::size_t max_size);
74 
75  double ComputeType309Rot(double ap_offset, std::string start_time, double start_time_mjd);
76  double ComputeType309RotFallback(double ap_offset);
77 
87  void ConvertPhasorToCounts(const std::complex< double >& phasor, double acc_period, double sample_period,
88  uint32_t& real_count, uint32_t& imag_count);
89 
93  void ExtractPCalChannelInfo();
94  void ExtractPCalChannelInfoFromVex();
95  double DeterminePCalToneSpacing();
96 
97  double FactorConvertToMHz(std::string units);
98  void DetermineChannelToneIndexes(double lower_freq, double upper_freq, std::size_t& start_idx, std::size_t& ntones);
99 
100  std::string GetStationMode();
101 
102  station_coord_type* fStationCoordData;
103  multitone_pcal_type* fPCalData;
104  struct mk4_sdata* fGeneratedStation;
105  std::string fOutputDir;
106  std::string fOutputFile;
107 
108  //copy of vex data
109  mho_json fVexData;
110  std::string fStationCode;
111  std::string fMode;
112  std::string fFreqSetupName;
113 
114  // Container dimensions
115  std::size_t fNCoord;
116  std::size_t fNIntervals;
117  std::size_t fNCoeffs;
118  std::size_t fNPols;
119  std::size_t fNAPs;
120  std::size_t fNTones;
121 
122  // PCal channel information
123  struct PCalChannelInfo
124  {
125  std::string channel_name;
126  std::string polarization;
127  std::string net_sideband;
128  int tone_start;
129  int ntones;
130  int accumulator_start_index;
131  double sky_freq;
132  double bandwidth;
133  double sample_period;
134  };
135 
136  //the ordering operator for channel info, sort by frequency and pol
137  class chan_predicate
138  {
139  public:
140  chan_predicate(){};
141  virtual ~chan_predicate(){};
142 
143  virtual bool operator()(const PCalChannelInfo& a, const PCalChannelInfo& b)
144  {
145  if(a.sky_freq == b.sky_freq)
146  {
147  return a.polarization < b.polarization;
148  }
149  return a.sky_freq < b.sky_freq;
150  }
151  };
152 
153  std::vector< PCalChannelInfo > fPCalChannelList;
154 
155  std::vector< void* > fAllocated;
156 };
157 
158 } // namespace hops
159 
160 #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:47
void SetStationCoordData(station_coord_type *coord_data)
Definition: MHO_MK4StationInterfaceReversed.hh:50
void FreeAllocated()
Definition: MHO_MK4StationInterfaceReversed.cc:70
void SetPCalData(multitone_pcal_type *pcal_data)
Definition: MHO_MK4StationInterfaceReversed.hh:52
void SetVexData(const mho_json &vex_data)
Definition: MHO_MK4StationInterfaceReversed.hh:46
void SetOutputDirectory(const std::string &output_dir)
Definition: MHO_MK4StationInterfaceReversed.cc:80
virtual ~MHO_MK4StationInterfaceReversed()
Definition: MHO_MK4StationInterfaceReversed.cc:59
void GenerateStationStructure()
Definition: MHO_MK4StationInterfaceReversed.cc:85
int WriteStationFile()
Definition: MHO_MK4StationInterfaceReversed.cc:706
void SetOutputFile(const std::string &output_file)
Definition: MHO_MK4StationInterfaceReversed.hh:54
struct mk4_sdata * GetStationStructure()
Definition: MHO_MK4StationInterfaceReversed.hh:60
Class MHO_TableContainer.
Definition: MHO_TableContainer.hh:36
Definition: mk4_data.h:108
Definition: MHO_AdhocFlagging.hh:18
Definition: type_212.h:10