Skip to content

Commit

Permalink
CoaddPsf: add control class
Browse files Browse the repository at this point in the history
This allows simple configuration of CoaddPsf from python.
  • Loading branch information
PaulPrice committed Jul 21, 2017
1 parent 6e7f056 commit 13f8791
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions include/lsst/meas/algorithms/CoaddPsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <memory>
#include "lsst/base.h"
#include "lsst/pex/config.h"
#include "lsst/meas/algorithms/ImagePsf.h"
#include "lsst/afw/image/Wcs.h"
#include "lsst/afw/table/Exposure.h"
Expand All @@ -36,6 +37,18 @@

namespace lsst { namespace meas { namespace algorithms {

class CoaddPsfControl {
public:

LSST_CONTROL_FIELD(warpingKernelName, std::string,
"Name of warping kernel; choices: lanczos3,lanczos4,lanczos5,bilinear,nearest");
LSST_CONTROL_FIELD(cacheSize, int, "Warping kernel cache size");

explicit CoaddPsfControl(std::string _warpingKernelName="lanczos3", int _cacheSize=10000) :
warpingKernelName(_warpingKernelName), cacheSize(_cacheSize)
{}
};

/**
* @brief CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
*
Expand Down Expand Up @@ -68,6 +81,27 @@ class CoaddPsf : public afw::table::io::PersistableFacade<CoaddPsf>, public Imag
int cacheSize=10000
);

/**
* @brief Constructor for CoaddPsf
*
* The ExposureCatalog contains info about each visit/ccd in Coadd; this must be provided to the
* constructor, and cannot be changed.
*
* @param[in] catalog ExposureCatalog containing the id, bbox, wcs, psf and weight for
* each ccd/visit. This is usually the same catalog as the "ccds"
* catalog in the coadd Exposure's CoaddInputs.
* @param[in] coaddWcs Wcs for the coadd.
* @param[in] ctrl Configuration options.
* @param[in] weightFieldName Field name that contains the weight of the exposure in the coadd;
* defaults to "weight".
*/
CoaddPsf(
afw::table::ExposureCatalog const & catalog,
afw::image::Wcs const & coaddWcs,
CoaddPsfControl const & ctrl,
std::string const & weightFieldName = "weight"
) : CoaddPsf(catalog, coaddWcs, weightFieldName, ctrl.warpingKernelName, ctrl.cacheSize) {}

/// Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
virtual PTR(afw::detection::Psf) clone() const;

Expand Down
4 changes: 4 additions & 0 deletions python/lsst/meas/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@
for name in dict(globals()):
if name.endswith("_swigregister"):
del globals()[name]

from lsst.pex.config import makeConfigClass
makeConfigClass(CoaddPsfControl, "CoaddPsfConfig")
del makeConfigClass
11 changes: 11 additions & 0 deletions python/lsst/meas/algorithms/coaddPsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "lsst/afw/table/io/python.h"
#include "lsst/meas/algorithms/CoaddPsf.h"
#include "lsst/pex/config/python.h" // for LSST_DECLARE_CONTROL_FIELD

namespace py = pybind11;
using namespace pybind11::literals;
Expand All @@ -34,6 +35,13 @@ namespace algorithms {
PYBIND11_PLUGIN(coaddPsf) {
py::module mod("coaddPsf");

/* CoaddPsfControl */
py::class_<CoaddPsfControl, std::shared_ptr<CoaddPsfControl>> clsControl(mod, "CoaddPsfControl");
clsControl.def(py::init<std::string, int>(), "warpingKernelName"_a="lanczos3", "cacheSize"_a=10000);
LSST_DECLARE_CONTROL_FIELD(clsControl, CoaddPsfControl, warpingKernelName);
LSST_DECLARE_CONTROL_FIELD(clsControl, CoaddPsfControl, cacheSize);

/* CoaddPsf */
afw::table::io::python::declarePersistableFacade<CoaddPsf>(mod, "CoaddPsf");

py::class_<CoaddPsf, std::shared_ptr<CoaddPsf>, afw::table::io::PersistableFacade<CoaddPsf>, ImagePsf>
Expand All @@ -44,6 +52,9 @@ PYBIND11_PLUGIN(coaddPsf) {
std::string const &, std::string const &, int>(),
"catalog"_a, "coaddWcs"_a, "weightFieldName"_a = "weight",
"warpingKernelName"_a = "lanczos3", "cacheSize"_a = 10000);
clsCoaddPsf.def(py::init<afw::table::ExposureCatalog const &, afw::image::Wcs const &,
CoaddPsfControl const &, std::string const &>(),
"catalog"_a, "coaddWcs"_a, "ctrl"_a, "weightFieldName"_a = "weight");

/* Members */
clsCoaddPsf.def("clone", &CoaddPsf::clone);
Expand Down

0 comments on commit 13f8791

Please sign in to comment.