1 #ifndef MHO_SamplerLabeler_HH__
2 #define MHO_SamplerLabeler_HH__
40 fChannelLabelKey =
"channel_label";
41 fRefSamplerIndexKey =
"ref_sampler_index";
42 fRemSamplerIndexKey =
"rem_sampler_index";
54 fRefSamplerChanSets = channel_sets;
64 fRemSamplerChanSets = channel_sets;
98 ConstructChannelToSamplerIDMap(fRefSamplerChanSets, fRefChanToSamplerID);
99 ConstructChannelToSamplerIDMap(fRemSamplerChanSets, fRemChanToSamplerID);
105 auto chan_axis_ptr = &(std::get< CHANNEL_AXIS >(*in));
106 std::size_t nchans = chan_axis_ptr->GetSize();
108 for(std::size_t ch = 0; ch < nchans; ch++)
110 std::string chan_label =
"";
111 chan_axis_ptr->RetrieveIndexLabelKeyValue(ch, fChannelLabelKey, chan_label);
113 if(fRefChanToSamplerID.find(chan_label) != fRefChanToSamplerID.end())
115 int ref_id = fRefChanToSamplerID[chan_label];
116 chan_axis_ptr->InsertIndexLabelKeyValue(ch, fRefSamplerIndexKey, ref_id);
118 if(fRemChanToSamplerID.find(chan_label) != fRemChanToSamplerID.end())
120 int rem_id = fRemChanToSamplerID[chan_label];
121 chan_axis_ptr->InsertIndexLabelKeyValue(ch, fRemSamplerIndexKey, rem_id);
145 std::vector< std::string > fRefSamplerChanSets;
146 std::vector< std::string > fRemSamplerChanSets;
147 std::map< std::string, int > fRefChanToSamplerID;
148 std::map< std::string, int > fRemChanToSamplerID;
151 std::string fChannelLabelKey;
152 std::string fRefSamplerIndexKey;
153 std::string fRemSamplerIndexKey;
162 void ConstructChannelToSamplerIDMap(std::vector< std::string >& chan_set, std::map< std::string, int >& chan2id)
165 for(std::size_t sampler_id = 0; sampler_id < chan_set.size(); sampler_id++)
167 std::string chans = chan_set[sampler_id];
168 std::vector< std::string > split_chans = SplitChannelLabels(chans);
169 for(
auto it = split_chans.begin(); it != split_chans.end(); it++)
171 chan2id[*it] = (int)sampler_id;
182 std::vector< std::string > SplitChannelLabels(std::string channels)
184 std::vector< std::string > split_chans;
188 if((channels.find(
',') != std::string::npos))
201 for(std::size_t i = 0; i < channels.size(); i++)
203 split_chans.push_back(std::string(1, channels[i]));
Class MHO_SamplerLabeler.
Definition: MHO_SamplerLabeler.hh:35
virtual bool InitializeInPlace(XArrayType *in) override
Initializes in-place mapping for channel labels to sampler indices.
Definition: MHO_SamplerLabeler.hh:75
virtual bool ExecuteInPlace(XArrayType *in) override
Function ExecuteInPlace - actual implementation, map channel label (e.g. 'a', 'b',...
Definition: MHO_SamplerLabeler.hh:95
virtual bool ExecuteOutOfPlace(const XArrayType *in, XArrayType *out) override
Copies input array and executes in-place operation on output.
Definition: MHO_SamplerLabeler.hh:137
void SetReferenceStationSamplerChannelSets(const std::vector< std::string > &channel_sets)
Setter for reference station sampler channel sets.
Definition: MHO_SamplerLabeler.hh:52
virtual ~MHO_SamplerLabeler()
Definition: MHO_SamplerLabeler.hh:45
MHO_SamplerLabeler()
Definition: MHO_SamplerLabeler.hh:37
virtual bool InitializeOutOfPlace(const XArrayType *, XArrayType *) override
Initializes output array in-place from input array.
Definition: MHO_SamplerLabeler.hh:85
void SetRemoteStationSamplerChannelSets(const std::vector< std::string > &channel_sets)
Setter for remote station sampler channel sets.
Definition: MHO_SamplerLabeler.hh:62
Class MHO_Tokenizer.
Definition: MHO_Tokenizer.hh:24
void SetUseMulticharacterDelimiterFalse()
Definition: MHO_Tokenizer.cc:40
void SetIncludeEmptyTokensFalse()
Definition: MHO_Tokenizer.cc:30
void SetString(const std::string *aString)
Definition: MHO_Tokenizer.cc:65
void GetTokens(std::vector< std::string > *tokens)
Definition: MHO_Tokenizer.cc:75
void SetRemoveLeadingTrailingWhitespaceTrue()
Setter for remove leading trailing whitespace true.
Definition: MHO_Tokenizer.cc:55
void SetDelimiter(const std::string &aDelim)
Definition: MHO_Tokenizer.cc:70
Class MHO_UnaryOperator.
Definition: MHO_UnaryOperator.hh:24
Definition: MHO_ChannelLabeler.hh:17