LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
ExposurePatch.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #if !defined(LSST_MEAS_ALGORITHMS_EXPOSURE_PATCH_H)
26 #define LSST_MEAS_ALGORITHMS_EXPOSURE_PATCH_H
27 
28 #include "lsst/base.h"
30 #include "lsst/afw/image/Wcs.h"
32 
33 namespace lsst { namespace meas { namespace algorithms {
34 
38 template<typename ExposureT>
40 public:
41  typedef unsigned char FlagT;
42  typedef PTR(ExposurePatch) Ptr;
44 
46  ExposurePatch(CONST_PTR(ExposureT) exp,
47  CONST_PTR(afw::detection::Footprint) foot,
48  afw::geom::Point2D const& center
49  ): _exp(exp), _foot(foot), _center(center), _fromStandard(), _toStandard() {}
50  ExposurePatch(CONST_PTR(ExposureT) exp,
51  afw::detection::Footprint const& standardFoot,
52  afw::geom::Point2D const& standardCenter,
53  afw::image::Wcs const& standardWcs
54  ) : _exp(exp) {
55  afw::image::Wcs const& expWcs = *exp->getWcs();
56  afw::coord::Coord::ConstPtr sky = standardWcs.pixelToSky(standardCenter);
57  const_cast<CONST_PTR(afw::detection::Footprint)&>(_foot) = standardFoot.transform(standardWcs, expWcs,
58  exp->getBBox());
59  const_cast<afw::geom::Point2D&>(_center) = expWcs.skyToPixel(*sky);
60  const_cast<afw::geom::AffineTransform&>(_fromStandard) = standardWcs.linearizePixelToSky(*sky) *
61  expWcs.linearizeSkyToPixel(*sky);
62  const_cast<afw::geom::AffineTransform&>(_toStandard) = expWcs.linearizePixelToSky(*sky) *
63  standardWcs.linearizeSkyToPixel(*sky);
64  }
65 
67  CONST_PTR(ExposureT) const getExposure() const { return _exp; }
69  afw::geom::Point2D const& getCenter() const { return _center; }
72 
74  void setCenter(afw::geom::Point2D const& center) { _center = center; }
75 
76 private:
77  CONST_PTR(ExposureT) const _exp;
78  CONST_PTR(afw::detection::Footprint) const _foot;
79  afw::geom::Point2D _center;
80  afw::geom::AffineTransform const _fromStandard;
81  afw::geom::AffineTransform const _toStandard;
82 };
83 
85 template<typename ExposureT>
87  CONST_PTR(ExposureT) exp,
88  CONST_PTR(afw::detection::Footprint) foot,
89  afw::geom::Point2D const& center
90  ) {
91  return std::make_shared<ExposurePatch<ExposureT> >(exp, foot, center);
92 }
93 template<typename ExposureT>
95  CONST_PTR(ExposureT) exp,
96  afw::detection::Footprint const& standardFoot,
97  afw::geom::Point2D const& standardCenter,
98  afw::image::Wcs const& standardWcs
99  ) {
100  return std::make_shared<ExposurePatch<ExposureT> >(exp, standardFoot, standardCenter, standardWcs);
101 }
102 
103 }}} // namespace
104 
105 #endif
void setCenter(afw::geom::Point2D const &center)
Modifiers.
Definition: ExposurePatch.h:74
Represent a set of pixels of an arbitrary shape and size.
boost::shared_ptr< ExposureT const > const getExposure() const
Accessors.
Definition: ExposurePatch.h:67
geom::AffineTransform linearizePixelToSky(coord::Coord const &coord, geom::AngleUnit skyUnit=geom::degrees) const
Return the local linear approximation to Wcs::pixelToSky at a point given in sky coordinates.
Definition: Wcs.cc:929
afw::geom::Point2D const & getCenter() const
Definition: ExposurePatch.h:69
A convenience container for the exposure, peak and footprint that will be measured.
Definition: ExposurePatch.h:39
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g.
Definition: Wcs.cc:796
unsigned char FlagT
Type for flags.
Definition: ExposurePatch.h:41
lsst::afw::detection::Footprint Footprint
Definition: Source.h:60
ExposurePatch(boost::shared_ptr< ExposureT const > exp, afw::detection::Footprint const &standardFoot, afw::geom::Point2D const &standardCenter, afw::image::Wcs const &standardWcs)
Definition: ExposurePatch.h:50
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
boost::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:886
boost::shared_ptr< ExposurePatch const > ConstPtr
Definition: ExposurePatch.h:43
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::shared_ptr< ExposurePatch< ExposureT > > makeExposurePatch(boost::shared_ptr< ExposureT const > exp, boost::shared_ptr< afw::detection::Footprint const > foot, afw::geom::Point2D const &center)
Factory function for ExposurePatch.
Definition: ExposurePatch.h:86
boost::shared_ptr< ExposureT const > const _exp
Exposure to be measured.
Definition: ExposurePatch.h:77
An affine coordinate transformation consisting of a linear transformation and an offset.
boost::shared_ptr< ExposurePatch > Ptr
Definition: ExposurePatch.h:42
afw::geom::AffineTransform const & fromStandard() const
Definition: ExposurePatch.h:70
A set of pixels in an Image.
Definition: Footprint.h:62
afw::geom::Point2D _center
Center of source on exposure.
Definition: ExposurePatch.h:79
boost::shared_ptr< Footprint > transform(image::Wcs const &source, image::Wcs const &target, geom::Box2I const &region, bool doClip=true) const
Transform the footprint from one WCS to another.
afw::geom::AffineTransform const & toStandard() const
Definition: ExposurePatch.h:71
#define PTR(...)
Definition: base.h:41
geom::AffineTransform linearizeSkyToPixel(coord::Coord const &coord, geom::AngleUnit skyUnit=geom::degrees) const
Return the local linear approximation to Wcs::skyToPixel at a point given in sky coordinates.
Definition: Wcs.cc:976
Point< double, 2 > Point2D
Definition: Point.h:288
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
Basic LSST definitions.
afw::geom::AffineTransform const _fromStandard
Transform from standard WCS.
Definition: ExposurePatch.h:80
boost::shared_ptr< afw::detection::Footprint const > const getFootprint() const
Definition: ExposurePatch.h:68
afw::geom::AffineTransform const _toStandard
Transform to standard WCS.
Definition: ExposurePatch.h:81
boost::shared_ptr< afw::detection::Footprint const > const _foot
Footprint to be measured.
Definition: ExposurePatch.h:78