1 #ifndef WIRECELL_WAVEFORM 2 #define WIRECELL_WAVEFORM 26 template<
typename Val>
44 BinRangeList
merge(
const BinRangeList& br);
47 BinRangeList
merge(
const BinRangeList& br1,
const BinRangeList& br2);
53 ChannelMasks
merge(
const ChannelMasks& one,
const ChannelMasks& two);
62 void merge(ChannelMaskMap &one, ChannelMaskMap &two, std::map<std::string,std::string>& name_map);
66 typedef std::pair<double,double>
Period;
69 typedef std::pair<double,double>
Band;
75 typedef std::pair<double,double>
Domain;
78 return (domain.second-domain.first)/
width;
82 return (domain.second-domain.first)/count;
86 std::pair<int,int>
sub_sample(
const Domain& domain,
int nsamples,
const Domain& subdomain);
91 template<
typename Val>
93 const int oldnsamples = wave.size();
94 const double oldstep =
sample_width(domain, oldnsamples);
97 for (
int ind=0; ind<nsamples; ++ind) {
98 double cursor = newdomain.first + ind*
step;
99 double oldfracsteps = (cursor-domain.first)/oldstep;
100 int oldind =
int(oldfracsteps);
101 if (cursor <= domain.first || oldind <= 0) {
102 ret.push_back(wave[0]);
105 if (cursor >= domain.second or oldind+1 >= oldnsamples) {
106 ret.push_back(wave[oldnsamples-1]);
109 double d1 = oldfracsteps - oldstep*oldind;
110 double d2 = oldstep - d1;
111 Val newval = (wave[oldind] * d1 + wave[oldind+1]*d2) / oldstep;
112 ret.push_back(newval);
118 realseq_t
real(
const compseq_t& seq);
120 realseq_t
imag(
const compseq_t& seq);
122 realseq_t
magnitude(
const compseq_t& seq);
124 realseq_t
phase(
const compseq_t& seq);
128 template<
typename Val>
131 [scalar](Val
x) {
return x+scalar; });
138 template<
typename Val>
140 std::transform(seq.begin(), seq.end(), other.begin(), seq.begin(),
145 template<
typename Val>
148 [scalar](Val
x) {
return x*scalar; });
151 scale(seq, (
float)scalar);
155 template<
typename Val>
157 std::transform(seq.begin(), seq.end(), other.begin(), seq.begin(),
158 std::multiplies<Val>());
161 template<
typename Val>
163 std::transform(seq.begin(), seq.end(), other.begin(), seq.begin(),
164 std::divides<Val>());
172 std::pair<int, int>
edge(
const realseq_t& wave);
177 template<
typename Val>
179 return std::accumulate(seq.begin(), seq.end(), Val());
183 template<
typename Val>
185 return std::accumulate(seq.begin(), seq.end(), Val(),
186 [](
const Val& bucket, Val
x) {
192 std::pair<double,double>
mean_rms(
const realseq_t& wave);
197 real_t
median(realseq_t& wave);
203 real_t
percentile(realseq_t& wave, real_t percentage);
208 compseq_t
dft(realseq_t seq);
216 bool truncate =
true);
225 bool truncate =
true);
230 realseq_t
idft(compseq_t spec);
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)