WeightedTimeSeries.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Kernel/Classes/dsp/WeightedTimeSeries.h
10 
11 #ifndef __WeightedTimeSeries_h
12 #define __WeightedTimeSeries_h
13 
14 #include "dsp/TimeSeries.h"
15 
16 namespace dsp {
17 
19  /* The WeightedTimeSeries class contains floating point data that
20  may be flagged as bad in the time domain. */
21  class WeightedTimeSeries : public TimeSeries {
22 
23  public:
24 
27 
30 
33 
36 
38 
39  void set_ndat_per_weight (unsigned ndat_per_weight);
40 
42  unsigned get_ndat_per_weight () const { return ndat_per_weight; }
43 
45  void set_npol_weight (unsigned npol_weight);
46 
48  unsigned get_npol_weight () const { return npol_weight; }
49 
51  void set_nchan_weight (unsigned nchan_weight);
52 
54  unsigned get_nchan_weight () const { return nchan_weight; }
55 
57  virtual WeightedTimeSeries* clone() const;
58 
60  virtual WeightedTimeSeries* null_clone() const;
61 
63  void set_reserve_kludge_factor (unsigned);
64 
66  virtual void copy_configuration (const Observation* copy);
67 
69  virtual void copy_data (const TimeSeries* data,
70  uint64_t idat_start = 0, uint64_t ndat = 0);
71 
73  virtual void resize (uint64_t nsamples);
74 
76  virtual void seek (int64_t offset);
77 
79  virtual void zero ();
80 
82  void copy_weights (const Observation* copy);
83 
85  void mask_weights ();
86 
88  void check_weights ();
89 
91  void neutral_weights ();
92 
94  uint64_t get_nweights () const;
95 
97  uint64_t get_nweights (uint64_t nsample) const;
98 
100  void set_weight_idat (uint64_t weight_idat);
101 
103  uint64_t get_weight_idat () const { return weight_idat; }
104 
106  uint64_t get_nzero () const;
107 
109  unsigned* get_weights (unsigned ichan=0, unsigned ipol=0);
110 
112  const unsigned* get_weights (unsigned ichan=0, unsigned ipol=0) const;
113 
115  void convolve_weights (unsigned nfft, unsigned nkeep);
116 
118  void scrunch_weights (unsigned nscrunch);
119 
120  protected:
121 
123  unsigned npol_weight = 1;
124 
126  unsigned nchan_weight = 1;
127 
129  unsigned ndat_per_weight = 0;
130 
132  unsigned reserve_kludge_factor = 1;
133 
135  void copy_weights (const WeightedTimeSeries* copy,
136  uint64_t idat_start = 0, uint64_t copy_ndat = 0);
137 
139  void resize_weights (uint64_t nsamples);
140 
142  uint64_t have_nweights () const;
143 
144  void prepend_checks (const TimeSeries*, uint64_t pre_ndat);
145 
146  private:
147 
149  unsigned* base = nullptr;
150 
152  unsigned* weights = nullptr;
153 
155  uint64_t weight_idat = 0;
156 
158  uint64_t weight_size = 0;
159 
161  uint64_t weight_subsize = 0;
162  };
163 
164 }
165 
166 #endif
167 
virtual void copy_configuration(const Observation *copy)
Copy the configuration of another WeightedTimeSeries instance.
Definition: WeightedTimeSeries.C:31
unsigned get_npol_weight() const
Get the number of polarizations with independent weights.
Definition: WeightedTimeSeries.h:58
void scrunch_weights(unsigned nscrunch)
Scrunch the weights.
Definition: WeightedTimeSeries.C:698
unsigned reserve_kludge_factor
The reserve kludge factor is required by the Filterbank.
Definition: WeightedTimeSeries.h:142
unsigned ndat_per_weight
The number of time samples per weight.
Definition: WeightedTimeSeries.h:139
uint64_t get_nzero() const
Get the number of zero weights in the ichan == ipol == 0 array.
Definition: WeightedTimeSeries.C:512
virtual void resize(uint64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: WeightedTimeSeries.C:200
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
float * data
Pointer into buffer, offset to the first time sample requested by user.
Definition: TimeSeries.h:186
static bool verbose
Verbosity flag.
Definition: Observation.h:39
void neutral_weights()
Set all weights to one.
Definition: WeightedTimeSeries.C:500
unsigned nchan_weight
Number of frequency channels with independent weights.
Definition: WeightedTimeSeries.h:136
virtual WeightedTimeSeries & operator+=(const WeightedTimeSeries &data)
Add each value in data to this.
Definition: WeightedTimeSeries.C:460
uint64_t have_nweights() const
Get the number of weights possible given allocated space.
Definition: WeightedTimeSeries.C:143
uint64_t get_ndat() const
Return the number of time samples in container.
Definition: Observation.h:107
void check_weights()
Check that each floating point value is zeroed if weight is zero.
Definition: WeightedTimeSeries.C:494
virtual WeightedTimeSeries & operator=(const WeightedTimeSeries &copy)
Set this equal to copy.
Definition: WeightedTimeSeries.C:347
virtual TimeSeries & operator+=(const TimeSeries &data)
Add each value in data to this.
Definition: TimeSeries.C:410
unsigned npol_weight
Number of polarizations with independent weights.
Definition: WeightedTimeSeries.h:133
unsigned * get_weights(unsigned ichan=0, unsigned ipol=0)
Get the weights array for the specfied polarization and frequency.
Definition: WeightedTimeSeries.C:330
Container of weighted time-major order floating point data.
Definition: WeightedTimeSeries.h:26
Stores information about digital, band-limited, time-varying signals.
Definition: Observation.h:33
virtual void copy_data(const TimeSeries *data, uint64_t idat_start=0, uint64_t ndat=0)
Copy the data of another WeightedTimeSeries instance.
Definition: WeightedTimeSeries.C:68
virtual void zero()
Set all values to zero.
Definition: DataSeries.C:251
virtual TimeSeries & operator=(const TimeSeries &copy)
Set this equal to copy.
Definition: TimeSeries.C:225
void copy(const Observation *)
Call TimeSeries::copy if Observation is a TimeSeries.
Definition: TimeSeries.C:207
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
uint64_t get_nweights() const
Get the number of weights.
Definition: WeightedTimeSeries.C:119
virtual void copy_configuration(const Observation *copy)
Copy the configuration of another TimeSeries instance (not the data) This doesn't copy nchan,...
Definition: TimeSeries.C:396
unsigned get_ndat_per_weight() const
Get the number of time samples per weight.
Definition: WeightedTimeSeries.h:52
void set_reserve_kludge_factor(unsigned)
Set the reserve kludge factor.
Definition: WeightedTimeSeries.C:273
void mask_weights()
For each zero weight, sets all weights to zero.
Definition: WeightedTimeSeries.C:534
void copy_weights(const Observation *copy)
Maybe copy the weights from copy.
Definition: WeightedTimeSeries.C:37
virtual void zero()
Set all values to zero.
Definition: WeightedTimeSeries.C:487
virtual void copy_data(const TimeSeries *data, uint64_t idat_start=0, uint64_t ndat=0)
Copy the data of another TimeSeries instance.
Definition: TimeSeries.C:506
void convolve_weights(unsigned nfft, unsigned nkeep)
Flag all weights in corrupted transforms.
Definition: WeightedTimeSeries.C:577
WeightedTimeSeries()
Default constructor.
Definition: WeightedTimeSeries.C:20
virtual void resize(uint64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: TimeSeries.C:146
void set_npol_weight(unsigned npol_weight)
Set the number of polarizations with independent weights.
Definition: WeightedTimeSeries.C:107
virtual WeightedTimeSeries * null_clone() const
Returns a null-instantiation (calls new)
Definition: WeightedTimeSeries.C:177
unsigned get_nchan_weight() const
Get the number of frequency channels with independent weights.
Definition: WeightedTimeSeries.h:64
void set_weight_idat(uint64_t weight_idat)
Set the offset of the first time sample in the current weight array.
Definition: WeightedTimeSeries.C:166
virtual void seek(int64_t offset)
Offset the base pointer by offset time samples.
Definition: WeightedTimeSeries.C:279
virtual WeightedTimeSeries * clone() const
Cloner (calls new)
Definition: WeightedTimeSeries.C:172
void set_nchan_weight(unsigned nchan_weight)
Set the number of frequency channels with independent weights.
Definition: WeightedTimeSeries.C:113
uint64_t get_weight_idat() const
Get the offset into the current weight of the first time sample.
Definition: WeightedTimeSeries.h:113
void set_ndat_per_weight(unsigned ndat_per_weight)
Set the number of time samples per weight.
Definition: WeightedTimeSeries.C:101
void resize_weights(uint64_t nsamples)
Resize the weights array.
Definition: WeightedTimeSeries.C:209
virtual void seek(int64_t offset)
Offset the base pointer by offset time samples.
Definition: TimeSeries.C:234

Generated using doxygen 1.8.17