LSSTApplications  19.0.0+10,19.0.0+80,19.0.0-1-g20d9b18+31,19.0.0-1-g49a97f9+4,19.0.0-1-g8c57eb9+31,19.0.0-1-g9a028c0+13,19.0.0-1-ga72da6b+3,19.0.0-1-gb77924a+15,19.0.0-1-gbfe0924+66,19.0.0-1-gc3516c3,19.0.0-1-gefe1d0d+49,19.0.0-1-gf8cb8b4+3,19.0.0-14-g7511ce4+6,19.0.0-16-g3dc1a33c+6,19.0.0-17-g59f0e8a+4,19.0.0-17-g9c22e3c+9,19.0.0-18-g35bb99870+2,19.0.0-19-g2772d4a+9,19.0.0-2-g260436e+53,19.0.0-2-g31cdcee,19.0.0-2-g9675b69+3,19.0.0-2-gaa2795f,19.0.0-2-gbcc4de1,19.0.0-2-gd6f004e+6,19.0.0-2-gde8e5e3+5,19.0.0-2-gff6972b+15,19.0.0-21-ge306cd8,19.0.0-21-gf122e69+2,19.0.0-3-g2d43a51+2,19.0.0-3-gf3b1435+6,19.0.0-4-g56feb96,19.0.0-4-gac56cce+17,19.0.0-49-gce872c1+1,19.0.0-5-g66946eb+6,19.0.0-5-gd8897ba+6,19.0.0-51-gfc4a647e,19.0.0-7-g686a884+5,19.0.0-7-g886f805+5,19.0.0-8-g305ff64,w.2020.17
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...