Skip to content

Commit

Permalink
Merge pull request #212 from esheldon/beckermr-patch-1
Browse files Browse the repository at this point in the history
BUG add kind attribute for PrePSFMom fitter
  • Loading branch information
beckermr authored Dec 10, 2021
2 parents ba5eb09 + f95b547 commit 38c3790
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v2.0.6

### bug fixes

- Fixed a bug where the `kind` attribute was not set for the `PrePSFMom` fitter.


## v2.0.5

### new features
Expand Down
2 changes: 1 addition & 1 deletion ngmix/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.5' # noqa
__version__ = '2.0.6' # noqa
14 changes: 8 additions & 6 deletions ngmix/prepsfmom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def __init__(self, fwhm, kernel, pad_factor=4, ap_rad=1.5):
self.pad_factor = pad_factor
self.kernel = kernel
self.ap_rad = ap_rad
if self.kernel == "ksigma":
self.kind = "ksigma"
elif self.kernel in ["gauss", "pgauss"]:
self.kind = "pgauss"
else:
raise ValueError(
"The kernel '%s' for PrePSFMom is not recognized!" % self.kernel
)

def go(self, obs, return_kernels=False, no_psf=False):
"""Measure the pre-PSF ksigma moments.
Expand Down Expand Up @@ -185,9 +193,6 @@ class KSigmaMom(PrePSFMom):
The apodization radius for the stamp in pixels. The default of 1.5 is likely
fine for most ground based surveys.
"""

kind = "ksigma"

def __init__(self, fwhm, pad_factor=4, ap_rad=1.5):
super().__init__(fwhm, 'ksigma', pad_factor=pad_factor, ap_rad=ap_rad)

Expand All @@ -212,9 +217,6 @@ class PGaussMom(PrePSFMom):
The apodization radius for the stamp in pixels. The default of 1.5 is likely
fine for most ground based surveys.
"""

kind = "pgauss"

def __init__(self, fwhm, pad_factor=4, ap_rad=1.5):
super().__init__(fwhm, 'pgauss', pad_factor=pad_factor, ap_rad=ap_rad)

Expand Down
19 changes: 18 additions & 1 deletion ngmix/tests/test_prepsfmom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import numpy as np
import pytest

from ngmix.prepsfmom import KSigmaMom, PGaussMom, _build_square_apodization_mask
from ngmix.prepsfmom import (
KSigmaMom, PGaussMom,
_build_square_apodization_mask,
PrePSFMom,
)
from ngmix import Jacobian
from ngmix import Observation
from ngmix.moments import make_mom_result
Expand All @@ -26,6 +30,19 @@ def _report_info(s, arr, mn, err):
)


def test_prepsfmom_kind():
fitter = PrePSFMom(2.0, 'gauss')
assert fitter.kind == 'pgauss'
fitter = PrePSFMom(2.0, 'pgauss')
assert fitter.kind == 'pgauss'
fitter = PrePSFMom(2.0, 'ksigma')
assert fitter.kind == 'ksigma'
fitter = PGaussMom(2.0)
assert fitter.kind == 'pgauss'
fitter = KSigmaMom(2.0)
assert fitter.kind == 'ksigma'


@pytest.mark.parametrize("cls", [KSigmaMom, PGaussMom])
def test_prepsfmom_raises_nopsf(cls):
fitter = cls(20)
Expand Down

0 comments on commit 38c3790

Please sign in to comment.