LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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, "__str__");
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:339
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition: VisitInfo.cc:356
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)