DP3
UVWFlagger.h
Go to the documentation of this file.
1 // UVWFlagger.h: DP3 step class to flag data on UVW coordinates
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_UVWFLAGGER_H_
10 #define DP3_STEPS_UVWFLAGGER_H_
11 
12 #include "base/BdaBuffer.h"
13 #include "base/DPBuffer.h"
14 #include "base/UVWCalculator.h"
15 
16 #include "InputStep.h"
17 
18 namespace dp3 {
19 namespace common {
20 class ParameterSet;
21 class ParameterValue;
22 } // namespace common
23 
24 namespace steps {
26 
37 
38 class UVWFlagger : public Step {
39  public:
45  UVWFlagger(const common::ParameterSet&, const std::string& prefix,
46  MsType inputType);
47 
48  ~UVWFlagger() override;
49 
50  common::Fields getRequiredFields() const override {
51  if (itsIsDegenerate) return common::Fields();
52 
53  common::Fields fields = kFlagsField;
54 
55  if (itsCenter.empty()) fields |= kUvwField;
56 
57  return fields;
58  }
59 
60  common::Fields getProvidedFields() const override {
61  return itsIsDegenerate ? common::Fields() : kFlagsField;
62  }
63 
66  bool process(std::unique_ptr<base::DPBuffer>) override;
67 
68  bool process(std::unique_ptr<base::BdaBuffer>) override;
69 
71  void finish() override;
72 
75  void updateInfo(const base::DPInfo&) override;
76 
78  void show(std::ostream&) const override;
79 
81  void showCounts(std::ostream&) const override;
82 
84  void showTimings(std::ostream&, double duration) const override;
85 
86  bool accepts(MsType dt) const override { return dt == itsInputType; }
87 
88  MsType outputs() const override { return itsInputType; }
89 
90  bool isDegenerate() const { return itsIsDegenerate; }
91 
92  private:
94  bool testUVWm(double uvw, const std::vector<double>& ranges);
95 
97  void testUVWl(double uvw, const std::vector<double>& ranges, bool* flagPtr,
98  unsigned int nrcorr, unsigned int baseline_id);
99 
100  // Apply UVW flagging
101  void doFlag(const std::array<double, 3>& uvw, bool* flagPtr,
102  unsigned int n_correlations, unsigned int n_channels,
103  unsigned int baseline_id = 0);
104 
111  std::vector<double> fillUVW(const common::ParameterSet& parset,
112  const std::string& prefix,
113  const std::string& name, bool square);
114 
117  void handleCenter();
118 
119  const MsType itsInputType;
120  std::string itsName;
121  unsigned int itsNTimes;
122 
127  std::vector<std::vector<double>> itsRecWavel;
128  const std::vector<double> itsRangeUVm;
129  const std::vector<double> itsRangeUm;
130  const std::vector<double> itsRangeVm;
131  const std::vector<double> itsRangeWm;
132  const std::vector<double>
133  itsRangeUVl;
134  const std::vector<double> itsRangeUl;
135  const std::vector<double> itsRangeVl;
136  const std::vector<double> itsRangeWl;
137 
139  const bool itsIsDegenerate;
140 
141  std::unique_ptr<base::UVWCalculator> itsUVWCalc;
142  const std::vector<std::string> itsCenter;
143  common::NSTimer itsTimer;
144  common::NSTimer itsUVWTimer;
145  base::FlagCounter itsFlagCounter;
146 };
147 
148 } // namespace steps
149 } // namespace dp3
150 
151 #endif
Buffer holding baseline-dependently averaged (BDA) data.
Buffer holding the data of a timeslot/band.
Abstract base class for a Step generating input.
Class to calculate UVW coordinates Note: this code is used by LOFAR and APERTIF software.
General info about DP3 data processing attributes like averaging.
Definition: DPInfo.h:35
Class to keep counts of nr of flagged points.
Definition: FlagCounter.h:35
Definition: Fields.h:16
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
Abstract base class for a DP3 step.
Definition: Step.h:52
static constexpr dp3::common::Fields kUvwField
Definition: Step.h:66
MsType
To check compatibility between steps before running.
Definition: Step.h:57
static constexpr dp3::common::Fields kFlagsField
Definition: Step.h:62
DP3 step class to flag data on UVW coordinates.
Definition: UVWFlagger.h:38
common::Fields getProvidedFields() const override
Definition: UVWFlagger.h:60
void showTimings(std::ostream &, double duration) const override
Show the timings.
bool process(std::unique_ptr< base::BdaBuffer >) override
UVWFlagger(const common::ParameterSet &, const std::string &prefix, MsType inputType)
void showCounts(std::ostream &) const override
Show the flag counts.
MsType outputs() const override
Return which datatype this step outputs.
Definition: UVWFlagger.h:88
void finish() override
Finish the processing of this step and subsequent steps.
bool process(std::unique_ptr< base::DPBuffer >) override
void updateInfo(const base::DPInfo &) override
common::Fields getRequiredFields() const override
Get the fields required by the current step.
Definition: UVWFlagger.h:50
void show(std::ostream &) const override
Show the step parameters.
bool accepts(MsType dt) const override
Boolean if this step can process this type of data.
Definition: UVWFlagger.h:86
bool isDegenerate() const
Definition: UVWFlagger.h:90
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53