From 9c26806219df26f2b7a1265084fd072e3a64c80a Mon Sep 17 00:00:00 2001 From: Pierre-Francois Leget Date: Thu, 10 Oct 2024 09:37:57 -0700 Subject: [PATCH] add ComputeExPsfConfig --- python/lsst/meas/algorithms/computeExPsf.py | 16 ++++++++--- tests/test_computeExPsf.py | 30 ++++++++++----------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/python/lsst/meas/algorithms/computeExPsf.py b/python/lsst/meas/algorithms/computeExPsf.py index e09e47be3..b2e77d81f 100644 --- a/python/lsst/meas/algorithms/computeExPsf.py +++ b/python/lsst/meas/algorithms/computeExPsf.py @@ -21,6 +21,7 @@ from lsst.meas.algorithms.treecorrUtils import TreecorrConfig +from lsst.pex.config import Config, ConfigField from lsst.pipe.base import Task import lsst.pipe.base as pipeBase import treecorr @@ -28,7 +29,16 @@ import numpy.typing as npt -__all__ = ("ComputeExPsfTask") +__all__ = ("ComputeExPsfTask", "ComputeExPsfConfig") + + +class ComputeExPsfConfig(Config): + """Config class of ComputeExPsfTask.""" + + treecorr_config = ConfigField( + dtype=TreecorrConfig, + doc="treecorr config.", + ) class ComputeExPsfTask(Task): @@ -67,7 +77,7 @@ class ComputeExPsfTask(Task): in an angular bin define in TreecorrConfig. """ - ConfigClass = TreecorrConfig + ConfigClass = ComputeExPsfConfig _DefaultName = "computeExPsf" def run( @@ -89,7 +99,7 @@ def run( cat1 = treecorr.Catalog(k=de1, **kwargs_cat) cat2 = treecorr.Catalog(k=de2, **kwargs_cat) - config_kk = self.config.toDict() + config_kk = self.config.treecorr_config.toDict() kk = treecorr.KKCorrelation(config_kk) diff --git a/tests/test_computeExPsf.py b/tests/test_computeExPsf.py index b6c7a7eea..db3d8fb36 100644 --- a/tests/test_computeExPsf.py +++ b/tests/test_computeExPsf.py @@ -223,11 +223,11 @@ def test_comp_ex_psf(self) -> None: config = ComputeExPsfTask.ConfigClass() - config.min_sep = 0.01 - config.max_sep = 5.0 - config.nbins = 1 - config.bin_type = "Linear" - config.sep_units = "arcmin" + config.treecorr_config.min_sep = 0.01 + config.treecorr_config.max_sep = 5.0 + config.treecorr_config.nbins = 1 + config.treecorr_config.bin_type = "Linear" + config.treecorr_config.sep_units = "arcmin" task = ComputeExPsfTask(config) output1 = task.run(self.de1, self.de2, ra, dec, units="arcmin") @@ -242,11 +242,11 @@ def test_comp_ex_psf(self) -> None: config = ComputeExPsfTask.ConfigClass() - config.min_sep = 5.0 - config.max_sep = 600.0 - config.nbins = 1 - config.bin_type = "Linear" - config.sep_units = "arcmin" + config.treecorr_config.min_sep = 5.0 + config.treecorr_config.max_sep = 600.0 + config.treecorr_config.nbins = 1 + config.treecorr_config.bin_type = "Linear" + config.treecorr_config.sep_units = "arcmin" # At intermediar scale, expect E1>E2>Ex. @@ -259,11 +259,11 @@ def test_comp_ex_psf(self) -> None: config = ComputeExPsfTask.ConfigClass() - config.min_sep = 600.0 - config.max_sep = 1000.0 - config.nbins = 1 - config.bin_type = "Linear" - config.sep_units = "arcmin" + config.treecorr_config.min_sep = 600.0 + config.treecorr_config.max_sep = 1000.0 + config.treecorr_config.nbins = 1 + config.treecorr_config.bin_type = "Linear" + config.treecorr_config.sep_units = "arcmin" # At large scale, expect the scalar two-point correlation function to # be all close to 0.