LSST Applications g0f08755f38+c89d42e150,g1635faa6d4+b6cf076a36,g1653933729+a8ce1bb630,g1a0ca8cf93+4c08b13bf7,g28da252d5a+f33f8200ef,g29321ee8c0+0187be18b1,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+e740673f1a,g5fbc88fb19+17cd334064,g7642f7d749+c89d42e150,g781aacb6e4+a8ce1bb630,g80478fca09+f8b2ab54e1,g82479be7b0+e2bd23ab8b,g858d7b2824+c89d42e150,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+065360aec4,gacf8899fa4+9553554aa7,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gbd46683f8f+ac57cbb13d,gc28159a63d+9634bc57db,gcf0d15dbbd+e37acf7834,gda3e153d99+c89d42e150,gda6a2b7d83+e37acf7834,gdaeeff99f8+1711a396fd,ge2409df99d+cb1e6652d6,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+02b11634a5,w.2024.45
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("getNdim", &PsfexPsf::getNdim);
67 clsPsfexPsf.def("isPersistable", &PsfexPsf::isPersistable);
68 clsPsfexPsf.def("write", &PsfexPsf::write);
69 });
70}
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