DP3
PointSource.h
Go to the documentation of this file.
1 // PointSource.h: Point source model component with optional spectral index and
2 // rotation measure.
3 //
4 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 
7 #ifndef DPPP_POINTSOURCE_H
8 #define DPPP_POINTSOURCE_H
9 
10 #include <vector>
11 
12 #include "ModelComponent.h"
13 #include "Stokes.h"
14 #include "base/Direction.h"
15 
16 #include <memory>
17 
18 namespace dp3 {
19 namespace base {
20 
23 
25 
26 class PointSource : public ModelComponent {
27  public:
28  typedef std::shared_ptr<PointSource> Ptr;
29  typedef std::shared_ptr<const PointSource> ConstPtr;
30 
31  PointSource(const Direction &position);
32  PointSource(const Direction &position, const Stokes &stokes);
33 
34  const Direction &direction() const override { return itsDirection; }
35  void setDirection(const Direction &position);
36 
37  void setStokes(const Stokes &stokes);
38 
39  template <typename T>
40  void setSpectralTerms(double refFreq, bool isLogarithmic, T first, T last);
41 
42  void setRotationMeasure(double fraction, double angle, double rm);
43 
44  Stokes stokes(double freq) const;
45  Stokes stokes() const;
46  const std::vector<double> &spectrum() const { return itsSpectralTerms; }
47  double referenceFreq() const { return itsRefFreq; }
48 
49  void accept(ModelComponentVisitor &visitor) const override;
50 
51  bool hasLogarithmicSI() const { return itsHasLogarithmicSI; }
52 
53  bool hasSpectralTerms() const;
54  bool hasRotationMeasure() const;
55 
56  double polarizationAngle() const { return itsPolarizationAngle; }
57  double polarizedFraction() const { return itsPolarizedFraction; }
58  double rotationMeasure() const { return itsRotationMeasure; }
59 
60  private:
61  Direction itsDirection;
62  Stokes itsStokes;
63  double itsRefFreq;
64  std::vector<double> itsSpectralTerms;
65  double itsPolarizedFraction;
66  double itsPolarizationAngle;
67  double itsRotationMeasure;
68  bool itsHasRotationMeasure;
69  bool itsHasLogarithmicSI;
70 };
71 
73 
74 // -------------------------------------------------------------------------- //
75 // - Implementation: PointSource - //
76 // -------------------------------------------------------------------------- //
77 
78 template <typename T>
79 void PointSource::setSpectralTerms(double refFreq, bool isLogarithmic, T first,
80  T last) {
81  itsRefFreq = refFreq;
82  itsHasLogarithmicSI = isLogarithmic;
83  itsSpectralTerms.clear();
84  itsSpectralTerms.insert(itsSpectralTerms.begin(), first, last);
85 }
86 
87 } // namespace base
88 } // namespace dp3
89 
90 #endif
Base class for visitors that visit model component hierarchies.
Definition: ModelComponentVisitor.h:20
Base class for model components.
Definition: ModelComponent.h:21
Point source model component with optional spectral index and rotation measure.
Definition: PointSource.h:26
PointSource(const Direction &position)
bool hasRotationMeasure() const
void setDirection(const Direction &position)
double referenceFreq() const
Definition: PointSource.h:47
void accept(ModelComponentVisitor &visitor) const override
bool hasLogarithmicSI() const
Definition: PointSource.h:51
PointSource(const Direction &position, const Stokes &stokes)
double polarizationAngle() const
Definition: PointSource.h:56
void setStokes(const Stokes &stokes)
Stokes stokes() const
bool hasSpectralTerms() const
double polarizedFraction() const
Definition: PointSource.h:57
std::shared_ptr< PointSource > Ptr
Definition: PointSource.h:28
std::shared_ptr< const PointSource > ConstPtr
Definition: PointSource.h:29
void setRotationMeasure(double fraction, double angle, double rm)
void setSpectralTerms(double refFreq, bool isLogarithmic, T first, T last)
Definition: PointSource.h:79
const std::vector< double > & spectrum() const
Definition: PointSource.h:46
double rotationMeasure() const
Definition: PointSource.h:58
const Direction & direction() const override
Definition: PointSource.h:34
Stokes stokes(double freq) const
Complex Stokes vector.
Definition: Stokes.h:16
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53
A direction on the celestial sphere.
Definition: Direction.h:15