4 #ifndef DP3_DDECAL_ROTATIONANDDIAGONAL_CONSTRAINT_H_
5 #define DP3_DDECAL_ROTATIONANDDIAGONAL_CONSTRAINT_H_
25 const std::vector<uint32_t>& solutions_per_direction,
26 const std::vector<double>& frequencies)
override;
28 void SetWeights(
const std::vector<double>& weights)
override;
32 std::vector<ConstraintResult>
GetResult()
const override {
return results_; }
35 void FitRotationAndDiagonal(
36 const std::complex<double>* data,
double& angle,
37 std::array<std::complex<double>, 2>& diagonal)
const;
39 template <
size_t PolCount>
40 void SetChannelWeights(std::vector<double>& values,
size_t channel,
41 double new_value)
const;
43 std::vector<ConstraintResult> results_;
44 bool do_rotation_reference_;
57 size_t n_antennas,
size_t n_sub_solutions,
size_t n_channels,
61 const std::array<std::complex<double>, 2>& diagonal,
62 size_t channel,
size_t antenna,
size_t subsolution,
63 size_t n_channels,
size_t n_sub_solutions,
69 const size_t index_part =
70 (antenna * n_sub_solutions + subsolution) * n_channels + channel;
71 switch (diagonal_solution_type) {
72 case CalType::kDiagonal:
73 results[0].
vals[index_part * 2] = std::abs(diagonal[0]);
74 results[0].
vals[index_part * 2 + 1] = std::abs(diagonal[1]);
75 results[1].
vals[index_part * 2] = std::arg(diagonal[0]);
76 results[1].
vals[index_part * 2 + 1] = std::arg(diagonal[1]);
78 case CalType::kDiagonalAmplitude:
79 results[0].
vals[index_part * 2] = std::abs(diagonal[0]);
80 results[0].
vals[index_part * 2 + 1] = std::abs(diagonal[1]);
82 case CalType::kDiagonalPhase:
83 results[0].
vals[index_part * 2] = std::arg(diagonal[0]);
84 results[0].
vals[index_part * 2 + 1] = std::arg(diagonal[1]);
86 case CalType::kScalar:
87 results[0].
vals[index_part] = std::abs(diagonal[0]);
88 results[1].
vals[index_part] = std::arg(diagonal[0]);
90 case CalType::kScalarAmplitude:
91 results[0].
vals[index_part] = std::abs(diagonal[0]);
93 case CalType::kScalarPhase:
94 results[0].
vals[index_part] = std::arg(diagonal[0]);
This class is the base class for classes that implement a constraint on calibration solutions....
Definition: Constraint.h:27
Definition: RotationAndDiagonalConstraint.h:18
void Initialize(size_t n_antennas, const std::vector< uint32_t > &solutions_per_direction, const std::vector< double > &frequencies) override
std::vector< ConstraintResult > GetResult() const override
Definition: RotationAndDiagonalConstraint.h:32
void SetDoRotationReference(bool do_rotation_reference)
void Apply(SolutionSpan &solutions, double time) override
RotationAndDiagonalConstraint(base::CalType diagonal_solution_type)
void SetWeights(const std::vector< double > &weights) override
CalType
Definition: CalType.h:11
aocommon::xt::Span< std::complex< double >, 4 > SolutionSpan
Definition: Solutions.h:20
void StoreDiagonal(ConstraintResult *results, const std::array< std::complex< double >, 2 > &diagonal, size_t channel, size_t antenna, size_t subsolution, size_t n_channels, size_t n_sub_solutions, base::CalType diagonal_solution_type)
Definition: RotationAndDiagonalConstraint.h:60
std::vector< ConstraintResult > MakeDiagonalResults(size_t n_antennas, size_t n_sub_solutions, size_t n_channels, base::CalType diagonal_solution_type)
void ConstrainDiagonal(std::array< std::complex< double >, 2 > &diagonal, base::CalType mode)
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53
Definition: ConstraintResult.h:18
std::vector< double > vals
Both vals and weights have the dimensions described in dims and axes.
Definition: ConstraintResult.h:20