DP3
Public Types | Public Member Functions | Static Public Member Functions | List of all members
dp3::ddecal::Constraint Class Referenceabstract

This class is the base class for classes that implement a constraint on calibration solutions. Constraints are used to increase the converge of calibration by applying these inside the solving step. More...

#include <Constraint.h>

Inheritance diagram for dp3::ddecal::Constraint:
dp3::ddecal::AmplitudeOnlyConstraint dp3::ddecal::AntennaConstraint dp3::ddecal::AntennaIntervalConstraint dp3::ddecal::FaradayConstraint dp3::ddecal::PolarizationLeakageConstraint dp3::ddecal::RotationAndDiagonalConstraint dp3::ddecal::RotationConstraint dp3::ddecal::ScreenConstraint dp3::ddecal::SmoothnessConstraint dp3::ddecal::TecConstraint dp3::ddecal::TecOffsetDelayConstraint

Public Types

typedef std::complex< double > dcomplex
 

Public Member Functions

virtual ~Constraint ()=default
 
virtual void Apply (SolutionSpan &solutions, double time)=0
 
void ApplyReferenceAntenna (SolutionSpan &solutions)
 
virtual std::vector< ConstraintResultGetResult () const
 
uint32_t GetSubSolutions (size_t direction) const
 
virtual void GetTimings ([[maybe_unused]] std::ostream &os, [[maybe_unused]] double duration) const
 
virtual void Initialize (size_t n_antennas, const std::vector< uint32_t > &solutions_per_direction, const std::vector< double > &frequencies)
 
size_t NAntennas () const
 
size_t NChannelBlocks () const
 
size_t NDirections () const
 
size_t NSubSolutions () const
 
virtual void PrepareIteration ([[maybe_unused]] bool hasReachedPrecision, [[maybe_unused]] size_t iteration, [[maybe_unused]] bool finalIter)
 
virtual bool Satisfied () const
 
virtual void SetSubSolutionWeights (const std::vector< std::vector< double >> &solution_weights)
 
virtual void SetWeights ([[maybe_unused]] const std::vector< double > &weights)
 

Static Public Member Functions

static bool isfinite (const dcomplex &value)
 

Detailed Description

This class is the base class for classes that implement a constraint on calibration solutions. Constraints are used to increase the converge of calibration by applying these inside the solving step.

The MultiDirSolver class uses this class for constrained calibration.

Member Typedef Documentation

◆ dcomplex

typedef std::complex<double> dp3::ddecal::Constraint::dcomplex

Constructor & Destructor Documentation

◆ ~Constraint()

virtual dp3::ddecal::Constraint::~Constraint ( )
virtualdefault

Member Function Documentation

◆ Apply()

virtual void dp3::ddecal::Constraint::Apply ( SolutionSpan solutions,
double  time 
)
pure virtual

This method applies the constraints to the solutions.

Parameters
solutionsA 4D array with dimensions n_channel_blocks x n_antennas x n_sub_solutions x n_pol solutions. n_pol is the dimension with the fastest changing index. Using a span instead of a real tensor as argument type avoids the need for copying data in Python bindings.
timeCentral time of interval.

Implemented in dp3::ddecal::TecOffsetDelayConstraint, dp3::ddecal::ApproximateTECConstraint, dp3::ddecal::TecConstraint, dp3::ddecal::SmoothnessConstraint, dp3::ddecal::RotationConstraint, dp3::ddecal::RotationAndDiagonalConstraint, dp3::ddecal::PolarizationLeakageConstraint, dp3::ddecal::FaradayConstraint, dp3::ddecal::AntennaIntervalConstraint, dp3::ddecal::AntennaConstraint, and dp3::ddecal::AmplitudeOnlyConstraint.

◆ ApplyReferenceAntenna()

void dp3::ddecal::Constraint::ApplyReferenceAntenna ( SolutionSpan solutions)

Pick a suitable reference antenna that is >20% unflagged, and references the phases and amplitudes of all solutions to this antenna.

◆ GetResult()

virtual std::vector<ConstraintResult> dp3::ddecal::Constraint::GetResult ( ) const
inlinevirtual

Obtain results that are to be written to the solution file, instead of the actual solutions. Not all constraints use these; some constraints modify the solutions and the solutions are the result. Example of constraint the do produce results are the Faraday and TEC constraints.

