LSSTApplications  18.1.0
LSSTDataManagementBasePackage
ampInfo.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 #include "pybind11/stl.h"
25 
26 #include <memory>
27 
28 #include "lsst/afw/table/Catalog.h"
29 #include "lsst/afw/table/AmpInfo.h"
32 
33 namespace py = pybind11;
34 using namespace pybind11::literals;
35 
36 namespace lsst {
37 namespace afw {
38 namespace table {
39 namespace {
40 
41 using PyAmpInfoRecord = py::class_<AmpInfoRecord, std::shared_ptr<AmpInfoRecord>, BaseRecord>;
42 using PyAmpInfoTable = py::class_<AmpInfoTable, std::shared_ptr<AmpInfoTable>, BaseTable>;
43 
44 static PyAmpInfoRecord declareAmpInfoRecord(py::module &mod) {
45  PyAmpInfoRecord cls(mod, "AmpInfoRecord");
46  cls.def("getName", &AmpInfoRecord::getName);
47  cls.def("setName", &AmpInfoRecord::setName, "name"_a, "Set name of amplifier location in camera");
48  cls.def("getTable", &AmpInfoRecord::getTable);
49  cls.def_property_readonly("table", &AmpInfoRecord::getTable);
50  cls.def("getBBox", &AmpInfoRecord::getBBox);
51  cls.def("setBBox", &AmpInfoRecord::setBBox, "bbox"_a);
52  cls.def("getGain", &AmpInfoRecord::getGain);
53  cls.def("setGain", &AmpInfoRecord::setGain, "gain"_a, "Set amplifier gain in electron/adu");
54  cls.def("getReadNoise", &AmpInfoRecord::getReadNoise);
55  cls.def("setReadNoise", &AmpInfoRecord::setReadNoise, "readNoise"_a, "Set read noise in electron");
56  cls.def("getSaturation", &AmpInfoRecord::getSaturation);
57  cls.def("setSaturation", &AmpInfoRecord::setSaturation, "saturation"_a,
58  "Set level in ADU above which pixels are considered saturated; "
59  "use `nan` if no such level applies");
60  cls.def("getSuspectLevel", &AmpInfoRecord::getSuspectLevel);
61  cls.def("setSuspectLevel", &AmpInfoRecord::setSuspectLevel, "suspectLevel"_a,
62  "Set level in ADU above which pixels are considered suspicious; "
63  "use `nan` if no such level applies");
64  cls.def("getReadoutCorner", &AmpInfoRecord::getReadoutCorner);
65  cls.def("setReadoutCorner", &AmpInfoRecord::setReadoutCorner, "corner"_a);
66  cls.def("getLinearityCoeffs", &AmpInfoRecord::getLinearityCoeffs);
67  cls.def("setLinearityCoeffs", &AmpInfoRecord::setLinearityCoeffs, "coeffs"_a);
68  cls.def("getLinearityType", &AmpInfoRecord::getLinearityType);
69  cls.def("setLinearityType", &AmpInfoRecord::setLinearityType, "type"_a);
70  cls.def("getHasRawInfo", &AmpInfoRecord::getHasRawInfo);
71  cls.def("setHasRawInfo", &AmpInfoRecord::setHasRawInfo, "hasRawInfo"_a);
72  cls.def("getRawBBox", &AmpInfoRecord::getRawBBox);
73  cls.def("setRawBBox", &AmpInfoRecord::setRawBBox, "bbox"_a);
74  cls.def("getRawDataBBox", &AmpInfoRecord::getRawDataBBox);
75  cls.def("setRawDataBBox", &AmpInfoRecord::setRawDataBBox, "bbox"_a);
76  cls.def("getRawFlipX", &AmpInfoRecord::getRawFlipX);
77  cls.def("setRawFlipX", &AmpInfoRecord::setRawFlipX, "rawFlipX"_a);
78  cls.def("getRawFlipY", &AmpInfoRecord::getRawFlipY);
79  cls.def("setRawFlipY", &AmpInfoRecord::setRawFlipY, "rawFlipY"_a);
80  cls.def("getRawXYOffset", &AmpInfoRecord::getRawXYOffset);
81  cls.def("setRawXYOffset", &AmpInfoRecord::setRawXYOffset, "offset"_a);
82  cls.def("getRawHorizontalOverscanBBox", &AmpInfoRecord::getRawHorizontalOverscanBBox);
83  cls.def("setRawHorizontalOverscanBBox", &AmpInfoRecord::setRawHorizontalOverscanBBox, "bbox"_a);
84  cls.def("getRawVerticalOverscanBBox", &AmpInfoRecord::getRawVerticalOverscanBBox);
85  cls.def("setRawVerticalOverscanBBox", &AmpInfoRecord::setRawVerticalOverscanBBox, "bbox"_a);
86  cls.def("getRawPrescanBBox", &AmpInfoRecord::getRawPrescanBBox);
87  cls.def("setRawPrescanBBox", &AmpInfoRecord::setRawPrescanBBox, "bbox"_a);
88  return cls;
89 }
90 
91 static PyAmpInfoTable declareAmpInfoTable(py::module &mod) {
92  PyAmpInfoTable cls(mod, "AmpInfoTable");
93  cls.def_static("make", &AmpInfoTable::make);
94  cls.def_static("makeMinimalSchema", &AmpInfoTable::makeMinimalSchema);
95  cls.def_static("checkSchema", &AmpInfoTable::checkSchema, "other"_a);
96  cls.def_static("getNameKey", &AmpInfoTable::getNameKey);
97  cls.def_static("getBBoxMinKey", &AmpInfoTable::getBBoxMinKey);
98  cls.def_static("getBBoxExtentKey", &AmpInfoTable::getBBoxExtentKey);
99  cls.def_static("getGainKey", &AmpInfoTable::getGainKey);
100  cls.def_static("getReadNoiseKey", &AmpInfoTable::getReadNoiseKey);
101  cls.def_static("getSaturationKey", &AmpInfoTable::getSaturationKey);
102  cls.def_static("getSuspectLevelKey", &AmpInfoTable::getSuspectLevelKey);
103  cls.def_static("getReadoutCornerKey", &AmpInfoTable::getReadoutCornerKey);
104  cls.def_static("getLinearityCoeffsKey", &AmpInfoTable::getLinearityCoeffsKey);
105  cls.def_static("getLinearityTypeKey", &AmpInfoTable::getLinearityTypeKey);
106  cls.def_static("getHasRawInfoKey", &AmpInfoTable::getHasRawInfoKey);
107  cls.def_static("getRawBBoxMinKey", &AmpInfoTable::getRawBBoxMinKey);
108  cls.def_static("getRawBBoxExtentKey", &AmpInfoTable::getRawBBoxExtentKey);
109  cls.def_static("getRawDataBBoxMinKey", &AmpInfoTable::getRawDataBBoxMinKey);
110  cls.def_static("getRawDataBBoxExtentKey", &AmpInfoTable::getRawDataBBoxExtentKey);
111  cls.def_static("getRawFlipXKey", &AmpInfoTable::getRawFlipXKey);
112  cls.def_static("getRawFlipYKey", &AmpInfoTable::getRawFlipYKey);
113  cls.def_static("getRawXYOffsetKey", &AmpInfoTable::getRawXYOffsetKey);
114  cls.def_static("getRawHorizontalOverscanBBoxMinKey", &AmpInfoTable::getRawHorizontalOverscanBBoxMinKey);
115  cls.def_static("getRawHorizontalOverscanBBoxExtentKey",
116  &AmpInfoTable::getRawHorizontalOverscanBBoxExtentKey);
117  cls.def_static("getRawVerticalOverscanBBoxMinKey", &AmpInfoTable::getRawVerticalOverscanBBoxMinKey);
118  cls.def_static("getRawVerticalOverscanBBoxExtentKey", &AmpInfoTable::getRawVerticalOverscanBBoxExtentKey);
119  cls.def_static("getRawPrescanBBoxMinKey", &AmpInfoTable::getRawPrescanBBoxMinKey);
120  cls.def_static("getRawPrescanBBoxExtentKey", &AmpInfoTable::getRawPrescanBBoxExtentKey);
121 
122  cls.def("clone", &AmpInfoTable::clone);
123  cls.def("makeRecord", &AmpInfoTable::makeRecord);
124  cls.def("copyRecord",
125  (std::shared_ptr<AmpInfoRecord> (AmpInfoTable::*)(BaseRecord const &)) & AmpInfoTable::copyRecord,
126  "other"_a);
127  cls.def("copyRecord",
128  (std::shared_ptr<AmpInfoRecord> (AmpInfoTable::*)(BaseRecord const &, SchemaMapper const &)) &
129  AmpInfoTable::copyRecord,
130  "other"_a, "mapper"_a);
131  return cls;
132 }
133 
134 PYBIND11_MODULE(ampInfo, mod) {
135  py::enum_<ReadoutCorner>(mod, "ReadoutCorner")
136  .value("LL", ReadoutCorner::LL)
137  .value("LR", ReadoutCorner::LR)
138  .value("UR", ReadoutCorner::UR)
139  .value("UL", ReadoutCorner::UL)
140  .export_values();
141 
142  auto clsAmpInfoRecord = declareAmpInfoRecord(mod);
143  auto clsAmpInfoTable = declareAmpInfoTable(mod);
144  auto clsAmpInfoColumnView = table::python::declareColumnView<AmpInfoRecord>(mod, "AmpInfo");
145  auto clsAmpInfoCatalog = table::python::declareCatalog<AmpInfoRecord>(mod, "AmpInfo");
146 
147  clsAmpInfoRecord.attr("Table") = clsAmpInfoTable;
148  clsAmpInfoRecord.attr("ColumnView") = clsAmpInfoColumnView;
149  clsAmpInfoRecord.attr("Catalog") = clsAmpInfoCatalog;
150  clsAmpInfoTable.attr("Record") = clsAmpInfoRecord;
151  clsAmpInfoTable.attr("ColumnView") = clsAmpInfoColumnView;
152  clsAmpInfoTable.attr("Catalog") = clsAmpInfoCatalog;
153  clsAmpInfoCatalog.attr("Record") = clsAmpInfoRecord;
154  clsAmpInfoCatalog.attr("Table") = clsAmpInfoTable;
155  clsAmpInfoCatalog.attr("ColumnView") = clsAmpInfoColumnView;
156 }
157 }
158 }
159 }
160 } // namespace lsst::afw::table::<anonymous>
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:34
A base class for image defects.