Skip to content

Commit

Permalink
add unit test for mcal types
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouconghao committed Aug 5, 2024
1 parent 6977ce8 commit 9f271a7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions metadetect/lsst/tests/test_lsst_metadetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def do_coadding(rng, sim_data, nowarp):

@pytest.mark.parametrize('meas_type', [None, 'wmom', 'ksigma', 'pgauss'])
@pytest.mark.parametrize('subtract_sky', [None, False, True])
def test_lsst_metadetect_smoke(meas_type, subtract_sky):
@pytest.mark.parametrize("metacal_types_option", [None, "1p1m", "full"])
def test_lsst_metadetect_smoke(meas_type, subtract_sky, metacal_types_option):
rng = np.random.RandomState(seed=116)

bands = ['r', 'i']
Expand All @@ -103,12 +104,26 @@ def test_lsst_metadetect_smoke(meas_type, subtract_sky):
if meas_type is not None:
config['meas_type'] = meas_type

if metacal_types_option is not None:
if metacal_types_option == "1p1m":
metacal_types = ['noshear', '1p', '1m']
config['metacal'] = {}
elif metacal_types_option == "full":
metacal_types = ['noshear', '1p', '1m', '2p', '2m']
config['metacal'] = {}
config['metacal']['types'] = metacal_types
else:
metacal_types = ['noshear', '1p', '1m']

detected = afw_image.Mask.getPlaneBitMask('DETECTED')
res = run_metadetect(rng=rng, config=config, **data)

# we remove the DETECTED bit
assert np.all(res['noshear']['bmask'] & detected == 0)

for metacal_type in metacal_types:
assert metacal_type in res.keys(), f"metacal_type={metacal_type} not in res.keys()"

if meas_type is None:
front = 'wmom'
else:
Expand All @@ -118,7 +133,7 @@ def test_lsst_metadetect_smoke(meas_type, subtract_sky):
flux_name = f'{front}_band_flux'
assert gname in res['noshear'].dtype.names

for shear in ('noshear', '1p', '1m'):
for shear in metacal_types:
# 5x5 grid
assert res[shear].size == 25

Expand Down

0 comments on commit 9f271a7

Please sign in to comment.