CyclicFold.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2011 by Paul Demorest
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __baseband_dsp_CyclicFold_h
10 #define __baseband_dsp_CyclicFold_h
11 
12 #include "dsp/Transformation.h"
13 #include "dsp/TimeSeries.h"
14 #include "dsp/PhaseSeries.h"
15 #include "dsp/Fold.h"
16 #include "FTransformAgent.h"
17 #include "dsp/Apodization.h"
18 
19 namespace dsp {
20 
22 
38  class CyclicFold : public Fold {
39 
40  /* TODO:
41  * Need to figure out how to overlap input by nlag points...
42  */
43 
44  public:
45 
47  CyclicFold ();
48 
50  ~CyclicFold ();
51 
53  virtual void prepare ();
54 
55  void set_engine(Engine*);
56 
58  void set_nlag(unsigned _nlag) { nlag = _nlag; }
60  unsigned get_nlag() const { return nlag; }
61 
63  void set_mover(unsigned _mover) { mover = _mover; }
65  unsigned get_mover() const { return mover; }
66 
68  void set_nchan(unsigned nchan) { set_nlag(mover*nchan/2 + 1); }
69 
71  void set_npol(unsigned _npol) { npol = _npol; }
73  unsigned get_npol() const { return npol; }
74 
75  protected:
76 
78  virtual void check_input();
79 
81  virtual void prepare_output();
82 
84  virtual void setup_engine();
85 
87  unsigned nlag;
88 
90  unsigned mover;
91 
93  unsigned npol;
94 
95  };
96 
98 
101  class CyclicFoldEngine : public Fold::Engine
102  {
103  public:
104 
107 
109  virtual void set_nlag (unsigned _nlag);
110 
112  virtual void set_mover (unsigned _mover);
113 
115  virtual void set_nbin (unsigned _nbin) { nbin = _nbin; }
116 
118  virtual void set_npol (unsigned _npol) { npol_out = _npol; }
119 
121  virtual void set_bin (uint64_t idat, double ibin, double bins_per_samp);
122 
123  uint64_t set_bins (double phi, double phase_per_sample, uint64_t ndat, uint64_t idat_start);
124 
125  uint64_t get_bin_hits (int ibin);
126 
128  virtual PhaseSeries* get_profiles ();
129 
130  void set_profiles (PhaseSeries* _out) { out = _out; }
131 
133  virtual void fold ();
134 
136  virtual void synch (PhaseSeries*);
137 
139  virtual void zero ();
140 
142  virtual void set_ndat (uint64_t ndat, uint64_t idat_start);
143 
145  uint64_t get_ndat_folded () const override;
146 
147  protected:
148 
149  // Copy of output
150  PhaseSeries* out;
151 
152  unsigned nlag;
153  unsigned mover;
154  unsigned nbin;
155  unsigned npol_out;
156 
157  uint64_t nval_folded {0};
158 
159  // Array of bins to fold into
160  unsigned* binplan[2];
161  uint64_t binplan_size;
162 
163  // Temp array to accumulate lag-domain results
164  float* lagdata {nullptr};
165  // Size of the lagdata array
166  uint64_t lagdata_size {0};
167  // Return the base address of the lag data for the specified coordinates
168  float* get_lagdata_ptr(unsigned ichan, unsigned ipol, unsigned ibin);
169 
170  // Temp array to accumulate lag-domain hits (counts of integrated samples)
171  unsigned* laghits {nullptr};
172  // Size of the laghits array
173  uint64_t laghits_size {0};
174  // Return the base address of the lag hits for the specified coordinates
175  unsigned* get_laghits_ptr(unsigned ichan, unsigned ibin);
176 
177  // FFT plan for going from lags to channels
178  FTransform::Plan* lag2chan;
179  };
180 
181 }
182 
183 #endif // !defined(__CyclicFold_h)
unsigned get_npol() const
Get the number of lags to fold.
Definition: CyclicFold.h:83
uint64_t get_ndat_folded() const override
Return the (average) number of good samples folded into result.
Definition: CyclicFold.C:540
uint64_t get_ndat_total() const
Return the total number of time samples.
Definition: PhaseSeries.C:516
virtual MJD get_end_time() const
Return the end time of the trailing edge of the last time sample.
Definition: Observation.C:521
virtual void zero()
Zero internal data.
Definition: CyclicFold.C:319
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
virtual void set_mover(unsigned _mover)
Set the amount of oversampling.
Definition: CyclicFold.C:245
void set_end_time(const MJD &mjd)
Set the end time.
Definition: PhaseSeries.h:96
Data as a function of pulse phase.
Definition: PhaseSeries.h:28
virtual void setup_engine()
Transfer current settings to engine.
Definition: CyclicFold.C:56
int get_dual_sideband() const
Return the dual-sideband.
Definition: Observation.C:93
unsigned get_nlag() const
Get the number of lags to fold.
Definition: CyclicFold.h:70
Signal::State get_state() const
Return the state of the signal.
Definition: Observation.h:70
void set_npol(unsigned _npol)
Set the number of polarizations to compute.
Definition: CyclicFold.h:81
void set_npol(unsigned)
Set the number of polarizations.
Definition: DataSeries.C:91
virtual void set_nsub_swap(unsigned _nsub)
Set the number of sub-bands that must be band swapped.
Definition: Observation.h:170
unsigned * get_hits(unsigned ichan=0)
Get the hits array for the specified ichan.
Definition: PhaseSeries.C:219
float * get_datptr(unsigned ichan=0, unsigned ipol=0)
Return pointer to the specified data block.
Definition: TimeSeries.C:304
virtual void check_input()
Check that the input state is appropriate.
Definition: CyclicFold.C:74
double get_integration_length() const
Get the number of seconds integrated.
Definition: PhaseSeries.h:87
uint64_t ndat_total
Total number of time samples passed to folding routine.
Definition: PhaseSeries.h:190
unsigned npol
Number of output polns to compute.
Definition: CyclicFold.h:103
virtual void set_npol(unsigned _npol)
Set the number of polarizations to compute.
Definition: CyclicFold.h:123
double get_rate() const
Return the sampling rate (time samples per second in Hz)
Definition: Observation.h:157
virtual void set_bin(uint64_t idat, double ibin, double bins_per_samp)
Set the phase bin into which the idat'th sample will be integrated.
Definition: CyclicFold.C:334
void set_mover(unsigned _mover)
Set the amount of oversampling to improve channel isolation.
Definition: CyclicFold.h:73
unsigned get_npol() const
Return the number of polarizations.
Definition: Observation.h:90
Interface to alternate processing engine (e.g. GPU)
Definition: Fold.h:252
void set_nchan(unsigned nchan)
Set number of channels to make.
Definition: CyclicFold.h:78
virtual void fold()
Perform the fold operation.
Definition: CyclicFold.C:410
virtual PhaseSeries * get_profiles()
Return the PhaseSeries into which data will be folded.
Definition: CyclicFold.C:353
~CyclicFold()
Destructor.
Definition: CyclicFold.C:26
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
unsigned nlag
Number of lags to compute when folding.
Definition: CyclicFold.h:97
void zero()
Reset all phase bin totals to zero.
Definition: PhaseSeries.C:268
void set_hits_nchan(unsigned _hits_nchan)
Set the number of channels in the hits array.
Definition: PhaseSeries.h:118
virtual void set_start_time(MJD _start_time)
Set the start time of the leading edge of the first time sample.
Definition: Observation.h:150
virtual void resize(int64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: PhaseSeries.C:97
virtual void prepare_output()
Prepare the output PhaseSeries.
Definition: CyclicFold.C:87
virtual void set_ndat(uint64_t ndat, uint64_t idat_start)
Enable engine to prepare any internal memory required for the plan.
Definition: CyclicFold.C:257
MJD get_end_time() const
Get the end time.
Definition: PhaseSeries.h:94
virtual void synch(PhaseSeries *)
Synchronize the folded profile.
Definition: CyclicFold.C:547
void set_ndim(unsigned)
Enforces that ndat*ndim must be an integer number of bytes.
Definition: DataSeries.C:78
virtual void set_nlag(unsigned _nlag)
Set the number of lags to fold.
Definition: CyclicFold.C:228
virtual void set_swap(bool _swap)
Set true if frequency channels are out of order (band swappped)
Definition: Observation.h:165
unsigned get_mover() const
Get the amount of oversampling.
Definition: CyclicFold.h:75
void set_nchan(unsigned)
Set the number of channels.
Definition: DataSeries.C:100
void set_nlag(unsigned _nlag)
Set the number of lags to fold.
Definition: CyclicFold.h:68
unsigned mover
Oversampling factor.
Definition: CyclicFold.h:100
CyclicFold()
Constructor.
Definition: CyclicFold.C:18
static Reference::To< Agent > current
virtual void set_nbin(unsigned _nbin)
Set the number of phase bins and initialize any other data structures.
Definition: CyclicFold.h:120
MJD get_start_time() const
Return the start time of the leading edge of the first time sample.
Definition: Observation.h:152
virtual void prepare()
Prepare for folding.
Definition: CyclicFold.C:30
bool get_swap() const
Return true if frequency channels are out of order (band swappped)
Definition: Observation.h:167
void set_order(Order order)
Set the order.
Definition: TimeSeries.C:98
bool get_zeroed_data() const
Get the zeroed data flag.
Definition: TimeSeries.h:162
virtual void set_state(Signal::State _state)
Set the state of the signal.
Definition: Observation.C:103
Order get_order() const
Get the order.
Definition: TimeSeries.C:92
unsigned get_nbin() const
Get the number of phase bins.
Definition: PhaseSeries.h:99
Engine class that actually performs the computation.
Definition: CyclicFold.h:106
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