LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Classes | Functions
lsst::meas::extensions::psfex Namespace Reference

Namespaces

namespace  detail
 
namespace  psfex
 
namespace  psfexPsfDeterminer
 
namespace  psfexStarSelector
 
namespace  version
 

Classes

class  PsfexPsf
 Represent a PSF as a linear combination of PSFEX (== Karhunen-Loeve) basis functions. More...
 

Functions

void wrapField (WrapperCollection &wrappers)
 
void wrapPrefs (WrapperCollection &wrappers)
 
void wrapPsfexPsf (WrapperCollection &wrappers)
 
void wrapPsf (WrapperCollection &wrappers)
 
 PYBIND11_MODULE (_psfexLib, mod)
 
void makeit (std::vector< std::shared_ptr< Field > > &fields_, std::vector< std::shared_ptr< Set > > const &sets)
 

Detailed Description

lsst.meas.extensions.psfex

Function Documentation

◆ makeit()

void lsst::meas::extensions::psfex::makeit ( std::vector< std::shared_ptr< Field > > & fields_,
std::vector< std::shared_ptr< Set > > const & sets )

RAII for the scribbling

Definition at line 72 of file psfexAdaptors.cc.

75{
76 if (sets.size() > MAXFILE) {
78 (boost::format("Too many sets: %d") % sets.size()).str());
79 }
80
81 std::vector<fieldstruct *> fields(fields_.size());
82 for (unsigned int i = 0; i != fields.size(); ++i) {
83 fields[i] = fields_[i]->impl;
84 }
85 /*
86 * We are going to scribble on prefs.incat_name to replace the array of (char*) with
87 * an array of data
88 */
89
91 struct ScribbleRaii {
92 int const ncat; // Original number
93 std::vector<char *> incat_name; // Original data
94 size_t const setsSize; // New size
95 ScribbleRaii(std::vector<std::shared_ptr<Set> > const& sets) :
96 ncat(prefs.ncat), incat_name(ncat), setsSize(sets.size())
97 {
98 for (int i = 0; i != prefs.ncat; ++i) {
99 incat_name[i] = prefs.incat_name[i];
100 }
101 for (unsigned int i = 0; i != sets.size(); ++i) {
102 prefs.incat_name[i] = reinterpret_cast<char *>(sets[i]->impl);
103 }
104 prefs.ncat = setsSize;
105 }
106 ~ScribbleRaii() {
107 for (int i = 0; i != prefs.ncat; ++i) {
108 prefs.incat_name[i] = incat_name[i];
109 }
110 for (size_t i = prefs.ncat; i < setsSize; ++i) {
111 prefs.incat_name[i] = NULL;
112 }
113 prefs.ncat = ncat;
114 }
115 };
116
117
118 contextstruct *context = NULL, *fullcontext = NULL;
119 {
120 ScribbleRaii scribble(sets);
121 makeit_body(&fields[0], &context, &fullcontext, false);
122 }
123
124 if (context->npc) {
125 context_end(fullcontext);
126 }
127 context_end(context);
128}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
Reports attempts to exceed implementation-defined length limits for some classes.
Definition Runtime.h:76
T size(T... args)

◆ PYBIND11_MODULE()

lsst::meas::extensions::psfex::PYBIND11_MODULE ( _psfexLib ,
mod  )

Definition at line 38 of file _psfexLib.cc.

38 {
39 lsst::cpputils::python::WrapperCollection wrappers(mod, "lsst.meas.extensions.psfex");
40 wrappers.addInheritanceDependency("lsst.meas.algorithms");
41 wrappers.addSignatureDependency("lsst.afw.table");
42 wrapField(wrappers);
43 wrapPrefs(wrappers);
44 wrapPsfexPsf(wrappers);
45 wrapPsf(wrappers);
46 wrappers.finish();
47}
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void wrapPrefs(WrapperCollection &wrappers)
Definition prefs.cc:37
void wrapField(WrapperCollection &wrappers)
Definition field.cc:39
void wrapPsfexPsf(WrapperCollection &wrappers)
Definition psfexPsf.cc:51

◆ wrapField()

void lsst::meas::extensions::psfex::wrapField ( WrapperCollection & wrappers)

Definition at line 39 of file field.cc.

39 {
40 using PyField = py::class_<Field, std::shared_ptr<Field>>;
41 wrappers.wrapType(PyField(wrappers.module, "Field"), [](auto &mod, auto &clsField) {
42
43 clsField.def(py::init<std::string const &>(),
44 "ident"_a = "unknown");
45
46 clsField.def("finalize", &Field::finalize);
47 clsField.def("addExt", &Field::addExt);
48 clsField.def("getNext", &Field::getNext);
49 clsField.def("getPsfs", &Field::getPsfs);
50
51 mod.def("makeit", makeit,
52 "fields"_a, "sets"_a);
53 });
54}
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition python.h:391

◆ wrapPrefs()

void lsst::meas::extensions::psfex::wrapPrefs ( WrapperCollection & wrappers)

