lsst.jointcal  16.0-26-g3163dd8
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/afw/geom/Box.h"
38 
39 #include "lsst/jointcal/RefStar.h"
41 #include "lsst/jointcal/CcdImage.h"
42 #include "lsst/jointcal/Point.h"
44 
46 
47 namespace lsst {
48 namespace jointcal {
49 
51 
53 class Associations {
54 public:
55  CcdImageList ccdImageList; // the catalog handlers
56  RefStarList refStarList; // e.g. GAIA or SDSS reference stars
57  FittedStarList fittedStarList; // stars that are going to be fitted
58 
59  // These are strictly speaking not needed anymore (after DM-4043),
60  // but keeping them seems cleaner then exposing the lists themselves.
61  size_t refStarListSize() { return refStarList.size(); }
62  size_t fittedStarListSize() { return fittedStarList.size(); }
63 
69  : _commonTangentPoint(Point(std::numeric_limits<double>::quiet_NaN(),
70  std::numeric_limits<double>::quiet_NaN())) {}
71 
80  Associations(CcdImageList const &imageList)
81  : ccdImageList(imageList),
82  _commonTangentPoint(Point(std::numeric_limits<double>::quiet_NaN(),
83  std::numeric_limits<double>::quiet_NaN())) {}
84 
86  Associations(Associations const &) = delete;
87  Associations(Associations &&) = delete;
88  Associations &operator=(Associations const &) = delete;
89  Associations &operator=(Associations &&) = delete;
90 
95 
101  void setCommonTangentPoint(lsst::afw::geom::Point2D const &commonTangentPoint);
102 
104  Point getCommonTangentPoint() const { return _commonTangentPoint; }
105 
122  lsst::afw::geom::Box2I const &bbox, std::string const &filter,
125  lsst::jointcal::JointcalControl const &control);
126 
128  void associateCatalogs(const double matchCutInArcsec = 0, const bool useFittedList = false,
129  const bool enlargeFittedList = true);
130 
143  void collectRefStars(afw::table::SimpleCatalog &refCat, afw::geom::Angle matchCut,
144  std::string const &fluxField, RefFluxMapType const &refFluxMap = RefFluxMapType(),
145  RefFluxMapType const &refFluxErrMap = RefFluxMapType(),
146  bool rejectBadFluxes = false);
147 
150  void deprojectFittedStars();
151 
153 /* If Color is "g-i", then the color is assigned from columns "g" and "i" of the colored catalog. */
154 #ifdef TODO
155  void setFittedStarColors(std::string const &dicStarListName, std::string const &color,
156  double matchCutArcSec);
157 #endif
158 
164  void prepareFittedStars(int minMeasurements);
165 
166  CcdImageList const &getCcdImageList() const { return ccdImageList; }
167 
169  unsigned getNFilters() const { return _filterMap.size(); }
170 
171  // Return the bounding box in (ra, dec) coordinates containing the whole catalog
172  const lsst::afw::geom::Box2D getRaDecBBox();
173 
177  int nCcdImagesValidForFit() const;
178 
182  size_t nFittedStarsWithAssociatedRefStar() const;
183 
184 private:
185  void associateRefStars(double matchCutInArcsec, const AstrometryTransform *transform);
186 
187  void assignMags();
188 
194  void selectFittedStars(int minMeasurements);
195 
202  void normalizeFittedStars() const;
203 
204  // Map from filter name to index in each refStar's _refFlux/_refFluxErr vector.
206 
207  Point _commonTangentPoint;
208 };
209 
210 } // namespace jointcal
211 } // namespace lsst
212 #endif // LSST_JOINTCAL_ASSOCIATIONS_H
unsigned getNFilters() const
Number of different bands in the input image list. Not implemented so far.
Definition: Associations.h:169
int nCcdImagesValidForFit() const
return the number of CcdImages with non-empty catalogs to-be-fit.
A point in a plane.
Definition: Point.h:36
table::Box2IKey bbox
table::Key< int > detector
STL namespace.
Point getCommonTangentPoint() const
can be used to project sidereal coordinates related to the image set on a plane.
Definition: Associations.h:104
STL class.
The class that implements the relations between MeasuredStar and FittedStar.
Definition: Associations.h:53
void associateCatalogs(const double matchCutInArcsec=0, const bool useFittedList=false, const bool enlargeFittedList=true)
incrementaly builds a merged catalog of all image catalogs
Definition: Associations.cc:91
STL class.
void prepareFittedStars(int minMeasurements)
Set the color field of FittedStar &#39;s from a colored catalog.
size_t nFittedStarsWithAssociatedRefStar() const
Return the number of fittedStars that have an associated refStar.
void collectRefStars(afw::table::SimpleCatalog &refCat, afw::geom::Angle matchCut, std::string const &fluxField, RefFluxMapType const &refFluxMap=RefFluxMapType(), RefFluxMapType const &refFluxErrMap=RefFluxMapType(), bool rejectBadFluxes=false)
Collect stars from an external reference catalog and associate them with fittedStars.
table::Key< table::Array< std::uint8_t > > wcs
Class for a simple mapping implementing a generic AstrometryTransform.
std::map< std::string, std::vector< double > > RefFluxMapType
Definition: Associations.h:50
table::Key< int > transform
void computeCommonTangentPoint()
Sets a shared tangent point for all ccdImages, using the mean of the centers of all ccdImages...
Definition: Associations.cc:75
A list of FittedStar s. Such a list is typically constructed by Associations.
Definition: FittedStar.h:122
void deprojectFittedStars()
Sends back the fitted stars coordinates on the sky FittedStarsList::inTangentPlaneCoordinates keeps t...
CcdImageList const & getCcdImageList() const
Definition: Associations.h:166
void setCommonTangentPoint(lsst::afw::geom::Point2D const &commonTangentPoint)
Sets a shared tangent point for all ccdImages.
Definition: Associations.cc:86
T size(T... args)
Key< int > visitInfo
void createCcdImage(afw::table::SourceCatalog &catalog, std::shared_ptr< lsst::afw::geom::SkyWcs > wcs, std::shared_ptr< lsst::afw::image::VisitInfo > visitInfo, lsst::afw::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:61
a virtual (interface) class for geometric transformations.
const lsst::afw::geom::Box2D getRaDecBBox()
Associations()
Source selection is performed in python, so Associations&#39; constructor only initializes a couple of va...
Definition: Associations.h:68
Associations(CcdImageList const &imageList)
Create an Associations object from a pre-built list of ccdImages.
Definition: Associations.h:80
Associations & operator=(Associations const &)=delete
FittedStarList fittedStarList
Definition: Associations.h:57