From e65cb1d505ad782ba164a1b40b593d0c1bac8840 Mon Sep 17 00:00:00 2001 From: John Parejko Date: Wed, 29 Jan 2025 16:55:42 -0800 Subject: [PATCH 1/3] Add getters/properties to KernelVisitor --- include/lsst/ip/diffim/BuildSingleKernelVisitor.h | 6 ++++++ python/lsst/ip/diffim/detail/buildSingleKernelVisitor.cc | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/include/lsst/ip/diffim/BuildSingleKernelVisitor.h b/include/lsst/ip/diffim/BuildSingleKernelVisitor.h index 7347c2e3e..549b737ed 100644 --- a/include/lsst/ip/diffim/BuildSingleKernelVisitor.h +++ b/include/lsst/ip/diffim/BuildSingleKernelVisitor.h @@ -56,6 +56,12 @@ namespace detail { int getNProcessed() {return _nProcessed;} void reset() {_nRejected = 0; _nProcessed = 0;} + std::shared_ptr getPropertySet() { return _ps; } + bool getSkipBuilt() { return _skipBuilt; } + bool getUseRegularization() { return _useRegularization; } + bool getUseCoreStats() { return _useCoreStats; } + int getCoreRadius() { return _coreRadius; } + void processCandidate(lsst::afw::math::SpatialCellCandidate *candidate); private: diff --git a/python/lsst/ip/diffim/detail/buildSingleKernelVisitor.cc b/python/lsst/ip/diffim/detail/buildSingleKernelVisitor.cc index f84cffa9e..0cbb23c94 100644 --- a/python/lsst/ip/diffim/detail/buildSingleKernelVisitor.cc +++ b/python/lsst/ip/diffim/detail/buildSingleKernelVisitor.cc @@ -69,6 +69,13 @@ void declareBuildSingleKernelVisitor(lsst::cpputils::python::WrapperCollection & cls.def("getNProcessed", &BuildSingleKernelVisitor::getNProcessed); cls.def("reset", &BuildSingleKernelVisitor::reset); cls.def("processCandidate", &BuildSingleKernelVisitor::processCandidate, "candidate"_a); + cls.def_property_readonly("nRejected", &BuildSingleKernelVisitor::getNRejected); + cls.def_property_readonly("nProcessed", &BuildSingleKernelVisitor::getNProcessed); + cls.def_property_readonly("useRegularization", &BuildSingleKernelVisitor::getUseRegularization); + cls.def_property_readonly("skipBuilt", &BuildSingleKernelVisitor::getSkipBuilt); + cls.def_property_readonly("useCoreStats", &BuildSingleKernelVisitor::getUseCoreStats); + cls.def_property_readonly("coreRadius", &BuildSingleKernelVisitor::getCoreRadius); + cls.def_property_readonly("propertySet", &BuildSingleKernelVisitor::getPropertySet); mod.def("makeBuildSingleKernelVisitor", (std::shared_ptr>(*)(afw::math::KernelList const &, From 3f28eea5f785bd6688c67774ecb5121b93ee270e Mon Sep 17 00:00:00 2001 From: John Parejko Date: Thu, 30 Jan 2025 16:38:08 -0800 Subject: [PATCH 2/3] Cleanup docstrings in psfMatch --- python/lsst/ip/diffim/psfMatch.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/python/lsst/ip/diffim/psfMatch.py b/python/lsst/ip/diffim/psfMatch.py index c56a18021..90baa40d6 100644 --- a/python/lsst/ip/diffim/psfMatch.py +++ b/python/lsst/ip/diffim/psfMatch.py @@ -455,6 +455,12 @@ class PsfMatchTask(pipeBase.Task, abc.ABC): also performs background matching and returns the differential background model as an `lsst.afw.math.Kernel.SpatialFunction`. + The initialization sets the Psf-matching kernel configuration using the + value of self.config.kernel.active. If the kernel is requested with + regularization to moderate the bias/variance tradeoff, currently only used + when a delta function kernel basis is provided, it creates a + regularization matrix stored as member variable self.hMat. + **Invoking the Task** As a base class, this Task is not directly invoked. However, ``run()`` methods that are @@ -549,23 +555,6 @@ def DebugInfo(name): _DefaultName = "psfMatch" def __init__(self, *args, **kwargs): - """Create the psf-matching Task - - Parameters - ---------- - *args - Arguments to be passed to ``lsst.pipe.base.task.Task.__init__`` - **kwargs - Keyword arguments to be passed to ``lsst.pipe.base.task.Task.__init__`` - - Notes - ----- - The initialization sets the Psf-matching kernel configuration using the value of - self.config.kernel.active. If the kernel is requested with regularization to moderate - the bias/variance tradeoff, currently only used when a delta function kernel basis - is provided, it creates a regularization matrix stored as member variable - self.hMat. - """ pipeBase.Task.__init__(self, *args, **kwargs) self.kConfig = self.config.kernel.active From 188a2d5a14490e0b6fafac8d9122d7a010954e1f Mon Sep 17 00:00:00 2001 From: John Parejko Date: Wed, 29 Jan 2025 16:58:51 -0800 Subject: [PATCH 3/3] Modernize MakeKernel init Use super() Remove unnecessary self.kConfig: this is already done in the parent class. --- python/lsst/ip/diffim/makeKernel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/lsst/ip/diffim/makeKernel.py b/python/lsst/ip/diffim/makeKernel.py index 46dc47c65..77c9e42b7 100644 --- a/python/lsst/ip/diffim/makeKernel.py +++ b/python/lsst/ip/diffim/makeKernel.py @@ -94,8 +94,7 @@ class MakeKernelTask(PsfMatchTask): _DefaultName = "makeALKernel" def __init__(self, *args, **kwargs): - PsfMatchTask.__init__(self, *args, **kwargs) - self.kConfig = self.config.kernel.active + super().__init__(*args, **kwargs) # the background subtraction task uses a config from an unusual location, # so cannot easily be constructed with makeSubtask self.background = SubtractBackgroundTask(config=self.kConfig.afwBackgroundConfig, name="background",