Skip to content

Commit

Permalink
replace by TreecorrConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
PFLeget committed Sep 26, 2024
1 parent 6c09696 commit af97734
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
36 changes: 7 additions & 29 deletions python/lsst/meas/algorithms/computeExPsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from lsst.pex.config import Config, Field
from lsst.pipe.base import Task
import lsst.pipe.base as pipeBase
from lsst.analysis.tools.actions.vector import TreecorrConfig
import treecorr
import copy
import numpy.typing as npt


__all__ = (
"ComputeExPsfConfig",
"ComputeExPsfTask",
)


class ComputeExPsfConfig(Config):
"""Config for ComputeExPsfTask."""

thetaMin = Field[float](
doc="Min angular scale value to compute Ex (arcmin).",
default=0.0,
)
thetaMax = Field[float](
doc="Max angular scale value to compute Ex (arcmin).",
default=1.0,
)
__all__ = ("ComputeExPsfTask",)


class ComputeExPsfTask(Task):
Expand Down Expand Up @@ -73,16 +57,16 @@ class ComputeExPsfTask(Task):
The struct contains the following data:
``E1``: `float`
<de1 de1> scalar correlation function, compute
in an angular bin define in ComputeExPsfConfig.
in an angular bin define in TreecorrConfig.
``E2``: `float`
<de2 de2> scalar correlation function, compute
in an angular bin define in ComputeExPsfConfig.
in an angular bin define in TreecorrConfig.
``Ex``: `float`
<de1 de2> scalar cross-correlation function, compute
in an angular bin define in ComputeExPsfConfig.
in an angular bin define in TreecorrConfig.
"""

ConfigClass = ComputeExPsfConfig
ConfigClass = TreecorrConfig # ComputeExPsfConfig
_DefaultName = "computeExPsf"

def run(
Expand All @@ -104,13 +88,7 @@ def run(
cat1 = treecorr.Catalog(k=de1, **kwargs_cat)
cat2 = treecorr.Catalog(k=de2, **kwargs_cat)

config_kk = {
"min_sep": self.config.thetaMin,
"max_sep": self.config.thetaMax,
"nbins": 1,
"bin_type": "Linear",
"sep_units": "arcmin",
}
config_kk = self.config.toDict()

kk = treecorr.KKCorrelation(config_kk)

Expand Down
16 changes: 12 additions & 4 deletions tests/test_computeExPsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ def test_comp_ex_psf(self) -> None:
dec = self.coord1[:, 1]

config = ComputeExPsfTask.ConfigClass()
config.thetaMin = 0.01
config.thetaMax = 5.0

config.min_sep = 0.01
config.max_sep = 5.0
config.nbins = 1
config.bin_type = "Linear"
config.sep_units = "arcmin"

task = ComputeExPsfTask(config)
output1 = task.run(self.de1, self.de2, ra, dec, units="arcmin")
Expand All @@ -237,8 +241,12 @@ def test_comp_ex_psf(self) -> None:
np.testing.assert_allclose(output1.Ex, 0.0, atol=1e-1)

config = ComputeExPsfTask.ConfigClass()
config.thetaMin = 600.0
config.thetaMax = 1000.0

config.min_sep = 600.0
config.max_sep = 1000.0
config.nbins = 1
config.bin_type = "Linear"
config.sep_units = "arcmin"

# At large scale, expect the scalar two-point correlation function to
# be all close to 0.
Expand Down

0 comments on commit af97734

Please sign in to comment.