LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Associations.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_ASSOCIATIONS_H
26 #define LSST_JOINTCAL_ASSOCIATIONS_H
27 
28 #include <string>
29 #include <iostream>
30 #include <list>
31 
32 #include "lsst/afw/table/Source.h"
33 #include "lsst/afw/geom/SkyWcs.h"
34 #include "lsst/afw/image/Calib.h"
37 #include "lsst/geom/Box.h"
38 #include "lsst/sphgeom/Circle.h"
39 
40 #include "lsst/jointcal/RefStar.h"
42 #include "lsst/jointcal/CcdImage.h"
43 #include "lsst/jointcal/Point.h"
45 
47 
48 namespace lsst {
49 namespace jointcal {
50 
52 
54 class Associations {
55 public:
56  CcdImageList ccdImageList; // the catalog handlers
57  RefStarList refStarList; // e.g. GAIA or SDSS reference stars
58  FittedStarList fittedStarList; // stars that are going to be fitted
59 
60  // These are strictly speaking not needed anymore (after DM-4043),
61  // but keeping them seems cleaner then exposing the lists themselves.
62  size_t refStarListSize() { return refStarList.size(); }
63  size_t fittedStarListSize() { return fittedStarList.size(); }
64 
70  : _commonTangentPoint(Point(std::numeric_limits<double>::quiet_NaN(),
71  std::numeric_limits<double>::quiet_NaN())),
72  _maxMeasuredStars(0) {}
73 
83  Associations(CcdImageList const &imageList, double epoch = 0)
84  : ccdImageList(imageList),
85  _commonTangentPoint(Point(std::numeric_limits<double>::quiet_NaN(),
86  std::numeric_limits<double>::quiet_NaN())),
87  _maxMeasuredStars(0),
88  _epoch(epoch) {}
89 
91  Associations(Associations const &) = delete;
92  Associations(Associations &&) = delete;
93  Associations &operator=(Associations const &) = delete;
95 
100 
107  void setCommonTangentPoint(lsst::geom::Point2D const &commonTangentPoint);
108  Point getCommonTangentPoint() const { return _commonTangentPoint; }
110 
112  size_t getMaxMeasuredStars() const { return _maxMeasuredStars; }
113 
118  double getEpoch() const { return _epoch; }
119  void setEpoch(double epoch) { _epoch = epoch; }
121 
140  lsst::jointcal::JointcalControl const &control);
141 
145  void addCcdImage(std::shared_ptr<CcdImage> const ccdImage) { ccdImageList.push_back(ccdImage); }
146 
148  void associateCatalogs(const double matchCutInArcsec = 0, const bool useFittedList = false,
149  const bool enlargeFittedList = true);
150 
165  std::string const &fluxField, float refCoordinateErr, bool rejectBadFluxes = false);
166 
169  void deprojectFittedStars();
170 
176  void prepareFittedStars(int minMeasurements);
177 
186  void cleanFittedStars();
187 
188  CcdImageList const &getCcdImageList() const { return ccdImageList; }
189 
191  unsigned getNFilters() const { return 1; }
192 
200 
204  int nCcdImagesValidForFit() const;
205 
209  size_t nFittedStarsWithAssociatedRefStar() const;
210 
211 private:
212  void associateRefStars(double matchCutInArcsec, const AstrometryTransform *transform);
213 
214  void assignMags();
215 
221  void selectFittedStars(int minMeasurements);
222 
229  void normalizeFittedStars();
230 
231  // Common tangent point on-sky of all of the ccdImages, typically determined by computeCommonTangentPoint.
232  // (decimal degrees)
233  Point _commonTangentPoint;
234 
235  // The number of MeasuredStars at the start of fitting, before any outliers are removed.
236  // This is used to reserve space in vectors for e.g. outlier removal, but is not updated during outlier
237  // removal or cleanup, so should only be used as an upper bound on the number of MeasuredStars.
238  size_t _maxMeasuredStars;
239 
240  // Julian Epoch Year (e.g. 2000.0 for J2000)
241  // Common epoch of all of the ccdImages, typically computed externally via astropy and then set.
242  double _epoch;
243 };
244 
245 } // namespace jointcal
246 } // namespace lsst
247 #endif // LSST_JOINTCAL_ASSOCIATIONS_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
This file declares a class for representing circular regions on the unit sphere.
table::Key< int > detector
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:66
table::Key< int > transform
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
Definition: SortedCatalog.h:42
A class representing an angle.
Definition: Angle.h:127
An integer coordinate rectangle.
Definition: Box.h:55
The class that implements the relations between MeasuredStar and FittedStar.
Definition: Associations.h:54
size_t nFittedStarsWithAssociatedRefStar() const
Return the number of fittedStars that have an associated refStar.
CcdImageList const & getCcdImageList() const
Definition: Associations.h:188
void cleanFittedStars()
Remove FittedStars that have no measured stars; this can happen after outlier rejection.
void computeCommonTangentPoint()
Sets a shared tangent point for all ccdImages, using the mean of the centers of all ccdImages.
Definition: Associations.cc:74
Associations()
Source selection is performed in python, so Associations' constructor only initializes a couple of va...
Definition: Associations.h:69
lsst::sphgeom::Circle computeBoundingCircle() const
Return the bounding circle in on-sky (RA, Dec) coordinates containing all CcdImages.
Definition: Associations.cc:90
int nCcdImagesValidForFit() const
return the number of CcdImages with non-empty catalogs to-be-fit.
Associations(Associations const &)=delete
No moves or copies: jointcal only ever needs one Associations object.
void setEpoch(double epoch)
Common epoch of all of the ccdImages as a Julian Epoch Year (e.g.
Definition: Associations.h:119
Associations(CcdImageList const &imageList, double epoch=0)
Create an Associations object from a pre-built list of ccdImages.
Definition: Associations.h:83
Associations & operator=(Associations &&)=delete
void createCcdImage(afw::table::SourceCatalog &catalog, std::shared_ptr< lsst::afw::geom::SkyWcs > wcs, std::shared_ptr< lsst::afw::image::VisitInfo > visitInfo, lsst::geom::Box2I const &bbox, std::string const &filter, std::shared_ptr< afw::image::PhotoCalib > photoCalib, std::shared_ptr< afw::cameraGeom::Detector > detector, int visit, int ccd, lsst::jointcal::JointcalControl const &control)
Create a ccdImage from an exposure catalog and metadata, and add it to the list.
Definition: Associations.cc:62
unsigned getNFilters() const
Number of different bands in the input image list. Not implemented so far.
Definition: Associations.h:191
Associations(Associations &&)=delete
size_t getMaxMeasuredStars() const
The number of MeasuredStars at the start of fitting, before any outliers are removed.
Definition: Associations.h:112
void setCommonTangentPoint(lsst::geom::Point2D const &commonTangentPoint)
Shared tangent point for all ccdImages (decimal degrees).
Definition: Associations.cc:85
void associateCatalogs(const double matchCutInArcsec=0, const bool useFittedList=false, const bool enlargeFittedList=true)
incrementaly builds a merged catalog of all image catalogs
double getEpoch() const
Common epoch of all of the ccdImages as a Julian Epoch Year (e.g.
Definition: Associations.h:118
Point getCommonTangentPoint() const
Shared tangent point for all ccdImages (decimal degrees).
Definition: Associations.h:108
void collectRefStars(afw::table::SimpleCatalog &refCat, geom::Angle matchCut, std::string const &fluxField, float refCoordinateErr, bool rejectBadFluxes=false)
Collect stars from an external reference catalog and associate them with fittedStars.
Associations & operator=(Associations const &)=delete
FittedStarList fittedStarList
Definition: Associations.h:58
void prepareFittedStars(int minMeasurements)
Prepare the fittedStar list by making quality cuts and normalizing measurements.
void addCcdImage(std::shared_ptr< CcdImage > const ccdImage)
Add a pre-constructed ccdImage to the ccdImageList.
Definition: Associations.h:145
void deprojectFittedStars()
Sends back the fitted stars coordinates on the sky FittedStarsList::inTangentPlaneCoordinates keeps t...
a virtual (interface) class for geometric transformations.
A list of FittedStar s. Such a list is typically constructed by Associations.
Definition: FittedStar.h:116
A point in a plane.
Definition: Point.h:37
Circle is a circular region on the unit sphere that contains its boundary.
Definition: Circle.h:46
A base class for image defects.
STL namespace.
T push_back(T... args)
T size(T... args)
Key< int > visitInfo
Definition: Exposure.cc:70
Key< int > photoCalib
Definition: Exposure.cc:67