Definition at line 37 of file prefs.cc.

37 {
38 using PyPrefs = py::class_<Prefs> ;
39 wrappers.wrapType(PyPrefs(wrappers.module, "Prefs"), [](auto &mod, auto &clsPrefs) {
40 clsPrefs.attr("ALL_EXTENSIONS") = py::cast(static_cast<int>(Prefs::ALL_EXTENSIONS));
41
42 clsPrefs.def(py::init<std::string const &, lsst::daf::base::PropertySet const *>(), "filename"_a,
43 "values"_a = nullptr);
44
45 clsPrefs.def("use", &Prefs::use);
46 clsPrefs.def("setCommandLine", &Prefs::setCommandLine);
47 clsPrefs.def("getNcat", &Prefs::getNcat);
48 clsPrefs.def("getPsfStep", &Prefs::getPsfStep);
49 clsPrefs.def("getMinsn", &Prefs::getMinsn);
50 clsPrefs.def("getMaxellip", &Prefs::getMaxellip);
51 clsPrefs.def("getFwhmrange", &Prefs::getFwhmrange);
52 clsPrefs.def("getPsfsize", &Prefs::getPsfsize);
53 clsPrefs.def("getAutoselectFlag", &Prefs::getAutoselectFlag);
54 clsPrefs.def("getFlagMask", &Prefs::getFlagMask);
55 clsPrefs.def("getMaxvar", &Prefs::getMaxvar);
56 clsPrefs.def("getVarType", &Prefs::getVarType);
57 clsPrefs.def("getBadpixNmax", &Prefs::getBadpixNmax);
58 clsPrefs.def("getBadpixFlag", &Prefs::getBadpixFlag);
59 clsPrefs.def("getCenterKey", &Prefs::getCenterKey);
60 clsPrefs.def("getPhotfluxRkey", &Prefs::getPhotfluxRkey);
61 clsPrefs.def("getPhotfluxNum", &Prefs::getPhotfluxNum);
62 clsPrefs.def("getPhotfluxerrRkey", &Prefs::getPhotfluxerrRkey);
63 clsPrefs.def("getPhotfluxerrNum", &Prefs::getPhotfluxerrNum);
64 clsPrefs.def("getProfAccuracy", &Prefs::getProfAccuracy);
65 clsPrefs.def("getVerboseType", &Prefs::getVerboseType);
66 clsPrefs.def("getContextName", &Prefs::getContextName);
67 clsPrefs.def("getContextGroup", &Prefs::getContextGroup);
68 clsPrefs.def("getGroupDeg", &Prefs::getGroupDeg);
69 clsPrefs.def("addCatalog", &Prefs::addCatalog);
70 clsPrefs.def("getCatalogs", &Prefs::getCatalogs);
71 });
72}

◆ wrapPsf()

void lsst::meas::extensions::psfex::wrapPsf ( WrapperCollection & wrappers)

Definition at line 39 of file psf.cc.

