LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
_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"
25#include "lsst/utils/python.h"
26
27#include <memory>
28#include <limits>
29#include <sstream>
30
31#include "lsst/utils/python.h"
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
57void declareVisitInfo(lsst::utils::python::WrapperCollection &wrappers) {
58 wrappers.wrapType(
60 "VisitInfo"),
61 [](auto &mod, auto &cls) {
62 /* Constructors */
63 cls.def(py::init<table::RecordId, 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 &>(),
68 "exposureId"_a = 0, "exposureTime"_a = nan, "darkTime"_a = nan,
69 "date"_a = daf::base::DateTime(), "ut1"_a = nan, "era"_a = nanAngle,
70 "boresightRaDec"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
71 "boresightAzAlt"_a = lsst::geom::SpherePoint(nanAngle, nanAngle),
72 "boresightAirmass"_a = nan, "boresightRotAngle"_a = nanAngle,
73 "rotType"_a = RotType::UNKNOWN,
74 "observatory"_a = coord::Observatory(nanAngle, nanAngle, nan),
75 "weather"_a = coord::Weather(nan, nan, nan), "instrumentLabel"_a = "", "id"_a = 0);
76 cls.def(py::init<daf::base::PropertySet const &>(), "metadata"_a);
77 cls.def(py::init<VisitInfo const &>(), "visitInfo"_a);
78
79 table::io::python::addPersistableMethods<VisitInfo>(cls);
80
81 /* Operators */
82 cls.def(
83 "__eq__", [](VisitInfo const &self, VisitInfo const &other) { return self == other; },
84 py::is_operator());
85 cls.def(
86 "__ne__", [](VisitInfo const &self, VisitInfo const &other) { return self != other; },
87 py::is_operator());
88
89 /* Members */
90 cls.def("getExposureId", &VisitInfo::getExposureId);
91 cls.def("getExposureTime", &VisitInfo::getExposureTime);
92 cls.def("getDarkTime", &VisitInfo::getDarkTime);
93 cls.def("getDate", &VisitInfo::getDate);
94 cls.def("getUt1", &VisitInfo::getUt1);
95 cls.def("getEra", &VisitInfo::getEra);
96 cls.def("getBoresightRaDec", &VisitInfo::getBoresightRaDec);
97 cls.def("getBoresightAzAlt", &VisitInfo::getBoresightAzAlt);
98 cls.def("getBoresightAirmass", &VisitInfo::getBoresightAirmass);
99 cls.def("getBoresightParAngle", &VisitInfo::getBoresightParAngle);
100 cls.def("getBoresightRotAngle", &VisitInfo::getBoresightRotAngle);
101 cls.def("getRotType", &VisitInfo::getRotType);
102 cls.def("getObservatory", &VisitInfo::getObservatory);
103 cls.def("getWeather", &VisitInfo::getWeather);
104 cls.def("isPersistable", &VisitInfo::isPersistable);
105 cls.def("getLocalEra", &VisitInfo::getLocalEra);
106 cls.def("getBoresightHourAngle", &VisitInfo::getBoresightHourAngle);
107 cls.def("getInstrumentLabel", &VisitInfo::getInstrumentLabel);
108 cls.def("getId", &VisitInfo::getId);
109
110 /* readonly property accessors */
111 cls.def_property_readonly("exposureTime", &VisitInfo::getExposureTime);
112 cls.def_property_readonly("darkTime", &VisitInfo::getDarkTime);
113 cls.def_property_readonly("date", &VisitInfo::getDate);
114 cls.def_property_readonly("ut1", &VisitInfo::getUt1);
115 cls.def_property_readonly("era", &VisitInfo::getEra);
116 cls.def_property_readonly("boresightRaDec", &VisitInfo::getBoresightRaDec);
117 cls.def_property_readonly("boresightAzAlt", &VisitInfo::getBoresightAzAlt);
118 cls.def_property_readonly("boresightAirmass", &VisitInfo::getBoresightAirmass);
119 cls.def_property_readonly("boresightParAngle", &VisitInfo::getBoresightParAngle);
120 cls.def_property_readonly("boresightRotAngle", &VisitInfo::getBoresightRotAngle);
121 cls.def_property_readonly("rotType", &VisitInfo::getRotType);
122 cls.def_property_readonly("observatory", &VisitInfo::getObservatory);
123 cls.def_property_readonly("weather", &VisitInfo::getWeather);
124 cls.def_property_readonly("isPersistable", &VisitInfo::isPersistable);
125 cls.def_property_readonly("localEra", &VisitInfo::getLocalEra);
126 cls.def_property_readonly("boresightHourAngle", &VisitInfo::getBoresightHourAngle);
127 cls.def_property_readonly("instrumentLabel", &VisitInfo::getInstrumentLabel);
128 cls.def_property_readonly("id", &VisitInfo::getId);
129
130 utils::python::addOutputOp(cls, "__repr__");
131 });
132}
133void declareRotType(lsst::utils::python::WrapperCollection &wrappers) {
134 wrappers.wrapType(py::enum_<RotType>(wrappers.module, "RotType"), [](auto &mod, auto &enm) {
135 enm.value("UNKNOWN", RotType::UNKNOWN);
136 enm.value("SKY", RotType::SKY);
137 enm.value("HORIZON", RotType::HORIZON);
138 enm.value("MOUNT", RotType::MOUNT);
139 enm.export_values();
140 });
141}
142
143void wrapVisitInfo(lsst::utils::python::WrapperCollection &wrappers) {
144 wrappers.addInheritanceDependency("lsst.daf.base");
145 wrappers.addInheritanceDependency("lsst.geom");
146 wrappers.addInheritanceDependency("lsst.afw.coord");
147 wrappers.addInheritanceDependency("lsst.afw.typehandling");
148 declareRotType(wrappers);
149 declareVisitInfo(wrappers);
150 wrappers.wrap([](auto &mod) {
151 /* Free Functions */
152 mod.def("setVisitInfoMetadata", &detail::setVisitInfoMetadata, "metadata"_a, "visitInfo"_a);
153 mod.def("stripVisitInfoKeywords", &detail::stripVisitInfoKeywords, "metadata"_a);
154 });
155}
156} // namespace image
157} // namespace afw
158} // 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:147
coord::Weather getWeather() const
get basic weather information
Definition: VisitInfo.h:182
lsst::geom::Angle getLocalEra() const
Definition: VisitInfo.cc:545
double getUt1() const
get UT1 (universal time) MJD date at middle of exposure
Definition: VisitInfo.h:150
double getBoresightAirmass() const
get airmass at the boresight, relative to zenith at sea level (and at the middle of the exposure,...
Definition: VisitInfo.h:165
lsst::geom::Angle getBoresightHourAngle() const
Definition: VisitInfo.cc:547
lsst::geom::Angle getBoresightRotAngle() const
Get rotation angle at boresight at middle of exposure.
Definition: VisitInfo.h:173
table::RecordId getExposureId() const
get exposure ID
Definition: VisitInfo.h:136
lsst::geom::Angle getEra() const
get earth rotation angle at middle of exposure
Definition: VisitInfo.h:153
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: VisitInfo.h:184
table::RecordId getId() const
Definition: VisitInfo.h:194
double getExposureTime() const
get exposure duration (shutter open time); (sec)
Definition: VisitInfo.h:141
RotType getRotType() const
get rotation type of boresightRotAngle
Definition: VisitInfo.h:176
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:161
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:157
std::string getInstrumentLabel() const
Definition: VisitInfo.h:192
double getDarkTime() const
get time from CCD flush to exposure readout, including shutter open time (despite the name); (sec)
Definition: VisitInfo.h:144
coord::Observatory getObservatory() const
get observatory longitude, latitude and elevation
Definition: VisitInfo.h:179
lsst::geom::Angle getBoresightParAngle() const
Get parallactic angle at the boresight.
Definition: VisitInfo.cc:549
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
A class representing an angle.
Definition: Angle.h:128
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:346
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Definition: VisitInfo.cc:363
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
void declareVisitInfo(lsst::utils::python::WrapperCollection &wrappers)
Definition: _visitInfo.cc:57
void declareRotType(lsst::utils::python::WrapperCollection &wrappers)
Definition: _visitInfo.cc:133
void wrapVisitInfo(lsst::utils::python::WrapperCollection &)
Definition: _visitInfo.cc:143
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
A base class for image defects.
T nan(T... args)