TimeSeries.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/TimeSeries.h
10 
11 #ifndef __TimeSeries_h
12 #define __TimeSeries_h
13 
14 #include <memory>
15 
16 #include "Error.h"
17 #include "environ.h"
18 
19 #include "dsp/DataSeries.h"
20 
21 namespace dsp {
22 
24  class TimeSeries : public DataSeries
25  {
26  public:
27 
29  enum Order {
30 
32  OrderFPT,
33 
35  OrderTFP
36 
37  };
38 
40  static bool auto_delete;
41 
43  TimeSeries ();
44 
46  TimeSeries(const TimeSeries& ts);
47 
49  virtual TimeSeries* clone() const;
50 
52  virtual TimeSeries* null_clone() const;
53 
55  virtual TimeSeries& swap_data (DataSeries& ts);
56 
58  virtual TimeSeries& swap_data (TimeSeries& ts);
59 
61  virtual ~TimeSeries();
62 
64  virtual TimeSeries& operator = (const TimeSeries& copy);
65 
67  void copy (const Observation*);
68 
70  void copy (const DataSeries*);
71 
73  virtual void copy(const TimeSeries* ts)
74  { operator=( *ts ); }
75 
77  virtual TimeSeries& operator += (const TimeSeries& data);
78 
80  virtual TimeSeries& operator *= (float mult);
81 
83  Order get_order () const;
84 
86  void set_order (Order order);
87 
90  virtual void copy_configuration (const Observation* copy);
91 
93  virtual void copy_data (const TimeSeries* data,
94  uint64_t idat_start = 0, uint64_t ndat = 0);
95 
97  virtual void internal_match (const TimeSeries*);
98 
100  virtual void internal_match (const DataSeries*);
101 
103  virtual void set_nbit (unsigned);
104 
106  virtual void resize (uint64_t nsamples);
107 
109  virtual void decrease_ndat (uint64_t new_ndat);
110 
112  TimeSeries& use_data(float* _buffer, uint64_t _ndat);
113 
115  float* get_datptr (unsigned ichan=0, unsigned ipol=0);
116 
118  const float* get_datptr (unsigned ichan=0, unsigned ipol=0) const;
119 
121  float* get_dattfp ();
122 
124  const float* get_dattfp () const;
125 
127  virtual void seek (int64_t offset);
128 
131  void prepend (const dsp::TimeSeries*, uint64_t pre_ndat = 0);
132 
134  int64_t get_input_sample () const { return input_sample; }
135 
137  void set_input_sample (uint64_t sample) { input_sample = sample; }
138 
140  uint64_t get_nfloat_span () const;
141 
143  double mean (unsigned ichan, unsigned ipol);
144 
146  virtual void check (float min=-10.0, float max=10.0);
147 
149  void set_zeroed_data (bool _zeroed_data) { zeroed_data = _zeroed_data; }
150 
152  bool get_zeroed_data () const { return zeroed_data; }
153 
154  void finite_check () const;
155 
156  void set_match (TimeSeries*);
157 
158  class Engine;
159 
160  void set_engine (Engine*);
161 
162  Engine * get_engine () const { return engine; };
163 
164  unsigned get_stride () const;
165 
166  protected:
167 
169  virtual unsigned char* get_data();
171  virtual const unsigned char* get_data() const;
172 
173  virtual void prepend_checks (const TimeSeries*, uint64_t pre_ndat);
174 
176  float* data;
177 
179  void change_reserve (int64_t change) const;
180 
182  uint64_t get_reserve () const { return reserve_ndat; }
183 
185  bool zeroed_data;
186 
187  friend class Reserve;
188  friend class Unpacker;
189 
190  // do the work of the null_clone: copy necessary attributes from the given TimeSeries
191  void null_work (const TimeSeries* from);
192 
193  Reference::To<Engine> engine;
194 
195  private:
196 
198  Order order;
199 
201  uint64_t reserve_ndat;
202 
204  uint64_t reserve_nfloat;
205 
208 
210 
211  int64_t input_sample;
212 
214  void init ();
215 
216 
217  };
218 
219  class TimeSeries::Engine : public OwnStream
220  {
221  public:
222 
223  virtual void prepare (dsp::TimeSeries * to) = 0;
224 
225  virtual void prepare_buffer (unsigned nbytes) = 0;
226 
227  virtual void copy_data_fpt (const dsp::TimeSeries * copy,
228  uint64_t idat_start = 0,
229  uint64_t ndat = 0) = 0;
230 
231  };
232 
233 }
234 
235 #endif
virtual void internal_match(const TimeSeries *)
Match the internal memory layout of another TimeSeries.
Definition: TimeSeries.C:379
virtual void set_ndat(uint64_t _ndat)
Set the number of time samples in container.
Definition: Observation.h:105
virtual void set_nbit(unsigned _nbit)
Set the number of bits per value.
Definition: Observation.h:93
const Observation & operator=(const Observation &)
Assignment operator.
Definition: Observation.C:404
virtual DataSeries & operator=(const DataSeries &copy)
Set this equal to copy.
Definition: DataSeries.C:341
unsigned char * buffer
The data buffer.
Definition: DataSeries.h:147
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
unsigned get_ndim() const
Return the dimension of each datum.
Definition: Observation.h:80
void set_input_sample(uint64_t sample)
Used to arrange pieces in order during input buffering.
Definition: TimeSeries.h:147
virtual void check(float min=-10.0, float max=10.0)
Check that each floating point value is roughly as expected.
Definition: TimeSeries.C:657
Order
Order of the dimensions.
Definition: TimeSeries.h:39
TimeSeries & use_data(float *_buffer, uint64_t _ndat)
For nchan=1, npol=1 data this uses the data in 'buffer'.
Definition: TimeSeries.C:110
float * get_datptr(unsigned ichan=0, unsigned ipol=0)
Return pointer to the specified data block.
Definition: TimeSeries.C:304
virtual TimeSeries & operator*=(float mult)
Multiple each value by this scalar.
Definition: TimeSeries.C:452
uint64_t get_ndat() const
Return the number of time samples in container.
Definition: Observation.h:107
virtual TimeSeries & operator+=(const TimeSeries &data)
Add each value in data to this.
Definition: TimeSeries.C:410
virtual DataSeries & swap_data(DataSeries &ds)
Swaps the two DataSeries's. Returns '*this'.
Definition: DataSeries.C:367
virtual TimeSeries * null_clone() const
Returns a null-instantiation (calls new)
Definition: TimeSeries.C:62
bool zeroed_data
Flag for whether the data contains zero values. See ZapWeight.
Definition: TimeSeries.h:195
void prepend(const dsp::TimeSeries *, uint64_t pre_ndat=0)
Append the given TimeSeries to the end of 'this' Copy data from given TimeSeries in front of the curr...
Definition: TimeSeries.C:484
unsigned get_npol() const
Return the number of polarizations.
Definition: Observation.h:90
void change_reserve(int64_t change) const
Change the amount of memory reserved at the start of the buffer.
Definition: TimeSeries.C:700
Reference::To< Memory > memory
The memory manager.
Definition: DataSeries.h:159
static bool auto_delete
Automatically delete arrays on resize(0)
Definition: TimeSeries.h:50
Stores information about digital, band-limited, time-varying signals.
Definition: Observation.h:33
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
virtual void resize(uint64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: DataSeries.C:121
virtual void internal_match(const DataSeries *)
Match the internal memory layout of another DataSeries.
Definition: DataSeries.C:383
int64_t get_input_sample() const
Return the sample offset from the start of the data source.
Definition: TimeSeries.h:144
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
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
virtual void decrease_ndat(uint64_t new_ndat)
Decrease the array lengths without changing the base pointers.
Definition: TimeSeries.C:194
TimeSeries()
Null constructor.
Definition: TimeSeries.C:32
void copy(const Observation *ds)
Same as operator= but takes a pointer.
Definition: DataSeries.C:331
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
Abstract base class of Transformations that convert n-bit to float.
Definition: Unpacker.h:42
virtual unsigned char * get_data()
Returns a uchar pointer to the first piece of data.
Definition: TimeSeries.C:279
virtual TimeSeries * clone() const
Clone operator.
Definition: TimeSeries.C:57
virtual void resize(uint64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: TimeSeries.C:146
double mean(unsigned ichan, unsigned ipol)
Return the mean of the data for the specified channel and poln.
Definition: TimeSeries.C:349
uint64_t get_nfloat_span() const
Get the span (number of floats)
Definition: TimeSeries.C:344
virtual void set_nbit(unsigned)
Disable the set_nbit method of the Observation base class.
Definition: TimeSeries.C:103
void set_zeroed_data(bool _zeroed_data)
Set the zeroed data flag.
Definition: TimeSeries.h:159
Remembers how much has been reserved and increases it if necessary.
Definition: Reserve.h:25
Container of dimension/time-major order floating point data.
Definition: DataSeries.h:36
uint64_t get_reserve() const
Get the amount of memory reserved at the start of the buffer.
Definition: TimeSeries.h:192
virtual ~TimeSeries()
Destructor.
Definition: TimeSeries.C:87
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
float * get_dattfp()
Return pointer to the specified data block.
Definition: TimeSeries.C:325
virtual TimeSeries & swap_data(DataSeries &ts)
Swaps the two TimeSeries if DataSeries is a TimeSeries. Returns '*this'.
Definition: TimeSeries.C:638
virtual void seek(int64_t offset)
Offset the base pointer by offset time samples.
Definition: TimeSeries.C:234
@ OrderFPT
Frequency, Polarization, Time (default before 3 October 2008)
Definition: TimeSeries.h:47
@ OrderTFP
Time, Frequency, Polarization (better for many things)
Definition: TimeSeries.h:50
Order get_order() const
Get the order.
Definition: TimeSeries.C:92
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