InverseFilterbank.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2019 by Andrew Jameson, Dean Shaff, and Willem van Straten,
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/General/dsp/InverseFilterbank.h
10 
11 #ifndef __InverseFilterbank_h
12 #define __InverseFilterbank_h
13 
14 #include <string>
15 
16 #include "dsp/Convolution.h"
17 
18 namespace dsp {
19 
21 
77  class InverseFilterbank: public Convolution {
78 
79  public:
80 
82  class Config;
83 
85  InverseFilterbank (const char* name = "InverseFilterbank",
86  Behaviour type = outofplace);
87 
88  void set_input (const TimeSeries* input);
89 
91  void prepare ();
92 
94  void reserve ();
95 
97  uint64_t get_minimum_samples () { return nsamp_fft; }
98 
100  uint64_t get_minimum_samples_lost () { return nsamp_overlap; }
101 
103  void set_input_nchan (unsigned _input_nchan) { input_nchan = _input_nchan; }
104 
106  unsigned get_input_nchan () const { return input_nchan; }
107 
109  void set_output_nchan (unsigned _output_nchan) { output_nchan = _output_nchan; }
110 
112  unsigned get_output_nchan () const { return output_nchan; }
113 
115  unsigned get_nchan_subband () const {return nchan_subband; }
116 
118  void set_freq_res (unsigned _freq_res) { freq_res = _freq_res; }
119 
121  void set_frequency_resolution (unsigned _freq_res) { freq_res = _freq_res; }
122 
124  unsigned get_freq_res () const { return freq_res; }
125 
127  unsigned get_frequency_resolution () const { return freq_res; }
128 
130  void set_frequency_overlap (unsigned over) { overlap_ratio = over; }
131 
133  unsigned get_frequency_overlap () const { return (unsigned) overlap_ratio; }
134 
136  void set_oversampling_factor (const Rational& _osf) { oversampling_factor = _osf; }
137 
140 
142  bool get_pfb_all_chan () const { return pfb_all_chan; }
143 
145  void set_pfb_all_chan (bool);
146 
148  int get_input_discard_neg() const {return input_discard_neg;}
149 
151  void set_input_discard_neg(int _input_discard_neg) { input_discard_neg = _input_discard_neg;}
152 
154  int get_input_discard_pos() const {return input_discard_pos;}
155 
157  void set_input_discard_pos(int _input_discard_pos) { input_discard_pos = _input_discard_pos;}
158 
160  int get_output_discard_neg() const {return output_discard_neg;}
161 
163  void set_output_discard_neg(int _output_discard_neg) { output_discard_neg = _output_discard_neg;}
164 
166  int get_output_discard_pos() const {return output_discard_pos;}
167 
169  void set_output_discard_pos(int _output_discard_pos) { output_discard_pos = _output_discard_pos;}
170 
172  int get_input_fft_length() const {return input_fft_length;}
173 
175  void set_input_fft_length(int _input_fft_length) { input_fft_length = _input_fft_length;}
176 
178  int get_output_fft_length() const {return output_fft_length;}
179 
181  void set_output_fft_length(int _output_fft_length) { output_fft_length = _output_fft_length;}
182 
183 
185  class Engine;
186  void set_engine (Engine*);
187 
188  protected:
189 
191  virtual void transformation ();
192 
194  virtual void filterbank ();
195 
198  virtual void custom_prepare () {}
199 
201  unsigned input_nchan;
202 
205  unsigned output_nchan;
206 
208  unsigned freq_res;
209 
212  unsigned nchan_subband;
213 
216 
221 
224  bool pfb_all_chan;
225 
228 
229  private:
230 
231  // div_t calc_lcf (int a, int b, Rational osf);
232 
237  void make_preparations ();
238 
240  void prepare_output (uint64_t ndat = 0, bool set_ndat = false);
241 
243  void resize_output (bool reserve_extra = false);
244 
246  int input_fft_length;
247 
249  int output_fft_length;
250 
252  int input_discard_total;
253 
255  int input_sample_step;
256 
258  int output_discard_total;
259 
261  int output_sample_step;
262 
264  int input_discard_pos;
266  int input_discard_neg;
267 
269  int output_discard_pos;
271  int output_discard_neg;
272 
273 
274  };
275 
276 }
277 
278 #endif
int get_input_discard_neg() const
Get the number of samples discarded at the end of an input step.
Definition: InverseFilterbank.h:158
int get_output_discard_neg() const
Get the number of samples discarded at the end of an output step.
Definition: InverseFilterbank.h:170
void set_output_discard_neg(int _output_discard_neg)
Set the number of samples discarded at the end of an output step.
Definition: InverseFilterbank.h:173
Abstract base class for derived engines that operate on data in order to perform inverse (synthesis) ...
Definition: InverseFilterbankEngine.h:20
bool get_pfb_all_chan() const
Get the pfb_all_chan flag.
Definition: InverseFilterbank.h:152
const Rational & get_oversampling_factor()
Get oversampling_factor.
Definition: InverseFilterbank.h:149
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
uint64_t get_minimum_samples_lost()
Get the minimum number of samples lost.
Definition: InverseFilterbank.h:110
unsigned get_nchan_subband() const
Get the number of input channels per output channels.
Definition: InverseFilterbank.h:125
void set_frequency_resolution(unsigned _freq_res)
Set the frequency resolution factor.
Definition: InverseFilterbank.h:131
void set_input(const TimeSeries *input)
Set the container from which input data will be read.
Definition: Transformation.h:258
void prepare()
Prepare all relevant attributes.
Definition: InverseFilterbank.C:62
void prepare_output()
Prepare the output TimeSeries.
Definition: Convolution.C:449
unsigned get_output_nchan() const
Get the number of output channels.
Definition: InverseFilterbank.h:122
int get_input_discard_pos() const
Get the number of samples discarded at the start of an input step.
Definition: InverseFilterbank.h:164
void build()
Build the specified window.
Definition: Apodization.C:44
Behaviour
All Transformations must define their behaviour.
Definition: Transformation.h:47
void dump(const std::string &filename)
Write the window to a text file.
Definition: Apodization.C:208
Performs the PFB inversion synthesis operation.
Definition: InverseFilterbank.h:82
unsigned input_nchan
number of input channels
Definition: InverseFilterbank.h:211
void set_output_discard_pos(int _output_discard_pos)
Get the number of samples discarded at the start of an output step.
Definition: InverseFilterbank.h:179
virtual void set_buffering_policy(BufferingPolicy *policy)
Set the policy for buffering input and/or output data.
Definition: Transformation.h:85
const ScalarMath pow(const ScalarMath &x, const ScalarMath &y)
void set_oversampling_factor(const Rational &_osf)
Set oversampling_factor.
Definition: InverseFilterbank.h:146
int get_input_fft_length() const
Get the size of the forward fft, in number of samples.
Definition: InverseFilterbank.h:182
std::string name
Operation name.
Definition: Operation.h:153
Represents a rational number.
Definition: Rational.h:15
static bool record_time
Global flag enables stopwatch to record the time spent operating.
Definition: Operation.h:42
InverseFilterbank(const char *name="InverseFilterbank", Behaviour type=outofplace)
Null constructor.
Definition: InverseFilterbank.C:29
Buffers the Transformation input.
Definition: InputBuffering.h:26
unsigned output_nchan
Number of channels into which the input will be synthesized This is the final number of channels in t...
Definition: InverseFilterbank.h:215
void set_frequency_overlap(unsigned over)
Set the frequency overlap.
Definition: InverseFilterbank.h:140
double overlap_ratio
Frequency channel overlap ratio.
Definition: InverseFilterbank.h:225
bool pfb_all_chan
This flag indicates whether we have all the channels from the last stage of upstream channelization.
Definition: InverseFilterbank.h:234
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
Convolves a TimeSeries using a frequency response function.
Definition: Convolution.h:64
unsigned get_frequency_resolution() const
Get the frequency resolution factor.
Definition: InverseFilterbank.h:137
void set_pfb_all_chan(bool)
Set the pfb_all_chan flag.
Definition: InverseFilterbank.C:43
unsigned get_freq_res() const
Get the frequency resolution factor.
Definition: InverseFilterbank.h:134
virtual void transformation()
Perform the convolution transformation on the input TimeSeries.
Definition: InverseFilterbank.C:112
int get_output_fft_length() const
Get the size of the backward fft, in number of samples.
Definition: InverseFilterbank.h:188
int get_output_discard_pos() const
Get the number of samples discarded at the start of an output step.
Definition: InverseFilterbank.h:176
unsigned freq_res
Frequency resolution factor.
Definition: InverseFilterbank.h:218
void set_output_nchan(unsigned _output_nchan)
Set the number of output channels.
Definition: InverseFilterbank.h:119
void set_size(unsigned)
Set the number of samples in the window.
Definition: Apodization.C:29
void set_input_discard_pos(int _input_discard_pos)
Set the number of samples discarded at the start of an input step.
Definition: InverseFilterbank.h:167
void set_freq_res(unsigned _freq_res)
Set the frequency resolution factor.
Definition: InverseFilterbank.h:128
void set_analytic(bool f=true)
Set true when the data to be tapered are complex-valued.
Definition: Apodization.h:47
virtual void custom_prepare()
Override this in a child class to do any custom pre-transformation data preparation.
Definition: InverseFilterbank.h:208
virtual void filterbank()
Perform the filterbank step.
Definition: InverseFilterbank.C:162
void set_input_discard_neg(int _input_discard_neg)
Set the number of samples discarded at the end of an input step.
Definition: InverseFilterbank.h:161
Reference::To< Engine > engine
Interface to alternate processing engine (e.g. GPU)
Definition: InverseFilterbank.h:237
unsigned get_input_nchan() const
Get the number of input channels.
Definition: InverseFilterbank.h:116
void set_input_nchan(unsigned _input_nchan)
Set the number of input channels.
Definition: InverseFilterbank.h:113
void set_input_fft_length(int _input_fft_length)
Set the size of the forward fft, in number of samples.
Definition: InverseFilterbank.h:185
void set_output_fft_length(int _output_fft_length)
Set the size of the backward fft, in number of samples.
Definition: InverseFilterbank.h:191
Various apodizing (window) functions.
Definition: Apodization.h:28
void set_input(const TimeSeries *input)
Set the container from which input data will be read.
Definition: InverseFilterbank.C:49
unsigned get_frequency_overlap() const
Get the frequency overlap.
Definition: InverseFilterbank.h:143
uint64_t get_minimum_samples()
Get the minimum number of samples required for operation.
Definition: InverseFilterbank.h:107
void reserve()
Reserve the maximum amount of output space required.
Definition: InverseFilterbank.C:71
Reference::To< const TimeSeries > input
Container from which input data will be read.
Definition: HasInput.h:49
Rational oversampling_factor
Polyphase filterbank oversampling ratio.
Definition: InverseFilterbank.h:230
unsigned nchan_subband
This is the number of input channels per output channel, or input_nchan / output_nchan.
Definition: InverseFilterbank.h:222
normalization get_norm()

Generated using doxygen 1.8.17