39 {
40 using PyContext = py::class_<Context>;
41
42 wrappers.wrapType(PyContext(wrappers.module, "Context"), [](auto &mod, auto &clsContext) {
43
44 clsContext.attr("KEEPHIDDEN") = py::cast(static_cast<int>(Context::KEEPHIDDEN));
45 clsContext.attr("REMOVEHIDDEN") = py::cast(static_cast<int>(Context::REMOVEHIDDEN));
46
47 clsContext.def(
48 py::init<std::vector<std::string> const &, std::vector<int> const &, std::vector<int> const &, bool>(),
49 "names"_a, "group"_a, "degree"_a, "pcexflag"_a);
50
51 clsContext.def("getName", &Context::getName);
52 clsContext.def("getNpc", &Context::getNpc);
53 clsContext.def("getPcflag", &Context::getPcflag);
54 clsContext.def("getPc", &Context::getPc);
55 });
56
57 using PySample = py::class_<Sample>;
58 wrappers.wrapType(PySample(wrappers.module, "Sample"), [](auto &mod, auto &clsSample) {
59
60 clsSample.def("getCatindex", &Sample::getCatindex);
61 clsSample.def("setCatindex", &Sample::setCatindex);
62 clsSample.def("getObjindex", &Sample::getObjindex);
63 clsSample.def("setObjindex", &Sample::setObjindex);
64 clsSample.def("getExtindex", &Sample::getExtindex);
65 clsSample.def("setExtindex", &Sample::setExtindex);
66 clsSample.def("setVig", &Sample::setVig);
67 clsSample.def("setNorm", &Sample::setNorm);
68 clsSample.def("setBacknoise2", &Sample::setBacknoise2);
69 clsSample.def("setGain", &Sample::setGain);
70 clsSample.def("setX", &Sample::setX);
71 clsSample.def("setY", &Sample::setY);
72 clsSample.def("setContext", &Sample::setContext);
73 clsSample.def("setFluxrad", &Sample::setFluxrad);
74 clsSample.def("getVig", &Sample::getVig);
75 clsSample.def("getVigResi", &Sample::getVigResi);
76 clsSample.def("getVigChi", &Sample::getVigChi);
77 clsSample.def("getVigWeight", &Sample::getVigWeight);
78 clsSample.def("getXY", &Sample::getXY);
79 clsSample.def("getNorm", &Sample::getNorm);
80 });
81
82 using PySet = py::class_<Set, std::shared_ptr<Set>>;
83 wrappers.wrapType(PySet(wrappers.module, "Set"), [](auto &mod, auto &clsSet) {
84 clsSet.def(py::init<Context &>());
85
86 clsSet.def("newSample", &Set::newSample);
87 clsSet.def("trimMemory", &Set::trimMemory);
88 clsSet.def("getFwhm", &Set::getFwhm);
89 clsSet.def("setFwhm", &Set::setFwhm);
90 clsSet.def("getNcontext", &Set::getNcontext);
91 clsSet.def("getNsample", &Set::getNsample);
92 clsSet.def("getContextOffset", &Set::getContextOffset);
93 clsSet.def("setContextOffset", &Set::setContextOffset);
94 clsSet.def("getContextScale", &Set::getContextScale);
95 clsSet.def("setContextScale", &Set::setContextScale);
96 clsSet.def("getRecentroid", &Set::getRecentroid);
97 clsSet.def("setRecentroid", &Set::setRecentroid);
98 clsSet.def("setVigSize", &Set::setVigSize);
99 clsSet.def("finiSample", &Set::finiSample);
100 clsSet.def("empty", &Set::empty);
101 clsSet.def("getContextNames", &Set::getContextNames);
102 clsSet.def("setContextname", &Set::setContextname);
103 clsSet.def("setBadFlags", &Set::setBadFlags);
104 clsSet.def("getBadFlags", &Set::getBadFlags);
105 clsSet.def("setBadSN", &Set::setBadSN);
106 clsSet.def("getBadSN", &Set::getBadSN);
107 clsSet.def("setBadFrmin", &Set::setBadFrmin);
108 clsSet.def("getBadFrmin", &Set::getBadFrmin);
109 clsSet.def("setBadFrmax", &Set::setBadFrmax);
110 clsSet.def("getBadFrmax", &Set::getBadFrmax);
111 clsSet.def("setBadElong", &Set::setBadElong);
112 clsSet.def("getBadElong", &Set::getBadElong);
113 clsSet.def("setBadPix", &Set::setBadPix);
114 clsSet.def("getBadPix", &Set::getBadPix);
115 clsSet.def("getSample", &Set::getSample);
116 });
117
118 using PyPsf = py::class_<Psf>;
119 wrappers.wrapType(PyPsf(wrappers.module, "Psf"), [](auto &mod, auto &clsPsf) {
120 clsPsf.def(py::init<>());
121
122 clsPsf.def("getLoc", &Psf::getLoc);
123 clsPsf.def("getResi", &Psf::getResi);
124 clsPsf.def("build", &Psf::build,
125 "x"_a, "y"_a, "other"_a = std::vector<double>());
126 clsPsf.def("clip", &Psf::clip);
127 });
128}

◆ wrapPsfexPsf()

void lsst::meas::extensions::psfex::wrapPsfexPsf ( WrapperCollection & wrappers)

Definition at line 51 of file psfexPsf.cc.

51 {
52 wrappers.module.attr("BIG") = py::cast(BIG);
53 wrappers.module.attr("INTERPFAC") = py::cast(INTERPFAC);
54
55 using PyPsfexPsf = py::class_<PsfexPsf, std::shared_ptr<PsfexPsf>, lsst::meas::algorithms::ImagePsf>;
56 wrappers.wrapType(PyPsfexPsf(wrappers.module, "PsfexPsf"), [](auto &mod, auto &clsPsfexPsf) {
57 lsst::afw::table::io::python::addPersistableMethods<PsfexPsf>(clsPsfexPsf);
58
59 clsPsfexPsf.def(py::init<lsst::meas::extensions::psfex::Psf const &, lsst::geom::Point2D const &>(),
60 "psf"_a, "averagePosition"_a = lsst::geom::Point2D());
61
62 clsPsfexPsf.def("clone", &PsfexPsf::clone);
63 clsPsfexPsf.def("getAveragePosition", &PsfexPsf::getAveragePosition);
64 clsPsfexPsf.def("getKernel", &PsfexPsf::getKernel,
65 "position"_a = lsst::geom::Point2D(std::numeric_limits<double>::quiet_NaN()));
66 clsPsfexPsf.def("isPersistable", &PsfexPsf::isPersistable);
67 clsPsfexPsf.def("write", &PsfexPsf::write);
68 });
69}
An intermediate base class for Psfs that use an image representation.
Definition ImagePsf.h:40
double INTERPFAC
Definition psfexPsf.cc:41
double BIG
Definition psfexPsf.cc:40