-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update copyright banners apply clang-format
- Loading branch information
Matthias Wittgen
committed
Mar 22, 2021
1 parent
2a5702d
commit e1b732b
Showing
63 changed files
with
1,242 additions
and
1,326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
## -*- python -*- | ||
from lsst.sconsUtils import scripts | ||
scripts.BasicSConscript.pybind11(['cameraSys', | ||
'camera/camera', | ||
'detector/detector', | ||
'amplifier/amplifier', | ||
'orientation', | ||
'transformMap', | ||
'detectorCollection/detectorCollection'], | ||
addUnderscore=False) | ||
scripts.BasicSConscript.python(['_cameraGeom']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* This file is part of afw. | ||
* | ||
* Developed for the LSST Data Management System. | ||
* This product includes software developed by the LSST Project | ||
* (https://www.lsst.org). | ||
* See the COPYRIGHT file at the top-level directory of this distribution | ||
* for details of code ownership. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "pybind11/pybind11.h" | ||
#include <lsst/utils/python.h> | ||
#include "pybind11/stl.h" | ||
|
||
#include "ndarray/pybind11.h" | ||
|
||
#include "lsst/afw/table/BaseRecord.h" | ||
#include "lsst/afw/cameraGeom/Amplifier.h" | ||
|
||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
namespace lsst { | ||
namespace afw { | ||
namespace cameraGeom { | ||
|
||
using PyAmplifier = py::class_<Amplifier, std::shared_ptr<Amplifier>>; | ||
using PyAmplifierBuilder = py::class_<Amplifier::Builder, Amplifier, std::shared_ptr<Amplifier::Builder>>; | ||
|
||
void wrapAmplifier(lsst::utils::python::WrapperCollection &wrappers) { | ||
wrappers.addInheritanceDependency("lsst.afw.table"); | ||
wrappers.wrapType(py::enum_<ReadoutCorner>(wrappers.module, "ReadoutCorner"), [](auto &mod, auto &enm) { | ||
enm.value("LL", ReadoutCorner::LL); | ||
enm.value("LR", ReadoutCorner::LR); | ||
enm.value("UR", ReadoutCorner::UR); | ||
enm.value("UL", ReadoutCorner::UL); | ||
}); | ||
wrappers.wrapType(py::enum_<AssemblyState>(wrappers.module, "AssemblyState"), [](auto &mod, auto &enm) { | ||
enm.value("RAW", AssemblyState::RAW); | ||
enm.value("SCIENCE", AssemblyState::SCIENCE); | ||
}); | ||
auto amplifier = wrappers.wrapType(PyAmplifier(wrappers.module, "Amplifier"), [](auto &mod, auto &cls) { | ||
cls.def_static("getRecordSchema", &Amplifier::getRecordSchema); | ||
cls.def("toRecord", &Amplifier::toRecord); | ||
cls.def("rebuild", &Amplifier::rebuild); | ||
cls.def("getName", &Amplifier::getName); | ||
cls.def("getBBox", &Amplifier::getBBox); | ||
cls.def("getGain", &Amplifier::getGain); | ||
cls.def("getReadNoise", &Amplifier::getReadNoise); | ||
cls.def("getSaturation", &Amplifier::getSaturation); | ||
cls.def("getSuspectLevel", &Amplifier::getSuspectLevel); | ||
cls.def("getReadoutCorner", &Amplifier::getReadoutCorner); | ||
cls.def("getLinearityCoeffs", &Amplifier::getLinearityCoeffs); | ||
cls.def("getLinearityType", &Amplifier::getLinearityType); | ||
cls.def("getLinearityThreshold", &Amplifier::getLinearityThreshold); | ||
cls.def("getLinearityMaximum", &Amplifier::getLinearityMaximum); | ||
cls.def("getLinearityUnits", &Amplifier::getLinearityUnits); | ||
cls.def("getRawBBox", &Amplifier::getRawBBox); | ||
cls.def("getRawDataBBox", &Amplifier::getRawDataBBox); | ||
cls.def("getRawFlipX", &Amplifier::getRawFlipX); | ||
cls.def("getRawFlipY", &Amplifier::getRawFlipY); | ||
cls.def("getRawXYOffset", &Amplifier::getRawXYOffset); | ||
cls.def("getRawHorizontalOverscanBBox", &Amplifier::getRawHorizontalOverscanBBox); | ||
cls.def("getRawVerticalOverscanBBox", &Amplifier::getRawVerticalOverscanBBox); | ||
cls.def("getRawPrescanBBox", &Amplifier::getRawPrescanBBox); | ||
cls.def("getRawSerialOverscanBBox", &Amplifier::getRawSerialOverscanBBox); | ||
cls.def("getRawParallelOverscanBBox", &Amplifier::getRawParallelOverscanBBox); | ||
cls.def("getRawSerialPrescanBBox", &Amplifier::getRawSerialPrescanBBox); | ||
cls.def("getRawHorizontalPrescanBBox", &Amplifier::getRawHorizontalPrescanBBox); | ||
}); | ||
wrappers.wrapType(PyAmplifierBuilder(amplifier, "Builder"), [](auto &mod, auto &cls) { | ||
cls.def_static("fromRecord", &Amplifier::Builder::fromRecord); | ||
cls.def(py::init()); | ||
cls.def("finish", &Amplifier::Builder::finish); | ||
cls.def("assign", [](Amplifier::Builder &self, Amplifier const &other) { self = other; }); | ||
cls.def("setName", &Amplifier::Builder::setName, "name"_a); | ||
cls.def("setBBox", &Amplifier::Builder::setBBox, "bbox"_a); | ||
cls.def("setGain", &Amplifier::Builder::setGain, "gain"_a); | ||
cls.def("setReadNoise", &Amplifier::Builder::setReadNoise, "readNoise"_a); | ||
cls.def("setSaturation", &Amplifier::Builder::setSaturation, "saturation"_a); | ||
cls.def("setSuspectLevel", &Amplifier::Builder::setSuspectLevel, "suspectLevel"_a); | ||
cls.def("setReadoutCorner", &Amplifier::Builder::setReadoutCorner, "corner"_a); | ||
cls.def("setLinearityCoeffs", &Amplifier::Builder::setLinearityCoeffs, "coeffs"_a); | ||
// Backwards compatibility: accept std::vector (list in Python) in | ||
// addition to ndarray::Array (np.ndarray) | ||
cls.def("setLinearityCoeffs", [](Amplifier::Builder &self, std::vector<double> const &coeffs) { | ||
ndarray::Array<double, 1, 1> array = ndarray::allocate(coeffs.size()); | ||
std::copy(coeffs.begin(), coeffs.end(), array.begin()); | ||
self.setLinearityCoeffs(array); | ||
}); | ||
cls.def("setLinearityType", &Amplifier::Builder::setLinearityType, "type"_a); | ||
cls.def("setLinearityThreshold", &Amplifier::Builder::setLinearityThreshold, "threshold"_a); | ||
cls.def("setLinearityMaximum", &Amplifier::Builder::setLinearityMaximum, "maximum"_a); | ||
cls.def("setLinearityUnits", &Amplifier::Builder::setLinearityUnits, "units"_a); | ||
cls.def("setRawBBox", &Amplifier::Builder::setRawBBox, "bbox"_a); | ||
cls.def("setRawDataBBox", &Amplifier::Builder::setRawDataBBox, "bbox"_a); | ||
cls.def("setRawFlipX", &Amplifier::Builder::setRawFlipX, "rawFlipX"_a); | ||
cls.def("setRawFlipY", &Amplifier::Builder::setRawFlipY, "rawFlipY"_a); | ||
cls.def("setRawXYOffset", &Amplifier::Builder::setRawXYOffset, "offset"_a); | ||
cls.def("setRawHorizontalOverscanBBox", &Amplifier::Builder::setRawHorizontalOverscanBBox, "bbox"_a); | ||
cls.def("setRawVerticalOverscanBBox", &Amplifier::Builder::setRawVerticalOverscanBBox, "bbox"_a); | ||
cls.def("setRawPrescanBBox", &Amplifier::Builder::setRawPrescanBBox, "bbox"_a); | ||
cls.def("setRawSerialOverscanBBox", &Amplifier::Builder::setRawSerialOverscanBBox, "bbox"_a); | ||
cls.def("setRawParallelOverscanBBox", &Amplifier::Builder::setRawParallelOverscanBBox, "bbox"_a); | ||
cls.def("setRawSerialPrescanBBox", &Amplifier::Builder::setRawSerialPrescanBBox, "bbox"_a); | ||
cls.def("setRawHorizontalPrescanBBox", &Amplifier::Builder::setRawHorizontalPrescanBBox, "bbox"_a); | ||
}); | ||
} | ||
|
||
} // namespace cameraGeom | ||
} // namespace afw | ||
} // namespace lsst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* This file is part of afw. | ||
* | ||
* Developed for the LSST Data Management System. | ||
* This product includes software developed by the LSST Project | ||
* (https://www.lsst.org). | ||
* See the COPYRIGHT file at the top-level directory of this distribution | ||
* for details of code ownership. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "pybind11/pybind11.h" | ||
#include <lsst/utils/python.h> | ||
|
||
#include "pybind11/stl.h" | ||
|
||
#include "lsst/utils/python.h" | ||
#include "lsst/afw/table/io/python.h" | ||
#include "lsst/afw/cameraGeom/Camera.h" | ||
|
||
namespace py = pybind11; | ||
using namespace py::literals; | ||
|
||
namespace lsst { | ||
namespace afw { | ||
namespace cameraGeom { | ||
|
||
using PyCamera = py::class_<Camera, DetectorCollection, std::shared_ptr<Camera>>; | ||
using PyCameraBuilder = py::class_<Camera::Builder, DetectorCollectionBase<Detector::InCameraBuilder>, | ||
std::shared_ptr<Camera::Builder>>; | ||
|
||
// Bindings here are ordered to match the order of the declarations in | ||
// Camera.h to the greatest extent possible; modifications to this file should | ||
// attempt to preserve this. | ||
|
||
void wrapCamera(lsst::utils::python::WrapperCollection &wrappers) { | ||
wrappers.addInheritanceDependency("lsst.afw.table.io"); | ||
wrappers.addSignatureDependency("lsst.afw.cameraGeom"); | ||
auto camera = wrappers.wrapType(PyCamera(wrappers.module, "Camera"), [](auto &mod, auto &cls) { | ||
cls.def("rebuild", &Camera::rebuild); | ||
cls.def("getName", &Camera::getName); | ||
cls.def("getPupilFactoryName", &Camera::getPupilFactoryName); | ||
cls.def("findDetectors", &Camera::findDetectors, "point"_a, "cameraSys"_a); | ||
cls.def("findDetectorsList", &Camera::findDetectorsList, "pointList"_a, "cameraSys"_a); | ||
// transform methods are wrapped with lambdas that translate exceptions for backwards compatibility | ||
cls.def( | ||
"getTransform", | ||
[](Camera const &self, CameraSys const &fromSys, CameraSys const &toSys) { | ||
try { | ||
return self.getTransform(fromSys, toSys); | ||
} catch (pex::exceptions::NotFoundError &err) { | ||
PyErr_SetString(PyExc_KeyError, err.what()); | ||
throw py::error_already_set(); | ||
} | ||
}, | ||
"fromSys"_a, "toSys"_a); | ||
cls.def("getTransformMap", &Camera::getTransformMap); | ||
cls.def( | ||
"transform", | ||
[](Camera const &self, lsst::geom::Point2D const &point, CameraSys const &fromSys, | ||
CameraSys const &toSys) { | ||
try { | ||
return self.transform(point, fromSys, toSys); | ||
} catch (pex::exceptions::NotFoundError &err) { | ||
PyErr_SetString(PyExc_KeyError, err.what()); | ||
throw py::error_already_set(); | ||
} | ||
}, | ||
"point"_a, "fromSys"_a, "toSys"_a); | ||
cls.def( | ||
"transform", | ||
[](Camera const &self, std::vector<lsst::geom::Point2D> const &points, | ||
CameraSys const &fromSys, CameraSys const &toSys) { | ||
try { | ||
return self.transform(points, fromSys, toSys); | ||
} catch (pex::exceptions::NotFoundError &err) { | ||
PyErr_SetString(PyExc_KeyError, err.what()); | ||
throw py::error_already_set(); | ||
} | ||
}, | ||
"points"_a, "fromSys"_a, "toSys"_a); | ||
table::io::python::addPersistableMethods(cls); | ||
}); | ||
wrappers.wrapType(PyCameraBuilder(camera, "Builder"), [](auto &mod, auto &cls) { | ||
cls.def(py::init<std::string const &>(), "name"_a); | ||
cls.def(py::init<Camera const &>(), "camera"_a); | ||
cls.def("finish", &Camera::Builder::finish); | ||
cls.def("getName", &Camera::Builder::getName); | ||
cls.def("setName", &Camera::Builder::setName); | ||
cls.def("getPupilFactoryName", &Camera::Builder::getPupilFactoryName); | ||
cls.def("setPupilFactoryName", &Camera::Builder::setPupilFactoryName); | ||
cls.def("setPupilFactoryClass", [](Camera::Builder &self, py::object pupilFactoryClass) { | ||
std::string pupilFactoryName = "lsst.afw.cameraGeom.pupil.PupilFactory"; | ||
if (!pupilFactoryClass.is(py::none())) { | ||
pupilFactoryName = py::str("{}.{}").format(pupilFactoryClass.attr("__module__"), | ||
pupilFactoryClass.attr("__name__")); | ||
} | ||
self.setPupilFactoryName(pupilFactoryName); | ||
}); | ||
cls.def("setTransformFromFocalPlaneTo", &Camera::Builder::setTransformFromFocalPlaneTo, "toSys"_a, | ||
"transform"_a); | ||
cls.def("discardTransformFromFocalPlaneTo", &Camera::Builder::discardTransformFromFocalPlaneTo); | ||
cls.def("add", &Camera::Builder::add); | ||
cls.def("__delitem__", py::overload_cast<int>(&Camera::Builder::remove)); | ||
cls.def("__delitem__", py::overload_cast<std::string const &>(&Camera::Builder::remove)); | ||
}); | ||
} | ||
|
||
} // namespace cameraGeom | ||
} // namespace afw | ||
} // namespace lsst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.