LSST Applications g042eb84c57+730a74494b,g04e9c324dd+8c5ae1fdc5,g134cb467dc+1f1e3e7524,g199a45376c+0ba108daf9,g1fd858c14a+fa7d31856b,g210f2d0738+f66ac109ec,g262e1987ae+83a3acc0e5,g29ae962dfc+d856a2cb1f,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+a1e0c9f713,g47891489e3+0d594cb711,g4d44eb3520+c57ec8f3ed,g4d7b6aa1c5+f66ac109ec,g53246c7159+8c5ae1fdc5,g56a1a4eaf3+fd7ad03fde,g64539dfbff+f66ac109ec,g67b6fd64d1+0d594cb711,g67fd3c3899+f66ac109ec,g6985122a63+0d594cb711,g74acd417e5+3098891321,g786e29fd12+668abc6043,g81db2e9a8d+98e2ab9f28,g87389fa792+8856018cbb,g89139ef638+0d594cb711,g8d7436a09f+80fda9ce03,g8ea07a8fe4+760ca7c3fc,g90f42f885a+033b1d468d,g97be763408+a8a29bda4b,g99822b682c+e3ec3c61f9,g9d5c6a246b+0d5dac0c3d,ga41d0fce20+9243b26dd2,gbf99507273+8c5ae1fdc5,gd7ef33dd92+0d594cb711,gdab6d2f7ff+3098891321,ge410e46f29+0d594cb711,geaed405ab2+c4bbc419c6,gf9a733ac38+8c5ae1fdc5,w.2025.38
LSST Data Management Base Package
Loading...
Searching...
No Matches
_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"
26
27#include <memory>
28#include <limits>
29#include <sstream>
30
32
36#include "lsst/geom/Angle.h"
38#include "lsst/afw/table/io/python.h" // for addPersistableMethods
39#include "lsst/afw/table/misc.h"
42
43namespace py = pybind11;
44using namespace pybind11::literals;
45
46namespace lsst {
47namespace afw {
48namespace image {
49
50namespace {
51
52static double const nan(std::numeric_limits<double>::quiet_NaN());
53static lsst::geom::Angle const nanAngle(nan);
54
55} // namespace
56
58 wrappers.wrapType(
59 py::classh<VisitInfo, typehandling::Storable>(wrappers.module,
60 "VisitInfo"),
61 [](auto &mod, auto &cls) {
62 /* Constructors */
63 cls.def(py::init<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 &, double, std::string const &,
68 std::string const &, std::string const &, std::string const &, bool>(),
69 "exposureTime"_a = nan, "darkTime"_a = nan, "date"_a = daf::base::DateTime(),
70 "ut1"_a = nan, "era"_a = nanAngle,
71 "boresightRaDec"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
72 "boresightAzAlt"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
73 "boresightAirmass"_a = nan, "boresightRotAngle"_a = nanAngle,
74 "rotType"_a = RotType::UNKNOWN,
75 "observatory"_a = coord::Observatory(nanAngle, nanAngle, nan),
76 "weather"_a = coord::Weather(nan, nan, nan), "instrumentLabel"_a = "", "id"_a = 0,
77 "focusZ"_a = nan, "observationType"_a = "", "scienceProgram"_a = "",
78 // default hasSimulatedContent=false for backwards compatibility
79 "observationReason"_a = "", "object"_a = "", "hasSimulatedContent"_a = false);
80 cls.def(py::init<daf::base::PropertySet const &>(), "metadata"_a);
81 cls.def(py::init<VisitInfo const &>(), "visitInfo"_a);
82
83 table::io::python::addPersistableMethods<VisitInfo>(cls);
84
85 /* Operators */
86 cls.def(
87 "__eq__", [](VisitInfo const &self, VisitInfo const &other) { return self == other; },
88 py::is_operator());
89 cls.def(
90 "__ne__", [](VisitInfo const &self, VisitInfo const &other) { return self != other; },
91 py::is_operator());
92
93 /* Members */
94 cls.def("getExposureTime", &VisitInfo::getExposureTime);
95 cls.def("getDarkTime", &VisitInfo::getDarkTime);
96 cls.def("getDate", &VisitInfo::getDate);
97 cls.def("getUt1", &VisitInfo::getUt1);
98 cls.def("getEra", &VisitInfo::getEra);
99 cls.def("getBoresightRaDec", &VisitInfo::getBoresightRaDec);
100 cls.def("getBoresightAzAlt", &VisitInfo::getBoresightAzAlt);
101 cls.def("getBoresightAirmass", &VisitInfo::getBoresightAirmass);
102 cls.def("getBoresightParAngle", &VisitInfo::getBoresightParAngle);
103 cls.def("getBoresightRotAngle", &VisitInfo::getBoresightRotAngle);
104 cls.def("getRotType", &VisitInfo::getRotType);
105 cls.def("getObservatory", &VisitInfo::getObservatory);
106 cls.def("getWeather", &VisitInfo::getWeather);
107 cls.def("isPersistable", &VisitInfo::isPersistable);
108 cls.def("getLocalEra", &VisitInfo::getLocalEra);
109 cls.def("getBoresightHourAngle", &VisitInfo::getBoresightHourAngle);
110 cls.def("getInstrumentLabel", &VisitInfo::getInstrumentLabel);
111 cls.def("getId", &VisitInfo::getId);
112 cls.def("getFocusZ", &VisitInfo::getFocusZ);
113 cls.def("getObservationType", &VisitInfo::getObservationType);
114 cls.def("getScienceProgram", &VisitInfo::getScienceProgram);
115 cls.def("getObservationReason", &VisitInfo::getObservationReason);
116 cls.def("getObject", &VisitInfo::getObject);
117 cls.def("getHasSimulatedContent", &VisitInfo::getHasSimulatedContent);
118
119 /* readonly property accessors */
120 cls.def_property_readonly("exposureTime", &VisitInfo::getExposureTime);
121 cls.def_property_readonly("darkTime", &VisitInfo::getDarkTime);
122 cls.def_property_readonly("date", &VisitInfo::getDate);
123 cls.def_property_readonly("ut1", &VisitInfo::getUt1);
124 cls.def_property_readonly("era", &VisitInfo::getEra);
125 cls.def_property_readonly("boresightRaDec", &VisitInfo::getBoresightRaDec);
126 cls.def_property_readonly("boresightAzAlt", &VisitInfo::getBoresightAzAlt);
127 cls.def_property_readonly("boresightAirmass", &VisitInfo::getBoresightAirmass);
128 cls.def_property_readonly("boresightParAngle", &VisitInfo::getBoresightParAngle);
129 cls.def_property_readonly("boresightRotAngle", &VisitInfo::getBoresightRotAngle);
130 cls.def_property_readonly("rotType", &VisitInfo::getRotType);
131 cls.def_property_readonly("observatory", &VisitInfo::getObservatory);
132 cls.def_property_readonly("weather", &VisitInfo::getWeather);
133 cls.def_property_readonly("isPersistable", &VisitInfo::isPersistable);
134 cls.def_property_readonly("localEra", &VisitInfo::getLocalEra);
135 cls.def_property_readonly("boresightHourAngle", &VisitInfo::getBoresightHourAngle);
136 cls.def_property_readonly("instrumentLabel", &VisitInfo::getInstrumentLabel);
137 cls.def_property_readonly("id", &VisitInfo::getId);
138 cls.def_property_readonly("focusZ", &VisitInfo::getFocusZ);
139 cls.def_property_readonly("observationType", &VisitInfo::getObservationType);
140 cls.def_property_readonly("scienceProgram", &VisitInfo::getScienceProgram);
141 cls.def_property_readonly("observationReason", &VisitInfo::getObservationReason);
142 cls.def_property_readonly("object", &VisitInfo::getObject);
143 cls.def_property_readonly("hasSimulatedContent", &VisitInfo::getHasSimulatedContent);
144
145 cpputils::python::addOutputOp(cls, "__repr__");
146 });
147}
149 wrappers.wrapType(py::enum_<RotType>(wrappers.module, "RotType"), [](auto &mod, auto &enm) {
150 enm.value("UNKNOWN", RotType::UNKNOWN);
151 enm.value("SKY", RotType::SKY);
152 enm.value("HORIZON", RotType::HORIZON);
153 enm.value("MOUNT", RotType::MOUNT);
154 enm.export_values();
155 });
156}
157
159 wrappers.addInheritanceDependency("lsst.daf.base");
160 wrappers.addInheritanceDependency("lsst.geom");
161 wrappers.addInheritanceDependency("lsst.afw.coord");
162 wrappers.addInheritanceDependency("lsst.afw.typehandling");
163 declareRotType(wrappers);
164 declareVisitInfo(wrappers);
165 wrappers.wrap([](auto &mod) {
166 /* Free Functions */
167 mod.def("setVisitInfoMetadata", &detail::setVisitInfoMetadata, "metadata"_a, "visitInfo"_a);
168 mod.def("stripVisitInfoKeywords", &detail::stripVisitInfoKeywords, "metadata"_a);
169 });
170}
171} // namespace image
172} // namespace afw
173} // namespace lsst
Information about a single exposure of an imaging camera.
Definition VisitInfo.h:68
daf::base::DateTime getDate() const
get uniform date and time at middle of exposure
Definition VisitInfo.h:150
coord::Weather getWeather() const
get basic weather information
Definition VisitInfo.h:185
lsst::geom::Angle getLocalEra() const
Definition VisitInfo.cc:612
double getUt1() const
get UT1 (universal time) MJD date at middle of exposure
Definition VisitInfo.h:153
double getBoresightAirmass() const
get airmass at the boresight, relative to zenith at sea level (and at the middle of the exposure,...
Definition VisitInfo.h:168
std::string getScienceProgram() const
Definition VisitInfo.h:203
lsst::geom::Angle getBoresightHourAngle() const
Definition VisitInfo.cc:614
lsst::geom::Angle getBoresightRotAngle() const
Get rotation angle at boresight at middle of exposure.
Definition VisitInfo.h:176
lsst::geom::Angle getEra() const
get earth rotation angle at middle of exposure
Definition VisitInfo.h:156
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition VisitInfo.h:187
table::RecordId getId() const
Definition VisitInfo.h:197
std::string getObservationReason() const
Definition VisitInfo.h:204
double getExposureTime() const
get exposure duration (shutter open time); (sec)
Definition VisitInfo.h:144
RotType getRotType() const
get rotation type of boresightRotAngle
Definition VisitInfo.h:179
lsst::geom::SpherePoint getBoresightAzAlt() const
get refracted apparent topocentric Az/Alt position at the boresight (and at the middle of the exposur...
Definition VisitInfo.h:164
std::string getObject() const
Definition VisitInfo.h:205
lsst::geom::SpherePoint getBoresightRaDec() const
get ICRS RA/Dec position at the boresight (and at the middle of the exposure, if it varies with time)
Definition VisitInfo.h:160
std::string getInstrumentLabel() const
Definition VisitInfo.h:195
bool getHasSimulatedContent() const
Definition VisitInfo.h:206
double getDarkTime() const
get time from CCD flush to exposure readout, including shutter open time (despite the name); (sec)
Definition VisitInfo.h:147
coord::Observatory getObservatory() const
get observatory longitude, latitude and elevation
Definition VisitInfo.h:182
lsst::geom::Angle getBoresightParAngle() const
Get parallactic angle at the boresight.
Definition VisitInfo.cc:616
std::string getObservationType() const
Definition VisitInfo.h:202
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void wrap(WrapperCallback function)
Add a set of wrappers without defining a class.
Definition python.h:369
void addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
Definition python.h:343
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition python.h:391
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition python.h:448
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition VisitInfo.cc:389
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition VisitInfo.cc:408
void declareRotType(lsst::cpputils::python::WrapperCollection &wrappers)
void wrapVisitInfo(lsst::cpputils::python::WrapperCollection &)
void declareVisitInfo(lsst::cpputils::python::WrapperCollection &wrappers)
Definition _visitInfo.cc:57
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition python.h:87
T nan(T... args)
T quiet_NaN(T... args)