LSSTApplications  20.0.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"
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
lsst::afw::image::RotType
RotType
Type of rotation.
Definition: VisitInfo.h:45
lsst::utils::python::addOutputOp
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
std::nan
T nan(T... args)
lsst::afw::image::detail::setVisitInfoMetadata
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition: VisitInfo.cc:281
lsst::afw::image::PYBIND11_MODULE
PYBIND11_MODULE(visitInfo, mod)
Definition: visitInfo.cc:55
Observatory.h
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::typehandling::Storable
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
lsst::daf::base::DateTime
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:64
lsst::afw::coord::Weather
Basic weather information sufficient for a simple model for air mass or refraction.
Definition: Weather.h:38
lsst::afw::geom.transform.transformContinued.cls
cls
Definition: transformContinued.py:33
lsst::afw::image::VisitInfo
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
Angle.h
misc.h
other
ItemVariant const * other
Definition: Schema.cc:56
PropertySet.h
Weather.h
Storable.h
std::int64_t
lsst::afw::coord::Observatory
Hold the location of an observatory.
Definition: Observatory.h:43
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
python.h
python.h
lsst::geom::Angle
A class representing an angle.
Definition: Angle.h:127
pybind11
Definition: _GenericMap.cc:40
SpherePoint.h
lsst::geom::SpherePoint
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
lsst::utils.tests.init
def init()
Definition: tests.py:58
lsst::afw::image::detail::stripVisitInfoKeywords
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:265
std::numeric_limits
visitInfo
Key< int > visitInfo
Definition: Exposure.cc:70
VisitInfo.h