LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
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