HOPS
HOPS class reference
MHO_DoubleSidebandChannelLabeler.hh
Go to the documentation of this file.
1 #ifndef MHO_DoubleSidebandChannelLabeler_HH__
2 #define MHO_DoubleSidebandChannelLabeler_HH__
3 
4 #include <map>
5 #include <stack>
6 #include <string>
7 
8 #include "MHO_Message.hh"
9 
10 #include "MHO_EncodeDecodeValue.hh"
11 
13 #include "MHO_TableContainer.hh"
14 #include "MHO_UnaryOperator.hh"
15 
16 namespace hops
17 {
18 
32 template< typename XArrayType > class MHO_DoubleSidebandChannelLabeler: public MHO_UnaryOperator< XArrayType >
33 {
34  public:
36  {
37  fEps = 1e-6; //tolerance (MHz) when checking if channels share a sky freq
38  };
39 
41 
42  //allow channel freq association to use a difference tolerance
48  void SetTolerance(double tol) { fEps = tol; }
49 
50  protected:
58  virtual bool ExecuteInPlace(XArrayType* in) override
59  {
60  if(in != nullptr)
61  {
62  //need to use the user provided frequency <-> channel label map
63  auto chan_ax = &(std::get< CHANNEL_AXIS >(*in));
64  std::size_t nchans = chan_ax->GetSize();
65 
66  int double_sideband_pair_counter = 0; //count unique double-sideband pairs
67  for(std::size_t ch = 0; ch < nchans - 1; ch++)
68  {
69  std::size_t next_ch = ch + 1;
70  double f1 = chan_ax->at(ch);
71  double f2 = chan_ax->at(next_ch);
72 
73  double bw1 = 0;
74  double bw2 = 0;
75  bool bw1_present = chan_ax->RetrieveIndexLabelKeyValue(ch, "bandwidth", bw1);
76  bool bw2_present = chan_ax->RetrieveIndexLabelKeyValue(next_ch, "bandwidth", bw2);
77 
78  if(std::abs(f1 - f2) < fEps && std::abs(bw1 - bw2) < fEps)
79  {
80  //sky frequencies of these two channels are the same
81  //now check if they are a LSB/USB pair
82  std::string nsb1 = "";
83  std::string nsb2 = "";
84  bool nsb1_present = chan_ax->RetrieveIndexLabelKeyValue(ch, "net_sideband", nsb1);
85  bool nsb2_present = chan_ax->RetrieveIndexLabelKeyValue(next_ch, "net_sideband", nsb2);
86 
87  if(nsb1_present && nsb2_present)
88  {
89  //1st channel is LSB, 2nd channel is USB --> we have a 'double-sideband' channel
90  //note: we ignore the oddball case where U and L are inverted
91  if(nsb1 == "L" && nsb2 == "U")
92  {
93  bool value = true;
94  chan_ax->InsertIntervalLabelKeyValue(ch, next_ch, "double_sideband", value);
95 
96  //make sure each channel has a reference to index of the other via a RELATIVE offset
97  chan_ax->InsertIndexLabelKeyValue(ch, "dsb_partner", 1);
98  chan_ax->InsertIndexLabelKeyValue(next_ch, "dsb_partner", -1);
99  }
100  double_sideband_pair_counter++;
101  }
102  }
103  }
104  return true;
105  }
106  return false;
107  }
108 
109  private:
110  double fEps;
111 };
112 
113 } // namespace hops
114 
115 #endif
Class MHO_DoubleSidebandChannelLabeler.
Definition: MHO_DoubleSidebandChannelLabeler.hh:33
virtual ~MHO_DoubleSidebandChannelLabeler()
Definition: MHO_DoubleSidebandChannelLabeler.hh:40
void SetTolerance(double tol)
Setter for tolerance - in (MHz) when checking if channels share a sky freq.
Definition: MHO_DoubleSidebandChannelLabeler.hh:48
virtual bool ExecuteInPlace(XArrayType *in) override
Function ExecuteInPlace labels LSB/USB channel pairs as "double sideband" channels if they share and ...
Definition: MHO_DoubleSidebandChannelLabeler.hh:58
MHO_DoubleSidebandChannelLabeler()
Definition: MHO_DoubleSidebandChannelLabeler.hh:35
Class MHO_UnaryOperator.
Definition: MHO_UnaryOperator.hh:24
Definition: MHO_AdhocFlagging.hh:18
Definition: vex.h:175