lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
frameSetUtils.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2017 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 #include "pybind11/pybind11.h"
23 
24 #include <memory>
25 
26 #include "astshim.h"
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 
30 #include "lsst/daf/base.h"
31 #include "lsst/afw/geom/Angle.h"
32 #include "lsst/afw/geom/Point.h"
34 
35 namespace py = pybind11;
36 using namespace py::literals;
37 
38 namespace lsst {
39 namespace afw {
40 namespace geom {
41 namespace detail {
42 namespace {
43 
44 PYBIND11_PLUGIN(frameSetUtils) {
45  py::module mod("frameSetUtils");
46 
47  py::module::import("lsst.daf.base");
48  py::module::import("lsst.afw.geom.angle");
49  py::module::import("lsst.afw.geom.coordinates");
50  py::module::import("lsst.afw.geom.spherePoint");
51 
52  // Need to import numpy for ndarray and eigen conversions
53  if (_import_array() < 0) {
54  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
55  return nullptr;
56  }
57 
58  mod.def("getSkyFrame", getSkyFrame, "frameSet"_a, "index"_a, "copy"_a);
59  mod.def("makeTanWcsMetadata", makeTanWcsMetadata, "crpix"_a, "crval"_a, "cdMatrix"_a);
60  mod.def("readFitsWcs", readFitsWcs, "metadata"_a, "strip"_a = true);
61  mod.def("readLsstSkyWcs", readLsstSkyWcs, "metadata"_a, "strip"_a = true);
62 
63  return mod.ptr();
64 }
65 
66 } // namespace
67 } // namespace detail
68 } // namespace geom
69 } // namespace afw
70 } // namespace lsst
std::shared_ptr< daf::base::PropertyList > makeTanWcsMetadata(Point2D const &crpix, coord::IcrsCoord const &crval, Eigen::Matrix2d const &cdMatrix)
Make FITS metadata for a pure tangent WCS.
std::shared_ptr< ast::SkyFrame > getSkyFrame(ast::FrameSet const &frameSet, int index, bool copy)
Get the specified frame of a FrameSet as a SkyFrame.
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
double const _a
Definition: RandomImage.cc:77
std::shared_ptr< ast::FrameSet > readLsstSkyWcs(daf::base::PropertyList &metadata, bool strip=true)
Read an LSST sky WCS FrameSet from a FITS header: 0,0 is the lower left corner of the parent image...
std::shared_ptr< ast::FrameSet > readFitsWcs(daf::base::PropertyList &metadata, bool strip=true)
Read a FITS convention WCS FrameSet from FITS metadata.