LSSTApplications  18.1.0
LSSTDataManagementBasePackage
visitInfo.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2017 AURA/LSST.
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 <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include "pybind11/pybind11.h"
24 
25 #include <memory>
26 #include <limits>
27 #include <sstream>
28 
29 #include "lsst/utils/python.h"
30 
33 #include "lsst/afw/coord/Weather.h"
34 #include "lsst/geom/Angle.h"
35 #include "lsst/geom/SpherePoint.h"
36 #include "lsst/afw/table/io/python.h" // for addPersistableMethods
37 #include "lsst/afw/table/misc.h"
39 
40 namespace py = pybind11;
41 using namespace pybind11::literals;
42 
43 namespace lsst {
44 namespace afw {
45 namespace image {
46 
47 namespace {
48 
49 static double const nan(std::numeric_limits<double>::quiet_NaN());
50 static lsst::geom::Angle const nanAngle(nan);
51 
52 } // namespace
53 
55  py::module::import("lsst.daf.base");
56  py::module::import("lsst.geom");
57  py::module::import("lsst.afw.coord.observatory");
58  py::module::import("lsst.afw.coord.weather");
59 
60  /* Module level */
61  py::class_<VisitInfo, std::shared_ptr<VisitInfo>> cls(mod, "VisitInfo");
62 
63  /* Member types and enums */
64  py::enum_<RotType>(mod, "RotType")
65  .value("UNKNOWN", RotType::UNKNOWN)
66  .value("SKY", RotType::SKY)
67  .value("HORIZON", RotType::HORIZON)
68  .value("MOUNT", RotType::MOUNT)
69  .export_values();
70 
71  /* Constructors */
72  cls.def(py::init<table::RecordId, double, double, daf::base::DateTime const &, double,
73  lsst::geom::Angle const &, lsst::geom::SpherePoint const &, lsst::geom::SpherePoint const &, double,
74  lsst::geom::Angle const &, RotType const &, coord::Observatory const &,
75  coord::Weather const &>(),
76  "exposureId"_a = 0, "exposureTime"_a = nan, "darkTime"_a = nan, "date"_a = daf::base::DateTime(),
77  "ut1"_a = nan, "era"_a = nanAngle, "boresightRaDec"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
78  "boresightAzAlt"_a = lsst::geom::SpherePoint(nanAngle, nanAngle), "boresightAirmass"_a = nan,
79  "boresightRotAngle"_a = nanAngle, "rotType"_a = RotType::UNKNOWN,
80  "observatory"_a = coord::Observatory(nanAngle, nanAngle, nan),
81  "weather"_a = coord::Weather(nan, nan, nan));
82  cls.def(py::init<daf::base::PropertySet const &>(), "metadata"_a);
83  cls.def(py::init<VisitInfo const &>(), "visitInfo"_a);
84 
85  table::io::python::addPersistableMethods<VisitInfo>(cls);
86 
87  /* Operators */
88  cls.def("__eq__", [](VisitInfo const &self, VisitInfo const &other) { return self == other; },
89  py::is_operator());
90  cls.def("__ne__", [](VisitInfo const &self, VisitInfo const &other) { return self != other; },
91  py::is_operator());
92 
93  /* Members */
94  cls.def("getExposureId", &VisitInfo::getExposureId);
95  cls.def("getExposureTime", &VisitInfo::getExposureTime);
96  cls.def("getDarkTime", &VisitInfo::getDarkTime);
97  cls.def("getDate", &VisitInfo::getDate);
98  cls.def("getUt1", &VisitInfo::getUt1);
99  cls.def("getEra", &VisitInfo::getEra);
100  cls.def("getBoresightRaDec", &VisitInfo::getBoresightRaDec);
101  cls.def("getBoresightAzAlt", &VisitInfo::getBoresightAzAlt);
102  cls.def("getBoresightAirmass", &VisitInfo::getBoresightAirmass);
103  cls.def("getBoresightParAngle", &VisitInfo::getBoresightParAngle);
104  cls.def("getBoresightRotAngle", &VisitInfo::getBoresightRotAngle);
105  cls.def("getRotType", &VisitInfo::getRotType);
106  cls.def("getObservatory", &VisitInfo::getObservatory);
107  cls.def("getWeather", &VisitInfo::getWeather);
108  cls.def("isPersistable", &VisitInfo::isPersistable);
109  cls.def("getLocalEra", &VisitInfo::getLocalEra);
110  cls.def("getBoresightHourAngle", &VisitInfo::getBoresightHourAngle);
111 
112  utils::python::addOutputOp(cls, "__str__");
113 
114  /* Free Functions */
115  mod.def("setVisitInfoMetadata", &detail::setVisitInfoMetadata, "metadata"_a, "visitInfo"_a);
116  mod.def("stripVisitInfoKeywords", &detail::stripVisitInfoKeywords, "metadata"_a);
117 }
118 } // namespace image
119 } // namespace afw
120 } // namespace lsst
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:64
PYBIND11_MODULE(visitInfo, mod)
Definition: visitInfo.cc:54
Hold the location of an observatory.
Definition: Observatory.h:43
RotType
Type of rotation.
Definition: VisitInfo.h:45
def init()
Definition: tests.py:75
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
A class representing an angle.
Definition: Angle.h:127
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition: VisitInfo.cc:283
A base class for image defects.
Basic weather information sufficient for a simple model for air mass or refraction.
Definition: Weather.h:38
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
T nan(T... args)
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:267
ItemVariant const * other
Definition: Schema.cc:56
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...