Returns
Optionally, a vector with the last results. The vector is index by value type (e.g. Faraday rotation and scalar).

Reimplemented in dp3::ddecal::TecOffsetDelayConstraint, dp3::ddecal::ApproximateTECConstraint, dp3::ddecal::TecConstraint, dp3::ddecal::RotationConstraint, dp3::ddecal::RotationAndDiagonalConstraint, and dp3::ddecal::FaradayConstraint.

◆ GetSubSolutions()

uint32_t dp3::ddecal::Constraint::GetSubSolutions ( size_t  direction) const
inline

◆ GetTimings()

virtual void dp3::ddecal::Constraint::GetTimings ( [[maybe_unused] ] std::ostream &  os,
[[maybe_unused] ] double  duration 
) const
inlinevirtual

◆ Initialize()

virtual void dp3::ddecal::Constraint::Initialize ( size_t  n_antennas,
const std::vector< uint32_t > &  solutions_per_direction,
const std::vector< double > &  frequencies 
)
inlinevirtual

Perform common constraint initialization. Should be overridden when something more than assigning dimensions is needed (e.g. resizing vectors).

Parameters
frequenciesFor each channel block, the mean frequency.

Reimplemented in dp3::ddecal::TecOffsetDelayConstraint, dp3::ddecal::TecConstraint, dp3::ddecal::SmoothnessConstraint, dp3::ddecal::ScreenConstraint, dp3::ddecal::RotationConstraint, dp3::ddecal::RotationAndDiagonalConstraint, dp3::ddecal::FaradayConstraint, and dp3::ddecal::AntennaIntervalConstraint.

◆ isfinite()

static bool dp3::ddecal::Constraint::isfinite ( const dcomplex value)
inlinestatic

◆ NAntennas()

size_t dp3::ddecal::Constraint::NAntennas ( ) const
inline

◆ NChannelBlocks()

size_t dp3::ddecal::Constraint::NChannelBlocks ( ) const
inline

◆ NDirections()

size_t dp3::ddecal::Constraint::NDirections ( ) const
inline

◆ NSubSolutions()

size_t dp3::ddecal::Constraint::NSubSolutions ( ) const
inline

Number of subsolutions over all directions, taking into account that a direction maybe have multiple intervals. This is the sum over solutions_per_direction_.

◆ PrepareIteration()

virtual void dp3::ddecal::Constraint::PrepareIteration ( [[maybe_unused] ] bool  hasReachedPrecision,
[[maybe_unused] ] size_t  iteration,
[[maybe_unused] ] bool  finalIter 
)
inlinevirtual

Function that initializes the constraint for the next calibration iteration. It should be called each time all antenna solutions have been calculated, but before the constraint has been applied to all those antenna solutions.

Unlike Apply(), this method is not thread safe.

Parameters
hasReachedPrecisionThis can be used to specify whether the previous solution "step" is smaller than the requested precision, i.e. calibration with the constraint has converged. This allows a constraint to apply its constraint in steps: apply a better-converging constraint as long as the solutions are far from the correct answer, then switch to a different constraint when hasReachedPrecision=true.

◆ Satisfied()

virtual bool dp3::ddecal::Constraint::Satisfied ( ) const
inlinevirtual

Whether the constraint has been satisfied. The calibration process will continue at least as long as Satisfied()=false, and performs at least one more iteration after Satisfied()=true. Together with SetPrecisionReached(), this can make the algorithm change the constraining method based on amount of convergence.

Reimplemented in dp3::ddecal::ApproximateTECConstraint.

◆ SetSubSolutionWeights()

virtual void dp3::ddecal::Constraint::SetSubSolutionWeights ( const std::vector< std::vector< double >> &  solution_weights)
inlinevirtual

Set direction dependent weights. It consists of n_sub_solutions vectors, each of which is an n_antennas * n_channel_blocks vector, where the channel index varies fastest.

If set, the normal weights are not used.

Reimplemented in dp3::ddecal::SmoothnessConstraint, and dp3::ddecal::FaradayConstraint.

◆ SetWeights()

virtual void dp3::ddecal::Constraint::SetWeights ( [[maybe_unused] ] const std::vector< double > &  weights)
inlinevirtual

Set weights. The vector should contain the flattened version of an array of size n_antennas * n_channel_blocks, where the channel index varies fastest.


The documentation for this class was generated from the following file: