DP3
SmoothnessConstraint.h
Go to the documentation of this file.
1 // Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
4 #ifndef DP3_DDECAL_SMOOTHNESS_CONSTRAINT_H_
5 #define DP3_DDECAL_SMOOTHNESS_CONSTRAINT_H_
6 
7 #include <vector>
8 
9 #include "Constraint.h"
10 #include "KernelSmoother.h"
11 
12 namespace dp3 {
13 namespace ddecal {
14 
15 class SmoothnessConstraint final : public Constraint {
16  public:
23  SmoothnessConstraint(double bandwidth_hz, double bandwidth_ref_frequency_hz,
24  double spectral_exponent, bool kernel_truncation);
25 
26  void Apply(SolutionSpan& solutions, double time) override;
27 
32  void SetWeights(const std::vector<double>& weights) override {
33  weights_ = weights;
34  }
35 
37  const std::vector<std::vector<double>>& sub_solution_weights) override {
38  sub_solution_weights_ = sub_solution_weights;
39  }
40 
41  void Initialize(size_t nAntennas,
42  const std::vector<uint32_t>& solutions_per_direction,
43  const std::vector<double>& frequencies) override;
44 
55  void SetAntennaFactors(std::vector<double>&& antenna_factors) {
56  antenna_factors_ = std::move(antenna_factors);
57  }
58 
59  const std::vector<double>& GetAntennaFactors() const {
60  return antenna_factors_;
61  }
62 
73  void SetDdSmoothingFactors(std::vector<double> dd_smoothing_factors);
74 
75  const std::vector<double>& GetDdSmoothingFactors() const {
76  return dd_smoothing_factors_;
77  }
78 
79  private:
80  using Smoother = KernelSmoother<std::complex<double>, double>;
81 
82  struct FitData {
83  FitData(const std::vector<double>& frequencies,
84  Smoother::KernelType kernel_type, double kernel_bandwidth,
85  double bandwidth_ref_frequency_hz, double spectral_exponent,
86  bool kernel_truncation)
87  : smoother(frequencies, kernel_type, kernel_bandwidth,
88  bandwidth_ref_frequency_hz, spectral_exponent,
89  kernel_truncation),
90  data(frequencies.size()),
91  weight(frequencies.size()) {}
92 
93  Smoother smoother;
94  std::vector<std::complex<double>> data;
95  std::vector<double> weight;
96  };
97  std::vector<FitData> fit_data_;
98  std::vector<double> frequencies_;
99  std::vector<double> antenna_factors_;
100  std::vector<double> dd_smoothing_factors_;
101  std::vector<double> weights_;
103  std::vector<std::vector<double>> sub_solution_weights_;
104  Smoother::KernelType kernel_type_;
105  double bandwidth_;
106  double bandwidth_ref_frequency_;
107  double spectral_exponent_;
108  bool kernel_truncation_;
109 };
110 
111 } // namespace ddecal
112 } // namespace dp3
113 
114 #endif
This class is the base class for classes that implement a constraint on calibration solutions....
Definition: Constraint.h:27
Smooths a series of possibly irregularly gridded values by a given kernel.
Definition: KernelSmoother.h:29
Definition: SmoothnessConstraint.h:15
SmoothnessConstraint(double bandwidth_hz, double bandwidth_ref_frequency_hz, double spectral_exponent, bool kernel_truncation)
void SetAntennaFactors(std::vector< double > &&antenna_factors)
Definition: SmoothnessConstraint.h:55
void SetWeights(const std::vector< double > &weights) override
Definition: SmoothnessConstraint.h:32
void SetDdSmoothingFactors(std::vector< double > dd_smoothing_factors)
void Initialize(size_t nAntennas, const std::vector< uint32_t > &solutions_per_direction, const std::vector< double > &frequencies) override
const std::vector< double > & GetDdSmoothingFactors() const
Definition: SmoothnessConstraint.h:75
void Apply(SolutionSpan &solutions, double time) override
const std::vector< double > & GetAntennaFactors() const
Definition: SmoothnessConstraint.h:59
void SetSubSolutionWeights(const std::vector< std::vector< double >> &sub_solution_weights) override
Definition: SmoothnessConstraint.h:36
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