lsst.jointcal  16.0-23-gcb65559+3
CcdImage.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * This file is part of jointcal.
4  *
5  * Developed for the LSST Data Management System.
6  * This product includes software developed by the LSST Project
7  * (https://www.lsst.org).
8  * See the COPYRIGHT file at the top-level directory of this distribution
9  * for details of code ownership.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef LSST_JOINTCAL_CCD_IMAGE_H
26 #define LSST_JOINTCAL_CCD_IMAGE_H
27 
28 #include <list>
29 #include <string>
30 
32 #include "lsst/afw/table/Source.h"
33 #include "lsst/afw/geom/SkyWcs.h"
37 #include "lsst/afw/geom/Box.h"
40 #include "lsst/jointcal/Gtransfo.h"
41 #include "lsst/jointcal/Frame.h"
42 
43 namespace lsst {
44 namespace jointcal {
45 
47 
48 typedef int VisitIdType;
49 typedef int CcdIdType;
51 struct CcdImageKey {
52  VisitIdType visit;
53  CcdIdType ccd;
54  bool operator!=(CcdImageKey const &right) const { return !(*this == right); }
55  bool operator==(CcdImageKey const &right) const { return (visit == right.visit) && (ccd == right.ccd); }
56 };
57 // typedef std::pair<VisitIdType, CcdIdType> CcdImageKey;
59 
64 class CcdImage {
65 public:
68  std::string const &filter, std::shared_ptr<afw::image::PhotoCalib> photoCalib,
70  std::string const &fluxField);
71 
73  CcdImage(CcdImage const &) = delete;
74  CcdImage(CcdImage &&) = delete;
75  CcdImage &operator=(CcdImage const &) = delete;
76  CcdImage &operator=(CcdImage &&) = delete;
77 
79  std::string getName() const { return _name; }
80 
86  MeasuredStarList const &getWholeCatalog() const { return _wholeCatalog; }
87 
89 
94  MeasuredStarList const &getCatalogForFit() const { return _catalogForFit; }
95  MeasuredStarList &getCatalogForFit() { return _catalogForFit; }
97 
100  getCatalogForFit().clear();
101  getWholeCatalog().copyTo(getCatalogForFit());
102  }
103 
112  std::pair<int, int> countStars() const;
113 
119  void setCommonTangentPoint(Point const &commonTangentPoint);
120 
126  Point const &getCommonTangentPoint() const { return _commonTangentPoint; }
127 
129  Gtransfo const *getPix2CommonTangentPlane() const { return _pix2CommonTangentPlane.get(); }
130 
132  Gtransfo const *getCommonTangentPlane2TP() const { return _CTP2TP.get(); }
133 
135  Gtransfo const *getTP2CommonTangentPlane() const { return _TP2CTP.get(); }
136 
138  Gtransfo const *getPix2TangentPlane() const { return _pix2TP.get(); }
139 
141  Gtransfo const *getSky2TP() const { return _sky2TP.get(); }
142 
144  CcdIdType getCcdId() const { return _ccdId; }
145 
147  VisitIdType getVisit() const { return _visit; }
148 
150 
151  CcdImageKey getHashKey() const { return CcdImageKey{_visit, _ccdId}; }
152 
154  double getAirMass() const { return _airMass; }
155 
157  double getMjd() const { return _mjd; }
158 
161 
165  lsst::afw::geom::SpherePoint getBoresightRaDec() const { return _boresightRaDec; }
166 
168  double getHourAngle() const { return _hourAngle; }
169 
171  double getSinEta() const { return _sineta; }
172 
174  double getCosEta() const { return _coseta; }
175 
177  double getTanZ() const { return _tgz; }
178 
180  Point getRefractionVector() const { return Point(_tgz * _coseta, _tgz * _sineta); }
181 
183  std::string getFilter() const { return _filter; }
184 
186  Gtransfo const *readWCS() const { return _readWcs.get(); }
187 
189  Frame const &getImageFrame() const { return _imageFrame; }
190 
191 private:
193  std::string const &fluxField);
194 
195  Frame _imageFrame; // in pixels
196 
197  MeasuredStarList _wholeCatalog; // the catalog of measured objets
198  MeasuredStarList _catalogForFit;
199 
200  std::shared_ptr<GtransfoSkyWcs> _readWcs; // apply goes from pix to sky
201 
202  // The following ones should probably be mostly removed.
203  std::shared_ptr<Gtransfo> _CTP2TP; // go from CommonTangentPlane to this tangent plane.
204  std::shared_ptr<Gtransfo> _TP2CTP; // reverse one
205  std::shared_ptr<Gtransfo> _pix2CommonTangentPlane; // pixels -> CTP
207 
209 
210  std::string _name;
211  CcdIdType _ccdId;
212  VisitIdType _visit;
213 
214  lsst::afw::geom::SpherePoint _boresightRaDec;
215  double _airMass; // airmass value.
216  double _mjd; // modified julian date
219  // refraction
220  // eta : parallactic angle, z: zenithal angle (X = 1/cos(z))
221  double _sineta, _coseta, _tgz;
222  // Local Sidereal Time and hour angle of observation
223  double _lstObs, _hourAngle;
224 
225  std::string _filter;
226 
227  Point _commonTangentPoint;
228 };
229 } // namespace jointcal
230 } // namespace lsst
231 
232 // Add our preferred hash of CcdImageKey to the std:: namespace, so it's always available "for free".
233 namespace std {
234 template <>
242  size_t operator()(lsst::jointcal::CcdImageKey const &key) const {
243  return hash<size_t>()(static_cast<size_t>(key.visit) | (static_cast<size_t>(key.ccd) << 32));
244  }
245 };
246 } // namespace std
247 
248 #endif // LSST_JOINTCAL_CCD_IMAGE_H
VisitIdType getVisit() const
returns visit ID
Definition: CcdImage.h:147
Gtransfo const * getCommonTangentPlane2TP() const
Definition: CcdImage.h:132
std::ostream & operator<<(std::ostream &out, CcdImageKey const &key)
Definition: CcdImage.cc:52
A point in a plane.
Definition: Point.h:36
bool operator==(CcdImageKey const &right) const
Definition: CcdImage.h:55
Gtransfo const * getSky2TP() const
Definition: CcdImage.h:141
double getCosEta() const
Parallactic angle.
Definition: CcdImage.h:174
std::string getName() const
Return the _name that identifies this ccdImage.
Definition: CcdImage.h:79
table::Box2IKey bbox
Gtransfo const * getPix2CommonTangentPlane() const
Definition: CcdImage.h:129
table::Key< int > detector
For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage.
Definition: CcdImage.h:51
double getMjd() const
Julian Date.
Definition: CcdImage.h:157
STL namespace.
CcdIdType getCcdId() const
returns ccd ID
Definition: CcdImage.h:144
Gtransfo const * getPix2TangentPlane() const
Definition: CcdImage.h:138
double getSinEta() const
Parallactic angle.
Definition: CcdImage.h:171
A list of MeasuredStar. They are usually filled in Associations::createCcdImage.
Definition: MeasuredStar.h:141
STL class.
void resetCatalogForFit()
Clear the catalog for fitting and set it to a copy of the whole catalog.
Definition: CcdImage.h:99
std::shared_ptr< afw::image::PhotoCalib > getPhotoCalib() const
Return the exposure&#39;s photometric calibration.
Definition: CcdImage.h:160
lsst::afw::geom::SpherePoint getBoresightRaDec() const
Gets the boresight RA/Dec.
Definition: CcdImage.h:165
rectangle with sides parallel to axes.
Definition: Frame.h:38
table::Key< table::Array< std::uint8_t > > wcs
MeasuredStarList & getCatalogForFit()
Gets the catalog to be used for fitting, which may have been cleaned-up.
Definition: CcdImage.h:95
Class for a simple mapping implementing a generic Gtransfo.
Gtransfo const * getTP2CommonTangentPlane() const
Definition: CcdImage.h:135
size_t operator()(lsst::jointcal::CcdImageKey const &key) const
Definition: CcdImage.h:242
Key< U > key
double getHourAngle() const
Definition: CcdImage.h:168
STL class.
double getAirMass() const
Airmass.
Definition: CcdImage.h:154
Key< int > visitInfo
double getTanZ() const
Parallactic angle.
Definition: CcdImage.h:177
Point getRefractionVector() const
Definition: CcdImage.h:180
MeasuredStarList const & getCatalogForFit() const
Gets the catalog to be used for fitting, which may have been cleaned-up.
Definition: CcdImage.h:94
a virtual (interface) class for geometric transformations.
Definition: Gtransfo.h:65
std::string getFilter() const
return the CcdImage filter name
Definition: CcdImage.h:183
Gtransfo const * readWCS() const
the wcs read in the header. NOT updated when fitting.
Definition: CcdImage.h:186
bool operator!=(CcdImageKey const &right) const
Definition: CcdImage.h:54
std::list< std::shared_ptr< CcdImage > > CcdImageList
Definition: CcdImage.h:46
int VisitIdType
Definition: CcdImage.h:48
CcdImageKey getHashKey() const
Definition: CcdImage.h:151
std::shared_ptr< afw::cameraGeom::Detector > getDetector() const
Definition: CcdImage.h:149
Handler of an actual image from a single CCD.
Definition: CcdImage.h:64
STL class.
Point const & getCommonTangentPoint() const
Gets the common tangent point, shared between all ccdImages.
Definition: CcdImage.h:126
MeasuredStarList const & getWholeCatalog() const
Gets the as-read catalog.
Definition: CcdImage.h:86
Frame const & getImageFrame() const
Frame in pixels.
Definition: CcdImage.h:189