lsst.jointcal  21.0.0-20-g3b2d1f0+b95b9e7887
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 
82  Associations(CcdImageList const &imageList)
83  : ccdImageList(imageList),
84  _commonTangentPoint(Point(std::numeric_limits<double>::quiet_NaN(),
85  std::numeric_limits<double>::quiet_NaN())),
86  _maxMeasuredStars(0) {}
87 
89  Associations(Associations const &) = delete;
90  Associations(Associations &&) = delete;
91  Associations &operator=(Associations const &) = delete;
93 
98 
104  void setCommonTangentPoint(lsst::geom::Point2D const &commonTangentPoint);
105 
107  Point getCommonTangentPoint() const { return _commonTangentPoint; }
108 
109  size_t getMaxMeasuredStars() const { return _maxMeasuredStars; }
110 
127  std::string const &filter, std::shared_ptr<afw::image::PhotoCalib> photoCalib,
128  std::shared_ptr<afw::cameraGeom::Detector> detector, int visit, int ccd,
129  lsst::jointcal::JointcalControl const &control);
130 
134  void addCcdImage(std::shared_ptr<CcdImage> const ccdImage) { ccdImageList.push_back(ccdImage); }
135 
137  void associateCatalogs(const double matchCutInArcsec = 0, const bool useFittedList = false,
138  const bool enlargeFittedList = true);
139 
154  std::string const &fluxField, float refCoordinateErr, bool rejectBadFluxes = false);
155 
158  void deprojectFittedStars();
159 
161 /* If Color is "g-i", then the color is assigned from columns "g" and "i" of the colored catalog. */
162 #ifdef TODO
163  void setFittedStarColors(std::string const &dicStarListName, std::string const &color,
164  double matchCutArcSec);
165 #endif
166 
172  void prepareFittedStars(int minMeasurements);
173 
182  void cleanFittedStars();
183 
184  CcdImageList const &getCcdImageList() const { return ccdImageList; }
185 
187  unsigned getNFilters() const { return 1; }
188 
196 
200  int nCcdImagesValidForFit() const;
201 
205  size_t nFittedStarsWithAssociatedRefStar() const;
206 
207 private:
208  void associateRefStars(double matchCutInArcsec, const AstrometryTransform *transform);
209 
210  void assignMags();
211 
217  void selectFittedStars(int minMeasurements);
218 
225  void normalizeFittedStars();
226 
227  Point _commonTangentPoint;
228 
229  // The number of MeasuredStars at the start of fitting, before any outliers are removed.
230  // This is used to reserve space in vectors for e.g. outlier removal, but is not updated during outlier
231  // removal or cleanup, so should only be used as an upper bound on the number of MeasuredStars.
232  size_t _maxMeasuredStars;
233 };
234 
235 } // namespace jointcal
236 } // namespace lsst
237 #endif // LSST_JOINTCAL_ASSOCIATIONS_H
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:184
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.
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:187
Associations(Associations &&)=delete
Associations(CcdImageList const &imageList)
Create an Associations object from a pre-built list of ccdImages.
Definition: Associations.h:82
size_t getMaxMeasuredStars() const
Definition: Associations.h:109
void setCommonTangentPoint(lsst::geom::Point2D const &commonTangentPoint)
Sets a shared tangent point for all ccdImages.
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
Point getCommonTangentPoint() const
can be used to project sidereal coordinates related to the image set on a plane.
Definition: Associations.h:107
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)
Set the color field of FittedStar 's from a colored catalog.
void addCcdImage(std::shared_ptr< CcdImage > const ccdImage)
Add a pre-constructed ccdImage to the ccdImageList.
Definition: Associations.h:134
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:123
A point in a plane.
Definition: Point.h:37
Class for a simple mapping implementing a generic AstrometryTransform.
STL namespace.
T push_back(T... args)
T size(T... args)