LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
_visitInfo.cc
Go to the documentation of this file.
1 /*
2  * This file is part of afw.
3  *
4  * Developed for the LSST Data Management System.
5  * This product includes software developed by the LSST Project
6  * (https://www.lsst.org).
7  * See the COPYRIGHT file at the top-level directory of this distribution
8  * for details of code ownership.
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 GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #include "pybind11/pybind11.h"
25 #include "lsst/utils/python.h"
26 
27 #include <memory>
28 #include <limits>
29 #include <sstream>
30 
31 #include "lsst/utils/python.h"
32 
35 #include "lsst/afw/coord/Weather.h"
36 #include "lsst/geom/Angle.h"
37 #include "lsst/geom/SpherePoint.h"
38 #include "lsst/afw/table/io/python.h" // for addPersistableMethods
39 #include "lsst/afw/table/misc.h"
42 
43 namespace py = pybind11;
44 using namespace pybind11::literals;
45 
46 namespace lsst {
47 namespace afw {
48 namespace image {
49 
50 namespace {
51 
52 static double const nan(std::numeric_limits<double>::quiet_NaN());
53 static lsst::geom::Angle const nanAngle(nan);
54 
55 } // namespace
56 
57 void declareVisitInfo(lsst::utils::python::WrapperCollection &wrappers) {
58  wrappers.wrapType(
59  py::class_<VisitInfo, std::shared_ptr<VisitInfo>, typehandling::Storable>(wrappers.module,
60  "VisitInfo"),
61  [](auto &mod, auto &cls) {
62  /* Constructors */
63  cls.def(py::init<table::RecordId, double, double, daf::base::DateTime const &, double,
64  lsst::geom::Angle const &, lsst::geom::SpherePoint const &,
65  lsst::geom::SpherePoint const &, double, lsst::geom::Angle const &,
66  RotType const &, coord::Observatory const &, coord::Weather const &,
67  std::string const &, table::RecordId const &>(),
68  "exposureId"_a = 0, "exposureTime"_a = nan, "darkTime"_a = nan,
69  "date"_a = daf::base::DateTime(), "ut1"_a = nan, "era"_a = nanAngle,
70  "boresightRaDec"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
71  "boresightAzAlt"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
72  "boresightAirmass"_a = nan, "boresightRotAngle"_a = nanAngle,
73  "rotType"_a = RotType::UNKNOWN,
74  "observatory"_a = coord::Observatory(nanAngle, nanAngle, nan),
75  "weather"_a = coord::Weather(nan, nan, nan), "instrumentLabel"_a = "", "id"_a = 0);
76  cls.def(py::init<daf::base::PropertySet const &>(), "metadata"_a);
77  cls.def(py::init<VisitInfo const &>(), "visitInfo"_a);
78 
79  table::io::python::addPersistableMethods<VisitInfo>(cls);
80 
81  /* Operators */
82  cls.def(
83  "__eq__", [](VisitInfo const &self, VisitInfo const &other) { return self == other; },
84  py::is_operator());
85  cls.def(
86  "__ne__", [](VisitInfo const &self, VisitInfo const &other) { return self != other; },
87  py::is_operator());
88 
89  /* Members */
90  cls.def("getExposureId", &VisitInfo::getExposureId);
91  cls.def("getExposureTime", &VisitInfo::getExposureTime);
92  cls.def("getDarkTime", &VisitInfo::getDarkTime);
93  cls.def("getDate", &VisitInfo::getDate);
94  cls.def("getUt1", &VisitInfo::getUt1);
95  cls.def("getEra", &VisitInfo::getEra);
96  cls.def("getBoresightRaDec", &VisitInfo::getBoresightRaDec);
97  cls.def("getBoresightAzAlt", &VisitInfo::getBoresightAzAlt);
98  cls.def("getBoresightAirmass", &VisitInfo::getBoresightAirmass);
99  cls.def("getBoresightParAngle", &VisitInfo::getBoresightParAngle);
100  cls.def("getBoresightRotAngle", &VisitInfo::getBoresightRotAngle);
101  cls.def("getRotType", &VisitInfo::getRotType);
102  cls.def("getObservatory", &VisitInfo::getObservatory);
103  cls.def("getWeather", &VisitInfo::getWeather);
104  cls.def("isPersistable", &VisitInfo::isPersistable);
105  cls.def("getLocalEra", &VisitInfo::getLocalEra);
106  cls.def("getBoresightHourAngle", &VisitInfo::getBoresightHourAngle);
107  cls.def("getInstrumentLabel", &VisitInfo::getInstrumentLabel);
108  cls.def("getId", &VisitInfo::getId);
109 
110  /* readonly property accessors */
111  cls.def_property_readonly("exposureTime", &VisitInfo::getExposureTime);
112  cls.def_property_readonly("darkTime", &VisitInfo::getDarkTime);
113  cls.def_property_readonly("date", &VisitInfo::getDate);
114  cls.def_property_readonly("ut1", &VisitInfo::getUt1);
115  cls.def_property_readonly("era", &VisitInfo::getEra);
116  cls.def_property_readonly("boresightRaDec", &VisitInfo::getBoresightRaDec);
117  cls.def_property_readonly("boresightAzAlt", &VisitInfo::getBoresightAzAlt);
118  cls.def_property_readonly("boresightAirmass", &VisitInfo::getBoresightAirmass);
119  cls.def_property_readonly("boresightParAngle", &VisitInfo::getBoresightParAngle);
120  cls.def_property_readonly("boresightRotAngle", &VisitInfo::getBoresightRotAngle);
121  cls.def_property_readonly("rotType", &VisitInfo::getRotType);
122  cls.def_property_readonly("observatory", &VisitInfo::getObservatory);
123  cls.def_property_readonly("weather", &VisitInfo::getWeather);
124  cls.def_property_readonly("isPersistable", &VisitInfo::isPersistable);
125  cls.def_property_readonly("localEra", &VisitInfo::getLocalEra);
126  cls.def_property_readonly("boresightHourAngle", &VisitInfo::getBoresightHourAngle);
127  cls.def_property_readonly("instrumentLabel", &VisitInfo::getInstrumentLabel);
128  cls.def_property_readonly("id", &VisitInfo::getId);
129 
130  utils::python::addOutputOp(cls, "__repr__");
131  });
132 }
133 void declareRotType(lsst::utils::python::WrapperCollection &wrappers) {
134  wrappers.wrapType(py::enum_<RotType>(wrappers.module, "RotType"), [](auto &mod, auto &enm) {
135  enm.value("UNKNOWN", RotType::UNKNOWN);
136  enm.value("SKY", RotType::SKY);
137  enm.value("HORIZON", RotType::HORIZON);
138  enm.value("MOUNT", RotType::MOUNT);
139  enm.export_values();
140  });
141 }
142 
143 void wrapVisitInfo(lsst::utils::python::WrapperCollection &wrappers) {
144  wrappers.addInheritanceDependency("lsst.daf.base");
145  wrappers.addInheritanceDependency("lsst.geom");
146  wrappers.addInheritanceDependency("lsst.afw.coord");
147  wrappers.addInheritanceDependency("lsst.afw.typehandling");
148  declareRotType(wrappers);
149  declareVisitInfo(wrappers);
150  wrappers.wrap([](auto &mod) {
151  /* Free Functions */
152  mod.def("setVisitInfoMetadata", &detail::setVisitInfoMetadata, "metadata"_a, "visitInfo"_a);
153  mod.def("stripVisitInfoKeywords", &detail::stripVisitInfoKeywords, "metadata"_a);
154  });
155 }
156 } // namespace image
157 } // namespace afw
158 } // namespace lsst
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
A class representing an angle.
Definition: Angle.h:127
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:346
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition: VisitInfo.cc:363
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
void declareVisitInfo(lsst::utils::python::WrapperCollection &wrappers)
Definition: _visitInfo.cc:57
void declareRotType(lsst::utils::python::WrapperCollection &wrappers)
Definition: _visitInfo.cc:133
void wrapVisitInfo(lsst::utils::python::WrapperCollection &)
Definition: _visitInfo.cc:143
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
A base class for image defects.
T nan(T... args)