DP3
FlagCounter.h
Go to the documentation of this file.
1 // FlagCounter.h: Class to keep counts of nr of flagged points
2 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 
8 
9 #ifndef DP3_FLAGCOUNTER_H_
10 #define DP3_FLAGCOUNTER_H_
11 
12 #include <casacore/casa/Arrays/Vector.h>
13 
14 #include <cstdint>
15 #include <ostream>
16 
17 namespace dp3 {
18 namespace common {
19 class ParameterSet;
20 }
21 
22 namespace base {
23 class DPInfo;
24 
26 
34 
35 class FlagCounter {
36  public:
38  FlagCounter() = default;
39 
42  FlagCounter(const common::ParameterSet&, const std::string& prefix);
43 
46  void init(const DPInfo& info);
47 
49  void incrBaseline(unsigned int bl) { base_line_counts_[bl]++; }
50 
52  void incrChannel(unsigned int chan) { channel_counts_[chan]++; }
53 
55  void incrCorrelation(unsigned int corr) { correlation_counts_[corr]++; }
56 
58  void add(const FlagCounter& that);
59 
62  const std::vector<int64_t>& baselineCounts() const {
63  return base_line_counts_;
64  }
65  const std::vector<int64_t>& channelCounts() const { return channel_counts_; }
66  const std::vector<int64_t>& correlationCounts() const {
67  return correlation_counts_;
68  }
70 
72  void showBaseline(std::ostream& os, int64_t ntimes) const;
73  void showChannel(std::ostream& os, int64_t ntimes) const;
74  void showCorrelation(std::ostream& os, int64_t ntimes) const;
75 
77  void showStation(std::ostream& os, int64_t ntimes) const;
78 
80  static void showPerc1(std::ostream&, double value, double total);
81 
83  static void showPerc3(std::ostream&, double value, double total);
84 
85  private:
87  void saveStation(int64_t npoints, const casacore::Vector<int64_t>& nused,
88  const casacore::Vector<int64_t>& count) const;
89 
91  void saveChannel(int64_t npoints, const std::vector<int64_t>& count) const;
92 
93  const DPInfo* info_{nullptr};
94  std::string save_filename_{};
95  double warning_percentage_{0.0};
96  bool show_fully_flagged_{false};
97  bool save_{false};
98  std::string path_{};
99  std::string name_{};
100  std::vector<int64_t> base_line_counts_{};
101  std::vector<int64_t> channel_counts_{};
102  std::vector<int64_t> correlation_counts_{};
103 };
104 
105 } // namespace base
106 } // namespace dp3
107 
108 #endif
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
void init(const DPInfo &info)
void showStation(std::ostream &os, int64_t ntimes) const
void incrBaseline(unsigned int bl)
Increment the count per baseline.
Definition: FlagCounter.h:49
static void showPerc1(std::ostream &, double value, double total)
Show percentage with 1 decimal.
const std::vector< int64_t > & channelCounts() const
Definition: FlagCounter.h:65
const std::vector< int64_t > & correlationCounts() const
Definition: FlagCounter.h:66
void add(const FlagCounter &that)
Add the contents of that to this.
void showCorrelation(std::ostream &os, int64_t ntimes) const
FlagCounter(const common::ParameterSet &, const std::string &prefix)
void showChannel(std::ostream &os, int64_t ntimes) const
FlagCounter()=default
The default constructor creates an empty object. It does not save.
void showBaseline(std::ostream &os, int64_t ntimes) const
Print the counts and optionally save percentages in a table.
void incrCorrelation(unsigned int corr)
Increment the count per correlation.
Definition: FlagCounter.h:55
const std::vector< int64_t > & baselineCounts() const
Definition: FlagCounter.h:62
void incrChannel(unsigned int chan)
Increment the count per channel.
Definition: FlagCounter.h:52
static void showPerc3(std::ostream &, double value, double total)
Show percentage with 3 decimals.
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53