lsst.afw  13.0-94-ga1c444047
filter.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 "lsst/daf/base/PropertySet.h"
27 #include "lsst/pex/policy/Policy.h"
28 #include "lsst/afw/image/Filter.h"
29 
30 namespace py = pybind11;
31 using namespace pybind11::literals;
32 
33 namespace lsst {
34 namespace afw {
35 namespace image {
36 namespace {
37 
38 using PyFilterProperty = py::class_<FilterProperty, std::shared_ptr<FilterProperty>>;
39 
40 using PyFilter = py::class_<Filter, std::shared_ptr<Filter>>;
41 
43  py::module mod("filter");
44 
45  py::module::import("lsst.daf.base");
46  py::module::import("lsst.pex.policy");
47 
48  mod.def("stripFilterKeywords", &detail::stripFilterKeywords, "metadata"_a);
49 
50  PyFilterProperty clsFilterProperty(mod, "FilterProperty");
51  clsFilterProperty.def(py::init<std::string const &, double, bool>(), "name"_a, "lambdaEff"_a,
52  "force"_a = false);
53  // note: metadata should be defaulted with "metadata"_a=daf::base::PropertySet()
54  // but that causes an error about copying when the Python extension is imported
55  clsFilterProperty.def(py::init<std::string const &, daf::base::PropertySet const &, bool>(), "name"_a,
56  "metadata"_a, "force"_a = false);
57  clsFilterProperty.def(py::init<std::string const &, pex::policy::Policy const &, bool>(), "name"_a,
58  "policy"_a, "force"_a = false);
59  clsFilterProperty.def(
60  "__eq__", [](FilterProperty const &self, FilterProperty const &other) { return self == other; },
61  py::is_operator());
62  clsFilterProperty.def(
63  "__ne__", [](FilterProperty const &self, FilterProperty const &other) { return self != other; },
64  py::is_operator());
65  clsFilterProperty.def("getName", &FilterProperty::getName);
66  clsFilterProperty.def("getLambdaEff", &FilterProperty::getLambdaEff);
67  clsFilterProperty.def_static("reset", &FilterProperty::reset);
68  clsFilterProperty.def_static("lookup", &FilterProperty::lookup, "name"_a);
69 
70  PyFilter clsFilter(mod, "Filter");
71  clsFilter.def(py::init<std::string const &, bool const>(), "name"_a, "force"_a = false);
72  clsFilter.def(py::init<int>(), "id"_a = Filter::UNKNOWN);
73  clsFilter.def(py::init<std::shared_ptr<daf::base::PropertySet const>, bool const>(), "metadata"_a,
74  "force"_a = false);
75  clsFilter.def("__eq__", [](Filter const &self, Filter const &other) { return self == other; },
76  py::is_operator());
77  clsFilter.def("__ne__", [](Filter const &self, Filter const &other) { return self != other; },
78  py::is_operator());
79  clsFilter.def_readonly_static("AUTO", &Filter::AUTO);
80  clsFilter.def_readonly_static("UNKNOWN", &Filter::UNKNOWN);
81  clsFilter.def("getId", &Filter::getId);
82  clsFilter.def("getName", &Filter::getName);
83  clsFilter.def("getCanonicalName", &Filter::getCanonicalName);
84  clsFilter.def("getAliases", &Filter::getAliases);
85  clsFilter.def("getFilterProperty", &Filter::getFilterProperty);
86  clsFilter.def_static("reset", &Filter::reset);
87  clsFilter.def_static("define", &Filter::define, "filterProperty"_a, "id"_a = Filter::AUTO,
88  "force"_a = false);
89  clsFilter.def_static("defineAlias", &Filter::defineAlias, "oldName"_a, "newName"_a, "force"_a = false);
90  clsFilter.def_static("getNames", &Filter::getNames);
91 
92  return mod.ptr();
93 }
94 }
95 }
96 }
97 } // namespace lsst::afw::image::<anonymous>
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
Definition: Filter.cc:123
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
A base class for image defects.
Definition: cameraGeom.dox:3