LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
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 boost::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 boost::make_shared<ExposurePatch<ExposureT> >(exp, standardFoot, standardCenter, standardWcs);
101 }
102 
103 }}} // namespace
104 
105 #endif
#define CONST_PTR(...)
Definition: base.h:47
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:940
afw::geom::Point2D const & getCenter() const
Definition: ExposurePatch.h:69
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g. RA/dec) to pixel positions.
Definition: Wcs.cc:788
unsigned char FlagT
Type for flags.
Definition: ExposurePatch.h:41
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
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
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g. RA/dec)
Definition: Wcs.cc:864
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:70
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
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:987
Point< double, 2 > Point2D
Definition: Point.h:286
boost::shared_ptr< Coord const > ConstPtr
Definition: Coord.h:73
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