File: baselineselector.h

package info (click to toggle)
aoflagger 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,868 kB
  • sloc: cpp: 52,164; python: 152; sh: 60; makefile: 17
file content (82 lines) | stat: -rw-r--r-- 2,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef BASELINE_SELECTOR_H
#define BASELINE_SELECTOR_H

#include <string>
#include <set>
#include <vector>
#include <mutex>

#include "../../structures/timefrequencymetadata.h"
#include "../../structures/mask2d.h"

class DefaultStatistics;

namespace rfiStrategy {

class BaselineSelector {
 public:
  struct SingleBaselineInfo {
    SingleBaselineInfo() : marked(false) {}

    bool operator<(const SingleBaselineInfo &rhs) const {
      return length < rhs.length;
    }

    int antenna1, antenna2;
    std::string antenna1Name, antenna2Name;
    int band;
    unsigned sequenceId;
    double length;
    unsigned long rfiCount, totalCount;
    bool marked;
  };

  BaselineSelector()
      : _threshold(8.0),
        _absThreshold(0.4),
        _smoothingSigma(0.6),
        _makePlot(false),
        _useLog(true) {}

  typedef std::vector<SingleBaselineInfo> BaselineVector;
  void Search(
      std::vector<BaselineSelector::SingleBaselineInfo> &markedBaselines);
  void ImplyStations(
      const std::vector<BaselineSelector::SingleBaselineInfo> &markedBaselines,
      double maxRatio, std::set<unsigned> &badStations) const;
  void Add(Mask2DCPtr mask, TimeFrequencyMetaDataCPtr metaData);
  void Add(class DefaultStatistics &baselineStat, class AntennaInfo &antenna1,
           class AntennaInfo &antenna2);

  std::mutex &Mutex() { return _mutex; }

  double Threshold() const { return _threshold; }
  double AbsThreshold() const { return _absThreshold; }

  void SetThreshold(double threshold) { _threshold = threshold; }
  void SetAbsThreshold(double absThreshold) { _absThreshold = absThreshold; }
  void SetSmoothingSigma(double smoothingSigma) {
    _smoothingSigma = smoothingSigma;
  }
  void SetUseLog(bool useLog) { _useLog = useLog; }

  size_t BaselineCount() const { return _baselines.size(); }

 private:
  std::mutex _mutex;
  BaselineVector _baselines;
  double _threshold, _absThreshold;
  double _smoothingSigma;
  bool _makePlot;
  bool _useLog;

  double smoothedValue(double length) const;
  double smoothedValue(
      const BaselineSelector::SingleBaselineInfo &baseline) const {
    return smoothedValue(baseline.length);
  }
};

}  // namespace rfiStrategy

#endif