DP3
ApplyCal.h
Go to the documentation of this file.
1 // ApplyCal.h: DP3 step class to ApplyCal visibilities from a source model
2 // Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 
8 
9 #ifndef DP3_STEPS_APPLYCAL_H_
10 #define DP3_STEPS_APPLYCAL_H_
11 
12 #include <utility>
13 
14 #include <aocommon/matrix2x2.h>
15 #include <aocommon/matrix2x2diag.h>
16 
17 #include "base/DPBuffer.h"
18 #include "OneApplyCal.h"
19 
20 namespace dp3 {
21 namespace common {
22 class ParameterSet;
23 }
24 
25 namespace steps {
26 
28 
31 
32 class ApplyCal : public Step {
33  public:
36  ApplyCal(const common::ParameterSet&, const std::string& prefix,
37  bool substep = false, std::string predictDirection = "");
38 
39  ApplyCal() = default;
40 
41  ~ApplyCal() override = default;
42 
43  common::Fields getRequiredFields() const override {
44  // ApplyCal is a dummy step, which is followed by OneApplyCal steps.
45  return {};
46  }
47 
48  common::Fields getProvidedFields() const override {
49  // ApplyCal is a dummy step, which is followed by OneApplyCal steps.
50  return {};
51  }
52 
56  bool process(std::unique_ptr<base::DPBuffer> buffer) override;
57 
59  void finish() override;
60 
63  void setNextStep(Step::ShPtr nextStep) override;
64 
68  void show(std::ostream&) const override;
69 
73  void showTimings(std::ostream&, double duration) const override;
74 
76  template <typename NumType>
77  static void invert(std::complex<NumType>* v);
78 
80  static void ApplyDiag(const aocommon::MC2x2FDiag& gain_a,
81  const aocommon::MC2x2FDiag& gain_b,
82  base::DPBuffer& buffer, unsigned int baseline,
83  unsigned int channel, bool update_weights,
84  base::FlagCounter& flag_counter,
85  const std::string& direction = "");
86 
89  static void ApplyScalar(const std::complex<float>& gain_a,
90  const std::complex<float>& gain_b,
91  base::DPBuffer& buffer, unsigned int baseline,
92  unsigned int channel, bool update_weights,
93  base::FlagCounter& flag_counter);
94 
100  static void ApplyFull(const aocommon::MC2x2F& gain_a,
101  const aocommon::MC2x2F& gain_b, base::DPBuffer& buffer,
102  unsigned int baseline, unsigned int channel,
103  bool update_weights, base::FlagCounter& flag_counter,
104  const std::string& direction = "");
105 
114  static void ApplyWeights(const aocommon::MC2x2F& gain_a,
115  const aocommon::MC2x2F& gain_b, float* weight);
116 
117  private:
118  bool is_sub_step_{false};
119  std::vector<std::shared_ptr<OneApplyCal>> apply_cals_;
120 };
121 
122 } // namespace steps
123 } // namespace dp3
124 
125 #endif
Buffer holding the data of a timeslot/band.
DP3 step class to apply a calibration correction to the data.
Buffer holding the data of a timeslot/band.
Definition: DPBuffer.h:92
Class to keep counts of nr of flagged points.
Definition: FlagCounter.h:35
Definition: Fields.h:16
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
DP3 step class to ApplyCal visibilities from a source model.
Definition: ApplyCal.h:32
static void invert(std::complex< NumType > *v)
Invert a 2x2 matrix in place.
common::Fields getRequiredFields() const override
Get the fields required by the current step.
Definition: ApplyCal.h:43
void finish() override
Finish the processing of this step and subsequent steps.
static void ApplyDiag(const aocommon::MC2x2FDiag &gain_a, const aocommon::MC2x2FDiag &gain_b, base::DPBuffer &buffer, unsigned int baseline, unsigned int channel, bool update_weights, base::FlagCounter &flag_counter, const std::string &direction="")
Apply a diagonal Jones matrix to the 2x2 visibilities matrix: A.V.B^H.
common::Fields getProvidedFields() const override
Definition: ApplyCal.h:48
void setNextStep(Step::ShPtr nextStep) override
static void ApplyScalar(const std::complex< float > &gain_a, const std::complex< float > &gain_b, base::DPBuffer &buffer, unsigned int baseline, unsigned int channel, bool update_weights, base::FlagCounter &flag_counter)
ApplyCal(const common::ParameterSet &, const std::string &prefix, bool substep=false, std::string predictDirection="")
bool process(std::unique_ptr< base::DPBuffer > buffer) override
~ApplyCal() override=default
void showTimings(std::ostream &, double duration) const override
void show(std::ostream &) const override
static void ApplyFull(const aocommon::MC2x2F &gain_a, const aocommon::MC2x2F &gain_b, base::DPBuffer &buffer, unsigned int baseline, unsigned int channel, bool update_weights, base::FlagCounter &flag_counter, const std::string &direction="")
static void ApplyWeights(const aocommon::MC2x2F &gain_a, const aocommon::MC2x2F &gain_b, float *weight)
Abstract base class for a DP3 step.
Definition: Step.h:52
std::shared_ptr< Step > ShPtr
Definition: Step.h:54
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53