DP3
Averager.h
Go to the documentation of this file.
1 // Averager.h: DP3 step class to average in time and/or freq
2 // Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 
8 
9 #ifndef DP3_STEPS_AVERAGER_H_
10 #define DP3_STEPS_AVERAGER_H_
11 
12 #include <memory>
13 
14 #include <xtensor/containers/xtensor.hpp>
15 #include <aocommon/staticfor.h>
16 
17 #include "base/DPBuffer.h"
18 #include "steps/Step.h"
19 #include "common/Timer.h"
20 
21 namespace dp3 {
22 
23 namespace common {
24 class ParameterSet;
25 }
26 
27 namespace steps {
28 
30 
38 
39 class Averager : public Step {
40  public:
45 
48  Averager(const common::ParameterSet&, const std::string& prefix);
49 
51  Averager(const std::string& stepname, unsigned int nchanAvg,
52  unsigned int ntimeAvg);
53  Averager(const std::string& stepname, double freq_resolution,
54  double time_resolution);
55 
56  ~Averager() override;
57 
58  common::Fields getRequiredFields() const override { return kRequiredFields; }
59 
60  common::Fields getProvidedFields() const override { return kProvidedFields; }
61 
65  bool process(std::unique_ptr<base::DPBuffer> buffer) override;
66 
68  void finish() override;
69 
71  void updateInfo(const base::DPInfo&) override;
72 
74  void show(std::ostream&) const override;
75 
77  void showTimings(std::ostream&, double duration) const override;
78 
81  static double getFreqHz(const std::string& freqstr);
82 
83  private:
85  void average();
86 
87  std::string itsName;
88  std::unique_ptr<base::DPBuffer> itsBuf;
89  xt::xtensor<int, 3> itsNPoints;
90  xt::xtensor<std::complex<float>, 3> itsAvgAll;
91  xt::xtensor<float, 3> itsWeightAll;
92  double itsFreqResolution;
93  double itsTimeResolution;
94  unsigned int itsNChanAvg;
95  unsigned int itsNTimeAvg;
96  unsigned int itsMinNPoint;
97  float itsMinPerc;
98  unsigned int itsNTimes;
99  double itsOriginalTimeInterval;
100  bool itsNoAvg;
101  common::NSTimer itsTimer;
102 };
103 
104 } // namespace steps
105 } // namespace dp3
106 
107 #endif
Buffer holding the data of a timeslot/band.
Class to hold code for virtual base class for Flaggers in DP3.
General info about DP3 data processing attributes like averaging.
Definition: DPInfo.h:35
Definition: Fields.h:16
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
DP3 step class to average in time and/or freq.
Definition: Averager.h:39
Averager(const common::ParameterSet &, const std::string &prefix)
void updateInfo(const base::DPInfo &) override
Update the general info.
static const common::Fields kProvidedFields
Definition: Averager.h:44
Averager(const std::string &stepname, unsigned int nchanAvg, unsigned int ntimeAvg)
Construct the object using the given parameters.
void showTimings(std::ostream &, double duration) const override
Show the timings.
static double getFreqHz(const std::string &freqstr)
void show(std::ostream &) const override
Show the step parameters.
bool process(std::unique_ptr< base::DPBuffer > buffer) override
static const common::Fields kRequiredFields
Definition: Averager.h:43
common::Fields getProvidedFields() const override
Definition: Averager.h:60
Averager(const std::string &stepname, double freq_resolution, double time_resolution)
void finish() override
Finish the processing of this step and subsequent steps.
common::Fields getRequiredFields() const override
Get the fields required by the current step.
Definition: Averager.h:58
Abstract base class for a DP3 step.
Definition: Step.h:52
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53