1 #ifndef MHO_ChannelLabeler_HH__
2 #define MHO_ChannelLabeler_HH__
37 fIndexToChannelLabel.clear();
39 fChannelLabelKey =
"channel_label";
71 auto chan_axis_ptr = &(std::get< CHANNEL_AXIS >(*in));
72 std::size_t nchans = chan_axis_ptr->GetSize();
75 std::vector< mho_json > dsb_labels = chan_axis_ptr->GetMatchingIntervalLabels(
"double_sideband");
77 if(fChannelLabelToFrequency.size() == 0)
80 FillDefaultMap(nchans);
81 std::size_t label_count = 0;
82 for(std::size_t i = 0; i < nchans; i++)
84 std::string ch_label = fIndexToChannelLabel[label_count];
87 bool already_labeled = chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"channel_label",
dummy);
90 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label);
93 if(dsb_labels.size() != 0)
96 bool has_dsb_partner =
97 chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"dsb_partner", partner_offset);
98 int partner_idx = i + partner_offset;
99 if(has_dsb_partner && (0 <= partner_offset) && (partner_offset < nchans))
103 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label +
"-");
104 chan_axis_ptr->InsertIndexLabelKeyValue(partner_idx, fChannelLabelKey, ch_label +
"+");
113 if(fChannelLabelToFrequency.size() < nchans - dsb_labels.size())
115 msg_error(
"calibration",
"not all channels given a user specified label, "
116 <<
"some channels will remain un-labelled." << eom);
121 for(
auto it = fChannelLabelToFrequency.begin(); it != fChannelLabelToFrequency.end(); it++)
123 std::string ch_label = it->first;
124 double freq = it->second;
125 for(std::size_t i = 0; i < nchans; i++)
127 double ch_freq = chan_axis_ptr->at(i);
128 if(std::abs(freq - ch_freq) < fEps)
130 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label);
133 if(dsb_labels.size() != 0)
136 bool has_dsb_partner =
137 chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"dsb_partner", partner_offset);
138 int partner_idx = i + partner_offset;
143 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label +
"-");
144 chan_axis_ptr->InsertIndexLabelKeyValue(partner_idx, fChannelLabelKey, ch_label +
"+");
163 void FillDefaultMap(std::size_t nchans)
165 fIndexToChannelLabel.clear();
166 for(std::size_t i = 0; i < nchans; i++)
173 std::string fChannelLabelKey;
176 std::map< std::string, double > fChannelLabelToFrequency;
179 std::map< std::size_t, std::string > fIndexToChannelLabel;
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:238
Class MHO_ChannelIndexLabeler.
Definition: MHO_EncodeDecodeValue.hh:96
std::string EncodeValueToLabel(const uint64_t &value) const
Encodes a uint64_t value into a label string using default and extended encoding schemes.
Definition: MHO_EncodeDecodeValue.hh:130
Class MHO_ChannelLabeler.
Definition: MHO_ChannelLabeler.hh:33
void SetTolerance(double tol)
Setter for tolerance - allows channel freq association to use a (freq) difference tolerance.
Definition: MHO_ChannelLabeler.hh:49
void SetChannelLabelToFrequencyMap(const std::map< std::string, double > &map)
Setter for channel label to frequency map so if there is a user provided labeling scheme,...
Definition: MHO_ChannelLabeler.hh:56
MHO_ChannelLabeler()
Definition: MHO_ChannelLabeler.hh:35
virtual ~MHO_ChannelLabeler()
Definition: MHO_ChannelLabeler.hh:42
virtual bool ExecuteInPlace(XArrayType *in) override
Function ExecuteInPlace - attaches channel labels based on sky frequency or user specified map.
Definition: MHO_ChannelLabeler.hh:66
Class MHO_UnaryOperator.
Definition: MHO_UnaryOperator.hh:24
def dummy(fringe_data_interface)
Definition: example1.py:3
Definition: MHO_AdhocFlagging.hh:18