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 
44 {
45  public:
47  virtual ~MHO_MK4CorelInterface();
48 
54  void SetVexFile(const std::string& vex) { fVexFile = vex; }
55 
61  void SetCorelFile(const std::string& corel) { fCorelFile = corel; }
62 
68  struct mk4_corel* GetCorelData() { return fCorel; };
69 
70  //read the vex and corel files and dump into new format
74  int ExtractCorelFile();
75 
76  //TODO FIXME:
77  //Depending on how the return values are managed by the external caller
78  //the return values here are a potential memory leak, so we should
79  //consider replacing the raw ptr return value with smart pointers.
80  //For now we assume the caller will handle clean-up/deletion, so we do
81  //not attempt to delete fExtractedVisibilities/fExtractedWeights in the
82  //destructor of this interface class.
88  uch_visibility_store_type* GetExtractedVisibilities() { return fExtractedVisibilities; };
89 
95  uch_weight_store_type* GetExtractedWeights() { return fExtractedWeights; };
96 
97  private:
98  //corel and vex file members
102  void ReadCorelFile();
106  void ReadVexFile();
107  bool fHaveCorel;
108  bool fHaveVex;
109  struct mk4_corel* fCorel;
110  mho_json fVex;
111  std::string fVexFile;
112  std::string fCorelFile;
113  std::string fRootCode; //derived from corel file name
114 
115  //data dimensions related members
119  void DetermineDataDimensions();
120  std::size_t fNPPs;
121  std::size_t fNAPs;
122  std::size_t fNSpectral; //not really number of lags, but rather, spectral points
123  std::size_t fNChannels;
124  std::size_t fNChannelsPerPP;
125  std::set< std::string > fPolProducts;
126 
127  //meta-data information
128  std::string fBaselineName; //e.g. Gs:Wf
129  std::string fBaselineShortName; //e.g GE
130  std::string fRefStation; //e.g. Gs
131  std::string fRemStation; //e.g. Wf
132  std::string fRefStationMk4Id; //e.g G
133  std::string fRemStationMk4Id; //e.g.E
134 
135  //store all channel related data in interval labels for convenience
136  std::map< std::string, mho_json > fAllChannelMap;
137 
138  //this field stores pointers to channel labels on a per-pol product basis
139  //the keys are pol-product labels (e.g. XX, RL, YY, etc)
140  //the vectors are sorted by sky-frequency
141  std::map< std::string, std::vector< mho_json* > > fPPSortedChannelInfo;
142 
143  //helper function to convert raw char arrays to strings
144  std::string getstr(const char* char_array, size_t max_size);
145  bool channel_info_match(double ref_sky_freq, double rem_sky_freq, double ref_bw, double rem_bw, std::string ref_net_sb,
146  std::string rem_net_sb);
147  double calc_freq_bin(double sky_freq, double bw, std::string net_sb, int nlags, int bin_index);
148 
149  uch_visibility_store_type* fExtractedVisibilities;
150  uch_weight_store_type* fExtractedWeights;
151 };
152 
153 } // namespace hops
154 
155 #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:44
MHO_MK4CorelInterface()
Definition: MHO_MK4CorelInterface.cc:66
int 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:95
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:54
uch_visibility_store_type * GetExtractedVisibilities()
Getter for extracted visibilities.
Definition: MHO_MK4CorelInterface.hh:88
struct mk4_corel * GetCorelData()
Getter for raw mk4 corel data struct.
Definition: MHO_MK4CorelInterface.hh:68
void SetCorelFile(const std::string &corel)
Setter for corel file.
Definition: MHO_MK4CorelInterface.hh:61
Class MHO_TableContainer.
Definition: MHO_TableContainer.hh:36
Definition: mk4_data.h:71
Definition: MHO_AdhocFlagging.hh:18
Definition: vex.h:28