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 LOFAR_PARMDB_PATCHINFO_H
11 #define LOFAR_PARMDB_PATCHINFO_H
12 
13 #include <cmath>
14 #include <string>
15 
16 namespace dp3 {
17 
18 namespace blob {
19 class BlobOStream;
20 class BlobIStream;
21 } // namespace blob
22 
23 namespace parmdb {
24 
27 
29 class PatchInfo {
30  public:
32  PatchInfo() {}
33 
36  PatchInfo(const std::string& name, double ra, double dec, int category,
37  double apparentBrightness)
38  : itsName(name),
39  itsRa(ra),
40  itsDec(dec),
41  itsCategory(category),
42  itsAppBrightness(apparentBrightness) {}
43 
45  const std::string& getName() const { return itsName; }
46 
48  double getRa() const { return itsRa; }
49 
51  double getDec() const { return itsDec; }
52 
54  int getCategory() const { return itsCategory; }
55 
57  double apparentBrightness() const { return itsAppBrightness; }
58 
60  void setRa(double ra) { itsRa = ra; }
61 
63  void setDec(double dec) { itsDec = dec; }
64 
67  itsAppBrightness = apparentBrightness;
68  }
69 
70  private:
71  std::string itsName;
72  double itsRa{0.0};
73  double itsDec{0.0};
74  int itsCategory{0};
75  double itsAppBrightness{0.0};
76 };
77 
79 std::ostream& operator<<(std::ostream& os, const PatchInfo& info);
80 
83 
86 
88 class PatchSumInfo {
89  public:
92  explicit PatchSumInfo(unsigned int patchId)
93  : itsSumX(0),
94  itsSumY(0),
95  itsSumZ(0),
96  itsSumFlux(0),
97  itsPatchId(patchId) {}
98 
100  void add(double ra, double dec, double flux);
101 
103  double getFlux() const { return itsSumFlux; }
104 
106  double getRa() const {
107  return std::atan2(itsSumY / itsSumFlux, itsSumX / itsSumFlux);
108  }
109  double getDec() const { return std::asin(itsSumZ / itsSumFlux); }
110 
112  unsigned int getPatchId() const { return itsPatchId; }
113 
114  private:
115  double itsSumX;
116  double itsSumY;
117  double itsSumZ;
118  double itsSumFlux;
119  unsigned int itsPatchId;
120 };
121 
125 void toSkymodel(std::ostream& output, const PatchInfo& patch);
126 
128 
129 } // namespace parmdb
130 } // namespace dp3
131 
132 #endif
Input stream for a blob.
Definition: BlobIStream.h:43
Output stream for a blob.
Definition: BlobOStream.h:40
Info about a patch.
Definition: PatchInfo.h:29
PatchInfo(const std::string &name, double ra, double dec, int category, double apparentBrightness)
Definition: PatchInfo.h:36
double getRa() const
Get the right ascension in radians (J2000).
Definition: PatchInfo.h:48
const std::string & getName() const
Get the patch name.
Definition: PatchInfo.h:45
double getDec() const
Get the declination in radians (J2000).
Definition: PatchInfo.h:51
double apparentBrightness() const
Get the apparent brightness of the patch (in Jy).
Definition: PatchInfo.h:57
void setDec(double dec)
Set the declination in radians (J2000).
Definition: PatchInfo.h:63
void setApparentBrightness(double apparentBrightness)
Set the apparent brightness of the patch (in Jy).
Definition: PatchInfo.h:66
int getCategory() const
Get the category.
Definition: PatchInfo.h:54
PatchInfo()
Default constructor.
Definition: PatchInfo.h:32
void setRa(double ra)
Set the right ascension in radians (J2000).
Definition: PatchInfo.h:60
Info about a patch direction.
Definition: PatchInfo.h:88
unsigned int getPatchId() const
Get the patchId.
Definition: PatchInfo.h:112
void add(double ra, double dec, double flux)
Add a source direction to determine the average patch direction.
double getFlux() const
Get the total flux of the patch.
Definition: PatchInfo.h:103
double getDec() const
Definition: PatchInfo.h:109
double getRa() const
Get the patch direction (flux-weighted average direction of its sources).
Definition: PatchInfo.h:106
PatchSumInfo(unsigned int patchId)
Definition: PatchInfo.h:92
std::ostream & operator<<(std::ostream &os, const PatchInfo &info)
Show the contents of a PatchInfo object.
blob::BlobIStream operator>>(blob::BlobIStream &os, PatchInfo &info)
Read the contents of a PatchInfo object from a blob.
void toSkymodel(std::ostream &output, const PatchInfo &patch)
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53