DP3
ScreenConstraint.h
Go to the documentation of this file.
1 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
4 #ifndef DP3_DDECAL_SCREEN_CONSTRAINT_H_
5 #define DP3_DDECAL_SCREEN_CONSTRAINT_H_
6 
7 #include "base/PhaseFitter.h"
8 #include "base/Direction.h"
9 
10 #include "Constraint.h"
11 #include "PiercePoint.h"
12 #include "KLFitter.h"
13 
14 #include "common/ParameterSet.h"
15 
16 #include <cmath>
17 #include <complex>
18 #include <memory>
19 #include <ostream>
20 #include <vector>
21 
22 namespace dp3 {
23 namespace common {
24 class ParameterSet;
25 }
26 
27 namespace ddecal {
28 
29 class ScreenConstraint final : public Constraint {
30  static constexpr double kPhaseToTec = 1.0 / 8.4479745e9;
31  static constexpr double kTecToPhase = 8.4479745e9;
32  static constexpr size_t kMaxIterations =
33  30; // number of iterations to store in debug mode
34 
35  public:
37  const std::string& prefix);
38 
39  void Initialize(size_t nAntennas,
40  const std::vector<uint32_t>& solutions_per_direction,
41  const std::vector<double>& frequencies) override;
42  std::vector<Constraint::Result> Apply(SolutionSpan& solutions, double time,
43  std::ostream* statStream) override;
44 
45  void SetCoreAntennas(const std::set<size_t>& core_antennas);
46  void InitPiercePoints(const std::vector<std::array<double, 3>>& antenna_pos,
47  const std::vector<base::Direction>& source_directions);
48 
49  const std::vector<size_t>& GetCoreAntennas() const { return core_antennas_; }
50  const std::vector<std::vector<PiercePoint>>& GetPiercePoints() const {
51  return pierce_points_;
52  }
53 
54  private:
55  void SetTime(double time);
56  void CalculatePiercepoints();
57  void GetPpValue(const SolutionSpan&, size_t antenna_index,
58  size_t direction_index, double& avg_tec, double& error) const;
59 
60  std::vector<double> frequencies_;
61  std::vector<double> previous_solution_;
62  std::vector<double> iter_phases_;
66  std::vector<std::vector<PiercePoint>>
67  pierce_points_; // temporary hold calculated piercepoints per antenna
68  std::vector<KLFitter> screen_fitters_;
69  std::vector<size_t> core_antennas_;
70  std::vector<size_t> other_antennas_; // has to be a vector for openmp looping
71  double current_time_;
72  double beta_;
73  double height_;
74  double order_;
75  double r_diff_;
76  std::string mode_;
77  std::string avg_mode_;
78  int debug_mode_;
79  size_t iteration_;
80 };
81 
82 } // namespace ddecal
83 } // namespace dp3
84 
85 #endif
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
This class is the base class for classes that implement a constraint on calibration solutions....
Definition: Constraint.h:27
Definition: ScreenConstraint.h:29
const std::vector< std::vector< PiercePoint > > & GetPiercePoints() const
Definition: ScreenConstraint.h:50
void Initialize(size_t nAntennas, const std::vector< uint32_t > &solutions_per_direction, const std::vector< double > &frequencies) override
ScreenConstraint(const common::ParameterSet &parset, const std::string &prefix)
void SetCoreAntennas(const std::set< size_t > &core_antennas)
const std::vector< size_t > & GetCoreAntennas() const
Definition: ScreenConstraint.h:49
void InitPiercePoints(const std::vector< std::array< double, 3 >> &antenna_pos, const std::vector< base::Direction > &source_directions)
std::vector< Constraint::Result > Apply(SolutionSpan &solutions, double time, std::ostream *statStream) override
aocommon::xt::Span< std::complex< double >, 4 > SolutionSpan
Definition: Solutions.h:20
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53