LSST Applications g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+48cd4dd530,g228ff663f5+2051e4e242,g262e1987ae+9c6f24d2e3,g29ae962dfc+03663621e0,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3fd5ace14f+8c4d25a1ce,g47891489e3+27ba970c8a,g53246c7159+edbf708997,g5b326b94bb+db962c32ee,g64539dfbff+d237af7fd9,g67b6fd64d1+27ba970c8a,g74acd417e5+8234f56c0c,g786e29fd12+af89c03590,g87389fa792+a4172ec7da,g88cb488625+6878ed1c5e,g89139ef638+27ba970c8a,g8d7436a09f+f76ea57dde,g8ea07a8fe4+79658f16ab,g90f42f885a+6577634e1f,g97be763408+494f77a6c4,g98df359435+1750ea0126,g9b50b81019+d8f85438e7,ga2180abaac+edbf708997,ga9e74d7ce9+128cc68277,gad4c79568f+321c5e11c3,gbf99507273+edbf708997,gc2a301910b+d237af7fd9,gca7fc764a6+27ba970c8a,gcedae5159b+afaec0eb3d,gd7ef33dd92+27ba970c8a,gdab6d2f7ff+8234f56c0c,gdbb4c4dda9+d237af7fd9,ge410e46f29+27ba970c8a,ge41e95a9f2+d237af7fd9,geaed405ab2+062dfc8cdc,w.2025.45
LSST Data Management Base Package
Loading...
Searching...
No Matches
_calib.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 <vector>
29
30#include "ndarray/pybind11.h"
31
33
34namespace py = pybind11;
35using namespace pybind11::literals;
36
37namespace lsst {
38namespace afw {
39namespace image {
40namespace {
41
42template <typename T>
43void declareVectorOperations(lsst::cpputils::python::WrapperCollection &wrappers) {
44 wrappers.wrap([](auto &mod) {
45 using Array = ndarray::Array<T, 1>;
46 using ConstArray = ndarray::Array<const T, 1>;
47 mod.def("abMagFromFlux", (Array(*)(ConstArray const &)) & abMagFromFlux<T>, "flux"_a);
48 mod.def("abMagErrFromFluxErr",
49 (Array(*)(ConstArray const &, ConstArray const &)) & abMagErrFromFluxErr<T>, "fluxErr"_a,
50 "flux"_a);
51 mod.def("fluxFromABMag", (Array(*)(ConstArray const &)) & fluxFromABMag<T>, "mag"_a);
52 mod.def("fluxErrFromABMagErr",
53 (Array(*)(ConstArray const &, ConstArray const &)) & fluxErrFromABMagErr<T>, "magErr"_a,
54 "mag"_a);
55 });
56}
57
58void declareCalib(lsst::cpputils::python::WrapperCollection &wrappers) {
59 wrappers.wrap([](auto &mod) {
60 mod.def("abMagFromFlux", (double (*)(double)) & abMagFromFlux, "flux"_a);
61 mod.def("abMagErrFromFluxErr", (double (*)(double, double)) & abMagErrFromFluxErr, "fluxErr"_a,
62 "flux"_a);
63 mod.def("fluxFromABMag", (double (*)(double)) & fluxFromABMag, "mag"_a);
64 mod.def("fluxErrFromABMagErr", (double (*)(double, double)) & fluxErrFromABMagErr, "magErr"_a,
65 "mag"_a);
66 });
67}
68} // namespace
70 /* Module level */
71 declareCalib(wrappers);
72 declareVectorOperations<float>(wrappers);
73 declareVectorOperations<double>(wrappers);
74}
75} // namespace image
76} // namespace afw
77} // namespace lsst
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
double abMagErrFromFluxErr(double fluxErr, double flux)
Compute AB magnitude error from flux and flux error in Janskys.
Definition Calib.h:60
double fluxErrFromABMagErr(double magErr, double mag) noexcept
Compute flux error in Janskys from AB magnitude error and AB magnitude.
Definition Calib.h:68
void wrapCalib(lsst::cpputils::python::WrapperCollection &wrappers)
Definition _calib.cc:69
double abMagFromFlux(double flux)
Compute AB magnitude from flux in Janskys.
Definition Calib.h:57
double fluxFromABMag(double mag) noexcept
Compute flux in Janskys from AB magnitude.
Definition Calib.h:65