DP3
PatchInfo.h
Go to the documentation of this file.
1 // PatchInfo.h: Info about a patch
2 //
3 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 
9 
10 #ifndef DP3_SKY_MODEL_PATCHINFO_H
11 #define DP3_SKY_MODEL_PATCHINFO_H
12 
13 #include <cmath>
14 #include <string>
15 
16 namespace dp3::sky_model {
17 
19 class PatchInfo {
20  public:
21  PatchInfo() = default;
22 
25  PatchInfo(const std::string& name, double ra, double dec, int category,
26  double apparentBrightness)
27  : itsName(name),
28  itsRa(ra),
29  itsDec(dec),
30  itsCategory(category),
31  itsAppBrightness(apparentBrightness) {}
32 
34  const std::string& getName() const { return itsName; }
35 
37  double getRa() const { return itsRa; }
38 
40  double getDec() const { return itsDec; }
41 
43  int getCategory() const { return itsCategory; }
44 
46  double apparentBrightness() const { return itsAppBrightness; }
47 
49  void setRa(double ra) { itsRa = ra; }
50 
52  void setDec(double dec) { itsDec = dec; }
53 
56  itsAppBrightness = apparentBrightness;
57  }
58 
59  private:
60  std::string itsName;
61  double itsRa = 0.0;
62  double itsDec = 0.0;
63  int itsCategory = 0;
64  double itsAppBrightness = 0.0;
65 };
66 
68 std::ostream& operator<<(std::ostream& os, const PatchInfo& info);
69 
71 class PatchSumInfo {
72  public:
75  explicit PatchSumInfo(unsigned int patchId) : itsPatchId(patchId) {}
76 
78  void add(double ra, double dec, double flux);
79 
81  double getFlux() const { return itsSumFlux; }
82 
84  double getRa() const {
85  return std::atan2(itsSumY / itsSumFlux, itsSumX / itsSumFlux);
86  }
87  double getDec() const { return std::asin(itsSumZ / itsSumFlux); }
88 
90  unsigned int getPatchId() const { return itsPatchId; }
91 
92  private:
93  double itsSumX = 0.0;
94  double itsSumY = 0.0;
95  double itsSumZ = 0.0;
96  double itsSumFlux = 0.0;
97  unsigned int itsPatchId = 0;
98 };
99 
101 void toSkyModel(std::ostream& output, const PatchInfo& patch);
102 
103 } // namespace dp3::sky_model
104 
105 #endif
Info about a patch.
Definition: PatchInfo.h:19
const std::string & getName() const
Get the patch name.
Definition: PatchInfo.h:34
double getDec() const
Get the declination in radians (J2000).
Definition: PatchInfo.h:40
double apparentBrightness() const
Get the apparent brightness of the patch (in Jy).
Definition: PatchInfo.h:46
void setDec(double dec)
Set the declination in radians (J2000).
Definition: PatchInfo.h:52
double getRa() const
Get the right ascension in radians (J2000).
Definition: PatchInfo.h:37
void setApparentBrightness(double apparentBrightness)
Set the apparent brightness of the patch (in Jy).
Definition: PatchInfo.h:55
PatchInfo(const std::string &name, double ra, double dec, int category, double apparentBrightness)
Definition: PatchInfo.h:25
void setRa(double ra)
Set the right ascension in radians (J2000).
Definition: PatchInfo.h:49
int getCategory() const
Get the category.
Definition: PatchInfo.h:43
Info about a patch direction.
Definition: PatchInfo.h:71
unsigned int getPatchId() const
Get the patchId.
Definition: PatchInfo.h:90
double getDec() const
Definition: PatchInfo.h:87
double getFlux() const
Get the total flux of the patch.
Definition: PatchInfo.h:81
void add(double ra, double dec, double flux)
Add a source direction to determine the average patch direction.
PatchSumInfo(unsigned int patchId)
Definition: PatchInfo.h:75
double getRa() const
Get the patch direction (flux-weighted average direction of its sources).
Definition: PatchInfo.h:84
Definition: Patch.h:14
void toSkyModel(std::ostream &output, const PatchInfo &patch)
Output a patch to a sky_model text file.
std::ostream & operator<<(std::ostream &os, const PatchInfo &info)
Show the contents of a PatchInfo object.