Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG add kind attribute for PrePSFMom fitter #212

Merged
merged 8 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
beckermr marked this conversation as resolved.
Show resolved Hide resolved
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