Rescale.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2006-2024 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/General/dsp/Rescale.h
10 
11 #ifndef __dsp_Rescale_h
12 #define __dsp_Rescale_h
13 
14 #include "dsp/Transformation.h"
15 #include "dsp/TimeSeries.h"
16 
17 #include <vector>
18 
19 namespace dsp
20 {
24  class Rescale : public Transformation<TimeSeries,TimeSeries>
25  {
26 
27  public:
28 
30  Rescale ();
31 
33  ~Rescale () = default;
34 
35  void prepare ();
36 
38  void transformation ();
39 
41  void set_interval_seconds (double seconds);
42 
44  void set_interval_samples (uint64_t samples);
45 
47  void set_exact (bool exact);
48 
50  void set_constant (bool constant_offset_scale);
51 
53  void set_decay (float decay_constant);
54 
56  void set_output_after_interval (bool output_after_interval);
57 
59  void set_output_time_total (bool output_time_total);
60 
62  MJD get_update_epoch () const;
63 
65  const float* get_offset (unsigned ipol) const;
66 
68  const float* get_scale (unsigned ipol) const;
69 
76  const double* get_mean (unsigned ipol) const;
77 
84  const double* get_variance (unsigned ipol) const;
85 
87  uint64_t get_nsample () const;
88 
90  const float* get_time (unsigned ipol) const;
91 
92  private:
93 
95  std::vector< std::vector<double> > freq_total;
96 
98  std::vector< std::vector<double> > freq_totalsq;
99 
101  std::vector< std::vector<float> > time_total;
102 
104  std::vector< std::vector<float> > scale;
105 
107  std::vector< std::vector<float> > offset;
108 
110  std::vector< std::vector<float> > decay_offset;
111 
113  bool exact{false};
114 
116  bool output_time_total{false};
117 
119  bool output_after_interval{false};
120 
122  double interval_seconds{0.0};
123 
125  uint64_t interval_samples{0};
126 
128  float decay_constant{1e4};
129 
131  bool do_decay{false};
132 
134  uint64_t nsample{0};
135 
137  uint64_t isample{0};
138 
139  MJD update_epoch{};
140 
142  bool constant_offset_scale{false};
143 
145  bool first_integration{false};
146 
148  void init ();
149 
151  void compute_various (bool first_call = false, bool first_integration = false);
152  };
153 
154 } // namespace dsp
155 
156 #endif // __dsp_Rescale_h
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
Defines the interface by which Transformations are performed on data.
Definition: Transformation.h:54
void set_output_after_interval(bool output_after_interval)
Do not output any data before the first integration interval has passed.
Definition: Rescale.C:20
const double * get_mean(unsigned ipol) const
Get the spectrum of integrated input values for the given polarization.
Definition: Rescale.C:443
void set_interval_seconds(double seconds)
Set the rescaling interval in seconds.
Definition: Rescale.C:41
Buffers the Transformation input.
Definition: InputBuffering.h:26
void set_interval_samples(uint64_t samples)
Set the rescaling interval in samples.
Definition: Rescale.C:46
void transformation()
Rescale to zero mean and unit variance.
Definition: Rescale.C:141
const float * get_time(unsigned ipol) const
Get the total power time series for the given polarization.
Definition: Rescale.C:460
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
void set_decay(float decay_constant)
Subtract an exponential smooth with specified decay constant.
Definition: Rescale.C:35
const float * get_scale(unsigned ipol) const
Get the spectrum of scales for the given polarization.
Definition: Rescale.C:437
const double * get_variance(unsigned ipol) const
Get the spectrum in integrated squared input values for the given polarization.
Definition: Rescale.C:449
void set_exact(bool exact)
If exact, only allow set_interval_samples through each iteration.
Definition: Rescale.C:51
~Rescale()=default
Destructor.
void set_output_time_total(bool output_time_total)
Maintain fscrunched total that can be output.
Definition: Rescale.C:25
Rescale()
Default constructor.
Definition: Rescale.C:15
void set_constant(bool constant_offset_scale)
After setting offset and scale, keep them constant.
Definition: Rescale.C:30
const float * get_offset(unsigned ipol) const
Get the spectrum of offsets for the given polarization.
Definition: Rescale.C:431
MJD get_update_epoch() const
Get the epoch of the last scale/offset update.
Definition: Rescale.C:426
uint64_t get_nsample() const
Get the number of samples between updates.
Definition: Rescale.C:455
void prepare()
Prepare for data operations.
Definition: Rescale.C:137
@ 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

Generated using doxygen 1.8.17