LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
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"
40 
41 namespace py = pybind11;
42 using namespace pybind11::literals;
43 
44 namespace lsst {
45 namespace afw {
46 namespace image {
47 
48 namespace {
49 
50 static double const nan(std::numeric_limits<double>::quiet_NaN());
51 static lsst::geom::Angle const nanAngle(nan);
52 
53 } // namespace
54 
56  py::module::import("lsst.daf.base");
57  py::module::import("lsst.geom");
58  py::module::import("lsst.afw.coord.observatory");
59  py::module::import("lsst.afw.coord.weather");
60  py::module::import("lsst.afw.typehandling");
61 
62  /* Module level */
63  py::class_<VisitInfo, std::shared_ptr<VisitInfo>, typehandling::Storable> cls(mod, "VisitInfo");
64 
65  /* Member types and enums */
66  py::enum_<RotType>(mod, "RotType")
67  .value("UNKNOWN", RotType::UNKNOWN)
68  .value("SKY", RotType::SKY)
69  .value("HORIZON", RotType::HORIZON)
70  .value("MOUNT", RotType::MOUNT)
71  .export_values();
72 
73  /* Constructors */
74  cls.def(py::init<table::RecordId, double, double, daf::base::DateTime const &, double,
75  lsst::geom::Angle const &, lsst::geom::SpherePoint const &, lsst::geom::SpherePoint const &, double,
76  lsst::geom::Angle const &, RotType const &, coord::Observatory const &,
77  coord::Weather const &>(),
78  "exposureId"_a = 0, "exposureTime"_a = nan, "darkTime"_a = nan, "date"_a = daf::base::DateTime(),
79  "ut1"_a = nan, "era"_a = nanAngle, "boresightRaDec"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
80  "boresightAzAlt"_a = lsst::geom::SpherePoint(nanAngle, nanAngle), "boresightAirmass"_a = nan,
81  "boresightRotAngle"_a = nanAngle, "rotType"_a = RotType::UNKNOWN,
82  "observatory"_a = coord::Observatory(nanAngle, nanAngle, nan),
83  "weather"_a = coord::Weather(nan, nan, nan));
84  cls.def(py::init<daf::base::PropertySet const &>(), "metadata"_a);
85  cls.def(py::init<VisitInfo const &>(), "visitInfo"_a);
86 
87  table::io::python::addPersistableMethods<VisitInfo>(cls);
88 
89  /* Operators */
90  cls.def("__eq__", [](VisitInfo const &self, VisitInfo const &other) { return self == other; },
91  py::is_operator());
92  cls.def("__ne__", [](VisitInfo const &self, VisitInfo const &other) { return self != other; },
93  py::is_operator());
94 
95  /* Members */
96  cls.def("getExposureId", &VisitInfo::getExposureId);
97  cls.def("getExposureTime", &VisitInfo::getExposureTime);
98  cls.def("getDarkTime", &VisitInfo::getDarkTime);
99  cls.def("getDate", &VisitInfo::getDate);
100  cls.def("getUt1", &VisitInfo::getUt1);
101  cls.def("getEra", &VisitInfo::getEra);
102  cls.def("getBoresightRaDec", &VisitInfo::getBoresightRaDec);
103  cls.def("getBoresightAzAlt", &VisitInfo::getBoresightAzAlt);
104  cls.def("getBoresightAirmass", &VisitInfo::getBoresightAirmass);
105  cls.def("getBoresightParAngle", &VisitInfo::getBoresightParAngle);
106  cls.def("getBoresightRotAngle", &VisitInfo::getBoresightRotAngle);
107  cls.def("getRotType", &VisitInfo::getRotType);
108  cls.def("getObservatory", &VisitInfo::getObservatory);
109  cls.def("getWeather", &VisitInfo::getWeather);
110  cls.def("isPersistable", &VisitInfo::isPersistable);
111  cls.def("getLocalEra", &VisitInfo::getLocalEra);
112  cls.def("getBoresightHourAngle", &VisitInfo::getBoresightHourAngle);
113 
114  utils::python::addOutputOp(cls, "__str__");
115 
116  /* Free Functions */
117  mod.def("setVisitInfoMetadata", &detail::setVisitInfoMetadata, "metadata"_a, "visitInfo"_a);
118  mod.def("stripVisitInfoKeywords", &detail::stripVisitInfoKeywords, "metadata"_a);
119 }
120 } // namespace image
121 } // namespace afw
122 } // 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:55
Hold the location of an observatory.
Definition: Observatory.h:43
RotType
Type of rotation.
Definition: VisitInfo.h:45
def init()
Definition: tests.py:65
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
ItemVariant const * other
Definition: Schema.cc:56
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:281
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:265
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...