LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Namespaces | Classes | Functions
lsst::meas::extensions::psfex Namespace Reference

Namespaces

 detail
 
 psfex
 
 psfexPsfDeterminer
 
 psfexStarSelector
 
 version
 

Classes

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

Functions

 PYBIND11_MODULE (field, mod)
 
 PYBIND11_MODULE (prefs, mod)
 
 PYBIND11_MODULE (psf, mod)
 
 PYBIND11_MODULE (psfexPsf, mod)
 
void makeit (std::vector< std::shared_ptr< Field > > &fields_, std::vector< std::shared_ptr< Set > > const &sets)
 

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
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
T size(T... args)

◆ PYBIND11_MODULE() [1/4]

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

Definition at line 38 of file field.cc.

38  {
39  py::class_<Field, std::shared_ptr<Field>> clsField(mod, "Field");
40 
41  clsField.def(py::init<std::string const&>(),
42  "ident"_a="unknown");
43 
44  clsField.def("finalize", &Field::finalize);
45  clsField.def("addExt", &Field::addExt);
46  clsField.def("getNext", &Field::getNext);
47  clsField.def("getPsfs", &Field::getPsfs);
48 
49  mod.def("makeit", makeit,
50  "fields"_a, "sets"_a);
51 }
void makeit(std::vector< std::shared_ptr< Field > > &fields_, std::vector< std::shared_ptr< Set > > const &sets)

◆ PYBIND11_MODULE() [2/4]

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

Definition at line 36 of file prefs.cc.

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

◆ PYBIND11_MODULE() [3/4]

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

Definition at line 37 of file psf.cc.

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

◆ PYBIND11_MODULE() [4/4]

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

Definition at line 50 of file psfexPsf.cc.

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