HOPS
HOPS class reference
MHO_MK4CorelInterface.hh
Go to the documentation of this file.
1 #ifndef MHO_MK4CorelInterface_HH__
2 #define MHO_MK4CorelInterface_HH__
3 
4 #include <cstdlib>
5 #include <cstring>
6 #include <string>
7 #include <vector>
8 
10 #include "MHO_MK4VexInterface.hh"
11 
12 #include "MHO_Message.hh"
13 
14 //forward declaration of mk4_corel structs
15 //we do this to keep the mk4 structures from 'leaking' into the new code via includes,
16 //We want to make sure any interface to the old mk4 IO libraries is kept only
17 //within the MK4Interface library.
18 #ifndef HOPS3_USE_CXX
19 extern "C"
20 {
21 #endif
22 
23  struct mk4_corel;
24 
25 #ifndef HOPS3_USE_CXX
26 }
27 #endif
28 
29 namespace hops
30 {
31 
45 {
46  public:
48  virtual ~MHO_MK4CorelInterface();
49 
55  void SetVexFile(const std::string& vex) { fVexFile = vex; }
56 
62  void SetCorelFile(const std::string& corel) { fCorelFile = corel; }
63 
69  struct mk4_corel* GetCorelData() { return fCorel; };
70 
71  //read the vex and corel files and dump into new format
75  void ExtractCorelFile();
76 
77  //TODO FIXME:
78  //Depending on how the return values are managed by the external caller
79  //the return values here are a potential memory leak, so we should
80  //consider replacing the raw ptr return value with smart pointers.
81  //For now we assume the caller will handle clean-up/deletion, so we do
82  //not attempt to delete fExtractedVisibilities/fExtractedWeights in the
83  //destructor of this interface class.
89  uch_visibility_store_type* GetExtractedVisibilities() { return fExtractedVisibilities; };
90 
96  uch_weight_store_type* GetExtractedWeights() { return fExtractedWeights; };
97 
98  private:
99  //corel and vex file members
103  void ReadCorelFile();
107  void ReadVexFile();
108  bool fHaveCorel;
109  bool fHaveVex;
110  struct mk4_corel* fCorel;
111  mho_json fVex;
112  std::string fVexFile;
113  std::string fCorelFile;
114  std::string fRootCode; //derived from corel file name
115 
116  //data dimensions related members
120  void DetermineDataDimensions();
121  std::size_t fNPPs;
122  std::size_t fNAPs;
123  std::size_t fNSpectral; //not really number of lags, but rather, spectral points
124  std::size_t fNChannels;
125  std::size_t fNChannelsPerPP;
126  std::set< std::string > fPolProducts;
127 
128  //meta-data information
129  std::string fBaselineName; //e.g. Gs:Wf
130  std::string fBaselineShortName; //e.g GE
131  std::string fRefStation; //e.g. Gs
132  std::string fRemStation; //e.g. Wf
133  std::string fRefStationMk4Id; //e.g G
134  std::string fRemStationMk4Id; //e.g.E
135 
136  //store all channel related data in interval labels for convenience
137  std::map< std::string, mho_json > fAllChannelMap;
138 
139  //this field stores pointers to channel labels on a per-pol product basis
140  //the keys are pol-product labels (e.g. XX, RL, YY, etc)
141  //the vectors are sorted by sky-frequency
142  std::map< std::string, std::vector< mho_json* > > fPPSortedChannelInfo;
143 
144  //helper function to convert raw char arrays to strings
145  std::string getstr(const char* char_array, size_t max_size);
146  bool channel_info_match(double ref_sky_freq, double rem_sky_freq, double ref_bw, double rem_bw, std::string ref_net_sb,
147  std::string rem_net_sb);
148  double calc_freq_bin(double sky_freq, double bw, std::string net_sb, int nlags, int bin_index);
149 
150  uch_visibility_store_type* fExtractedVisibilities;
151  uch_weight_store_type* fExtractedWeights;
152 };
153 
154 } // namespace hops
155 
156 #endif
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
MHO_MK4CorelInterface - Needed to import data from mk4_corel file objects (type_1xx) to HOPS4 format....
Definition: MHO_MK4CorelInterface.hh:45
MHO_MK4CorelInterface()
Definition: MHO_MK4CorelInterface.cc:66
void ExtractCorelFile()
Extracts Corel file data and stores it in visibility and weight containers.
Definition: MHO_MK4CorelInterface.cc:487
uch_weight_store_type * GetExtractedWeights()
Getter for extracted weights.
Definition: MHO_MK4CorelInterface.hh:96
virtual ~MHO_MK4CorelInterface()
Definition: MHO_MK4CorelInterface.cc:87
void SetVexFile(const std::string &vex)
Setter for vex file, we need both the vex (root) file and corel file to extract the data.
Definition: MHO_MK4CorelInterface.hh:55
uch_visibility_store_type * GetExtractedVisibilities()
Getter for extracted visibilities.
Definition: MHO_MK4CorelInterface.hh:89
struct mk4_corel * GetCorelData()
Getter for raw mk4 corel data struct.
Definition: MHO_MK4CorelInterface.hh:69
void SetCorelFile(const std::string &corel)
Setter for corel file.
Definition: MHO_MK4CorelInterface.hh:62
Class MHO_TableContainer.
Definition: MHO_TableContainer.hh:36
Definition: mk4_data.h:71
Definition: MHO_ChannelLabeler.hh:17
Definition: vex.h:28