1 #ifndef MHO_ChannelLabeler_HH__
2 #define MHO_ChannelLabeler_HH__
39 fIndexToChannelLabel.clear();
41 fChannelLabelKey =
"channel_label";
92 auto chan_axis_ptr = &(std::get< CHANNEL_AXIS >(*in));
93 std::size_t nchans = chan_axis_ptr->GetSize();
96 std::vector< mho_json > dsb_labels = chan_axis_ptr->GetMatchingIntervalLabels(
"double_sideband");
98 if(fChannelLabelToFrequency.size() == 0)
101 FillDefaultMap(nchans);
102 std::size_t label_count = 0;
103 for(std::size_t i = 0; i < nchans; i++)
105 std::string ch_label = fIndexToChannelLabel[label_count];
108 bool already_labeled = chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"channel_label",
dummy);
111 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label);
114 if(dsb_labels.size() != 0)
117 bool has_dsb_partner =
118 chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"dsb_partner", partner_offset);
119 int partner_idx = i + partner_offset;
120 if(has_dsb_partner && (0 <= partner_offset) && (partner_offset < nchans))
124 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label +
"-");
125 chan_axis_ptr->InsertIndexLabelKeyValue(partner_idx, fChannelLabelKey, ch_label +
"+");
134 if(fChannelLabelToFrequency.size() < nchans - dsb_labels.size())
136 msg_error(
"calibration",
"not all channels given a user specified label, "
137 <<
"some channels will remain un-labelled." << eom);
142 for(
auto it = fChannelLabelToFrequency.begin(); it != fChannelLabelToFrequency.end(); it++)
144 std::string ch_label = it->first;
145 double freq = it->second;
146 for(std::size_t i = 0; i < nchans; i++)
148 double ch_freq = chan_axis_ptr->at(i);
149 if(std::abs(freq - ch_freq) < fEps)
151 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label);
154 if(dsb_labels.size() != 0)
157 bool has_dsb_partner =
158 chan_axis_ptr->RetrieveIndexLabelKeyValue(i,
"dsb_partner", partner_offset);
159 int partner_idx = i + partner_offset;
164 chan_axis_ptr->InsertIndexLabelKeyValue(i, fChannelLabelKey, ch_label +
"-");
165 chan_axis_ptr->InsertIndexLabelKeyValue(partner_idx, fChannelLabelKey, ch_label +
"+");
198 void FillDefaultMap(std::size_t nchans)
200 fIndexToChannelLabel.clear();
201 for(std::size_t i = 0; i < nchans; i++)
208 std::string fChannelLabelKey;
211 std::map< std::string, double > fChannelLabelToFrequency;
214 std::map< std::size_t, std::string > fIndexToChannelLabel;
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
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:35
virtual bool InitializeInPlace(XArrayType *in) override
Initializes XArrayType in-place and returns success.
Definition: MHO_ChannelLabeler.hh:68
void SetTolerance(double tol)
Setter for tolerance - allows channel freq association to use a (freq) difference tolerance.
Definition: MHO_ChannelLabeler.hh:51
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:58
virtual bool InitializeOutOfPlace(const XArrayType *, XArrayType *) override
Initializes output array out-of-place from input array.
Definition: MHO_ChannelLabeler.hh:78
virtual bool ExecuteOutOfPlace(const XArrayType *in, XArrayType *out) override
Copies input array to output and executes in-place operation on output.
Definition: MHO_ChannelLabeler.hh:186
MHO_ChannelLabeler()
Definition: MHO_ChannelLabeler.hh:37
virtual ~MHO_ChannelLabeler()
Definition: MHO_ChannelLabeler.hh:44
virtual bool ExecuteInPlace(XArrayType *in) override
Function ExecuteInPlace - attaches channel labels based on sky frequency or user specified map.
Definition: MHO_ChannelLabeler.hh:87
Class MHO_UnaryOperator.
Definition: MHO_UnaryOperator.hh:24
def dummy(fringe_data_interface)
Definition: example1.py:3
Definition: MHO_ChannelLabeler.hh:17