lsst.meas.algorithms  13.0-24-g22030a45+3
BinnedWcs.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3 * LSST Data Management System
4 * See COPYRIGHT file at the top of the source tree.
5 *
6 * This product includes software developed by the
7 * LSST Project (http://www.lsst.org/).
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the LSST License Statement and
20 * the GNU General Public License along with this program. If not,
21 * see <http://www.lsstcorp.org/LegalNotices/>.
22 */
23 
25 #include "wcslib/wcs.h" // Unfortunate, but necessary due to parent class mixing implementation and interface
26 
27 namespace lsst { namespace meas { namespace algorithms {
28 
30  PTR(afw::image::Wcs) parent,
31  unsigned int xBin,
32  unsigned int yBin,
34  ) :
35  afw::image::Wcs(*parent), // We have to inherit the implementation as well as the interface...
36  _parent(parent), _xBin(xBin), _yBin(yBin), _xy0(xy0),
37  _binnedToOriginal(afw::geom::AffineTransform::makeTranslation(afw::geom::Extent2D(_xy0))*
38  afw::geom::AffineTransform::makeScaling(_xBin, _yBin)),
39  _originalToBinned(_binnedToOriginal.invert())
40 {
41  // Correct CRPIX
42  afw::geom::Point2D const crpix = _originalToBinned(parent->getPixelOrigin());
43  _wcsInfo->crpix[0] = crpix.getX() + 1; // convert LSST --> FITS
44  _wcsInfo->crpix[1] = crpix.getY() + 1; // convert LSST --> FITS
45 }
46 
47 
48 void BinnedWcs::pixelToSkyImpl(double x, double y, afw::geom::Angle skyTmp[2]) const
49 {
50  PTR(afw::coord::Coord) coord = _parent->pixelToSky(_binnedToOriginal(afw::geom::Point2D(x, y)));
51  skyTmp[0] = coord->getLongitude();
52  skyTmp[1] = coord->getLatitude();
53 }
54 
55 afw::geom::Point2D BinnedWcs::skyToPixelImpl(afw::geom::Angle sky1, afw::geom::Angle sky2) const
56 {
57  return _originalToBinned(_parent->skyToPixel(*makeCorrectCoord(sky1, sky2)));
58 }
59 
60 }}} // namespace lsst::meas::algorithms
virtual afw::geom::Point2D skyToPixelImpl(afw::geom::Angle sky1, afw::geom::Angle sky2) const
Definition: BinnedWcs.cc:55
BinnedWcs(boost::shared_ptr< afw::image::Wcs > parent, unsigned int xBin, unsigned int yBin, afw::geom::Point2I xy0)
Definition: BinnedWcs.cc:29
virtual void pixelToSkyImpl(double pixel1, double pixel2, afw::geom::Angle skyTmp[2]) const
Definition: BinnedWcs.cc:48