InverseFilterbankEngineCPU.h
1 //-*-C++-*-
2 
3 /***************************************************************************
4  *
5  * Copyright (C) 2009 by Willem van Straten
6  * Licensed under the Academic Free License version 2.1
7  *
8  ***************************************************************************/
9 
10 // dspsr/Signal/General/dsp/InverseFilterbankEngineCPU.h
11 
12 #ifndef __InverseFilterbankEngineCPU_h
13 #define __InverseFilterbankEngineCPU_h
14 
15 #include "dsp/InverseFilterbankEngine.h"
16 
17 #include "FTransform.h"
18 
19 namespace dsp
20 {
21 
26  class InverseFilterbankEngineCPU : public dsp::InverseFilterbank::Engine
27  {
28 
29  public:
30 
33 
35 
38  void setup (InverseFilterbank*);
39 
41  void set_scratch (float *);
42 
45  void perform (const TimeSeries* in, TimeSeries* out,
46  uint64_t npart, uint64_t in_step=0, uint64_t out_step=0);
47 
48  void perform (const TimeSeries * in,
49  TimeSeries * out,
50  TimeSeries* zero_DM_out,
51  uint64_t npart,
52  const uint64_t in_step=0,
53  const uint64_t out_step=0);
54 
57  void finish ();
58 
59  protected:
60 
62  bool real_to_complex;
63 
65  bool dual_sideband;
66 
68  bool verbose;
69 
71  Response* response;
72 
75 
80 
82  unsigned input_npol;
83 
85  unsigned input_nchan;
87  unsigned output_nchan;
88 
90  unsigned input_discard_neg;
94  unsigned input_discard_total;
95 
99  unsigned output_discard_pos;
101  unsigned output_discard_total;
102 
106  unsigned output_fft_length;
107 
110 
112  unsigned output_sample_step;
113 
115  unsigned input_os_keep;
117  unsigned input_os_discard;
118 
119 
121  bool fft_plans_setup;
122 
126 
130  bool pfb_all_chan;
131 
133  unsigned pfb_nchan;
134 
135  const TimeSeries* input;
136  TimeSeries* output;
137  TimeSeries* zero_DM_out;
138 
140  unsigned coarse_channels;
141 
143 
145 
147 
149 
151 
153 
155 
157 
159  unsigned spectral_steps;
160 
163 
165  void stitch (float* dest, unsigned ipol, unsigned fine_channel_offset, uint64_t input_offset_nfloat, bool shift_by_half_chan);
166  void stitch_one (float* dest, unsigned ipol, unsigned chan_offset, uint64_t input_offset_nfloat, bool shift_by_half_chan);
167 
169  void filter (float* spectrum, unsigned ipol, unsigned chan_offset);
170 
172  void invert (float* spectrum, unsigned ipol, unsigned chan_offset, uint64_t output_offset_nfloat);
173 
174  void build_fine_channel_plan ();
175  std::vector<unsigned> fine_channel_plan;
176  unsigned matlab_fine_channel_plan (unsigned jchan);
177 
178  private:
179 
180 
182  float* scratch;
183 
185  FTransform::Plan* forward;
186 
188  FTransform::Plan* backward;
189 
191  float* input_fft_scratch;
192 
194  unsigned input_fft_scratch_nfloat;
195 
197  float* input_time_scratch;
198 
200  unsigned input_time_scratch_nfloat;
201 
203  float* output_fft_scratch;
204 
206  unsigned output_fft_scratch_nfloat;
207 
210  float* stitch_scratch;
211 
213  unsigned stitch_scratch_nfloat;
214 
215  float* stitch_scratch_zero_DM;
216  };
217 
218 }
219 
220 #endif
const In * get_input() const
Return pointer to the container from which input data will be read.
Definition: HasInput.h:41
bool real_to_complex
Complex-valued data.
Definition: InverseFilterbankEngineCPU.h:72
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
unsigned input_discard_neg
The number of samples discarded at the end of an input TimeSeries. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:100
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
unsigned spectral_steps
Number of steps across all of the input (fine) channels. *‍/.
Definition: InverseFilterbankEngineCPU.h:169
const Rational & get_oversampling_factor()
Get oversampling_factor.
Definition: InverseFilterbank.h:149
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
void perform(const TimeSeries *in, TimeSeries *out, uint64_t npart, uint64_t in_step=0, uint64_t out_step=0)
Operate on input and output data TimeSeries, performing the PFB inversion algorithm.
Definition: InverseFilterbankEngineCPU.C:712
unsigned get_ndim() const
Return the dimension of each datum.
Definition: Observation.h:80
unsigned output_channels_per_spectral_step
Number of output channels per spectral step.
Definition: InverseFilterbankEngineCPU.h:172
unsigned coarse_channels_per_output_channel
Number of coarse channels per output channel.
Definition: InverseFilterbankEngineCPU.h:162
int get_input_discard_pos() const
Get the number of samples discarded at the start of an input step.
Definition: InverseFilterbank.h:164
Apodization * spectral_apodization
Taper applied before backward FFT.
Definition: InverseFilterbankEngineCPU.h:89
Chooses the optimal FFT length for Filterbank and/or Convolution.
Definition: OptimalFFT.h:24
Performs the PFB inversion synthesis operation.
Definition: InverseFilterbank.h:82
unsigned fine_channels_per_output_channel
Number of fine channels per output channel.
Definition: InverseFilterbankEngineCPU.h:158
float * get_datptr(unsigned ichan=0, unsigned ipol=0)
Return pointer to the specified data block.
Definition: TimeSeries.C:304
Describes a frequency (or impulse) response.
Definition: Response.h:34
unsigned output_discard_pos
The number of samples discarded at the start of an output TimeSeries. From the parent InverseFilterba...
Definition: InverseFilterbankEngineCPU.h:109
unsigned fine_channels_per_coarse_channel
Number of fine channels per coarse channel.
Definition: InverseFilterbankEngineCPU.h:154
unsigned input_sample_step
The number samples in an input TimeSeries step, or segment. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:119
void setup(InverseFilterbank *)
Use the parent InverseFilterbank object to set properties used in the perform member function.
Definition: InverseFilterbankEngineCPU.C:52
virtual const Apodization * get_temporal_apodization() const
Return a pointer to to the temporal apodization object.
Definition: Convolution.C:115
uint64_t get_ndat() const
Return the number of time samples in container.
Definition: Observation.h:107
unsigned output_discard_total
The total number of samples discarded ain an input TimeSeries. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:111
int get_input_fft_length() const
Get the size of the forward fft, in number of samples.
Definition: InverseFilterbank.h:182
unsigned input_fft_length
The number of samples in the forward FFT.
Definition: InverseFilterbankEngineCPU.h:114
unsigned output_channels_per_coarse_channel
Number of output channels per coarse channel.
Definition: InverseFilterbankEngineCPU.h:166
virtual const Response * get_response() const
Return a pointer to the frequency response function.
Definition: Convolution.C:90
void set_scratch(float *)
Setup scratch space used in the perform member function.
Definition: InverseFilterbankEngineCPU.C:214
unsigned get_npol() const
Return the number of polarizations.
Definition: Observation.h:90
bool verbose
verbosity flag
Definition: InverseFilterbankEngineCPU.h:78
bool pfb_dc_chan
This flag indicates whether we have the DC, or zeroth PFB channel.
Definition: InverseFilterbankEngineCPU.h:135
unsigned input_discard_total
The total number of samples discarded in an input TimeSeries. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:104
void filter(float *spectrum, unsigned ipol, unsigned chan_offset)
Definition: InverseFilterbankEngineCPU.C:600
void stitch(float *dest, unsigned ipol, unsigned fine_channel_offset, uint64_t input_offset_nfloat, bool shift_by_half_chan)
Definition: InverseFilterbankEngineCPU.C:456
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
unsigned output_sample_step
The number samples in an output TimeSeries step, or segment. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:122
Apodization * temporal_apodization
Taper applied before forward FFT.
Definition: InverseFilterbankEngineCPU.h:87
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
Response * zero_DM_response
zero DM response
Definition: InverseFilterbankEngineCPU.h:84
unsigned coarse_channels
Number of coarse channels spanned by input data.
Definition: InverseFilterbankEngineCPU.h:150
bool has_temporal_apodization() const
Return true if the temporal apodization attribute has been set.
Definition: Convolution.C:126
Response * response
A response object that gets multiplied by assembled spectrum.
Definition: InverseFilterbankEngineCPU.h:81
static bool verbose
Global verbosity flag.
Definition: Operation.h:48
bool dual_sideband
Frequencies are ordered with fft[0]=DC, +ve, fft[N/2]=+/-Nyquist, -ve.
Definition: InverseFilterbankEngineCPU.h:75
unsigned input_os_keep
How much of the forward FFT to keep due to oversampling.
Definition: InverseFilterbankEngineCPU.h:125
void finish()
Called when the the InverseFilterbank sees that the engine is done operating on data.
Definition: InverseFilterbankEngineCPU.C:723
unsigned output_discard_neg
The number of samples discarded at the end of an output TimeSeries. From the parent InverseFilterbank...
Definition: InverseFilterbankEngineCPU.h:107
virtual std::string get_library(unsigned nfft)
Get the name of the FFT library to use for the given FFT length.
Definition: OptimalFFT.C:136
unsigned input_os_discard
How much of the forward FFT to discard due to oversampling.
Definition: InverseFilterbankEngineCPU.h:127
unsigned output_nchan
The number of output channels. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:97
Signal::Source get_type() const
Return the source type.
Definition: Observation.h:75
bool fft_plans_setup
Flag indicating whether FFT plans have been setup.
Definition: InverseFilterbankEngineCPU.h:131
unsigned input_nchan
The number of input channels. From the parent InverseFilterbank.
Definition: InverseFilterbankEngineCPU.h:95
virtual const Response * get_zero_DM_response() const
Return a pointer to the zero DM frequency response function.
Definition: Convolution.C:188
virtual Out * get_output() const
Return pointer to the container into which output data will be written.
Definition: HasOutput.h:41
unsigned input_discard_pos
The number of samples discarded at the start of an input TimeSeries. From the parent InverseFilterban...
Definition: InverseFilterbankEngineCPU.h:102
unsigned input_npol
the number of input polarizations
Definition: InverseFilterbankEngineCPU.h:92
Various apodizing (window) functions.
Definition: Apodization.h:28
void invert(float *spectrum, unsigned ipol, unsigned chan_offset, uint64_t output_offset_nfloat)
Definition: InverseFilterbankEngineCPU.C:677
bool get_zero_DM() const
get the zero_DM flag
Definition: Convolution.h:155
void set_library(const std::string &name)
static Reference::To< Agent > current
unsigned output_fft_length
The number of samples in the backward FFT.
Definition: InverseFilterbankEngineCPU.h:116
InverseFilterbankEngineCPU()
Default Constructor.
Definition: InverseFilterbankEngineCPU.C:32
bool has_response() const
Return true if the response attribute has been set.
Definition: Convolution.C:85
bool pfb_all_chan
This flag indicates whether we have all the channels from the last stage of upstream channelization.
Definition: InverseFilterbankEngineCPU.h:140
unsigned pfb_nchan
The number of channels output by the analysis filter bank (per input channel)
Definition: InverseFilterbankEngineCPU.h:143
bool has_spectral_apodization() const
Return true if the spectral apodization attribute has been set.
Definition: Convolution.C:146
virtual const Apodization * get_spectral_apodization() const
Return a pointer to to the spectral apodization object.
Definition: Convolution.C:136
unsigned get_nchan() const
Return the number of channels into which the band is divided.
Definition: Observation.h:85

Generated using doxygen 1.8.17