Commit 3af24543 authored by Simon Conseil's avatar Simon Conseil

More tests

parent cb150c5a
......@@ -189,8 +189,6 @@ def struct_from_moffat_fwhm(wcs, fwhm, psf_threshold=0.5, beta=2.5):
# image size will be twice the full-width, to account for
# psf_threshold < 0.5
size = int(round(fwhm / wcs.get_step(u.arcsec)[0])) * 2 + 1
if size % 2 == 0:
size += 1
psf = moffat_image(fwhm=(fwhm, fwhm), n=beta, peak=True,
wcs=wcs[:size, :size])
......@@ -207,8 +205,6 @@ def _get_psf_convolution_params(convolve_fwhm, segmap, psf_threshold):
# compute a structuring element for the dilatation, to simulate
# a convolution with a psf, but faster.
dilateit = 1
# logging.getLogger(__name__).debug(
# 'dilate with %d iterations, psf=%.2f', dilateit, convolve_fwhm)
struct = struct_from_moffat_fwhm(segmap.img.wcs, convolve_fwhm,
psf_threshold=psf_threshold)
else:
......
......@@ -22,6 +22,9 @@ def test_segmap():
assert_array_equal(segmap.copy().img.data, segmap.img.data)
cmap = segmap.cmap()
assert cmap.N == 14 # nb of values in the segmap
def test_align_segmap():
segmap = Segmap(get_data_file('segmap', 'segmap.fits'))
......@@ -31,17 +34,23 @@ def test_align_segmap():
assert (aligned.img.wcs.get_rot() - ref.wcs.get_rot()) < 1e-3
def test_cut_header():
segmap = Segmap(get_data_file('segmap', 'segmap.fits'),
cut_header_after='NAXIS2')
assert 'RADESYS' not in segmap.img.primary_header
assert 'RADESYS' not in segmap.img.data_header
def test_create_masks(tmpdir):
segfile = get_data_file('segmap', 'segmap.fits')
reffile = get_data_file('segmap', 'image.fits')
catalog = get_data_file('segmap', 'catalog.fits')
create_masks_from_segmap(
segfile, catalog, reffile, n_jobs=1, skip_existing=True,
segfile, catalog, reffile, n_jobs=1,
masksky_name=str(tmpdir.join('mask-sky.fits')),
maskobj_name=str(tmpdir.join('mask-source-%05d.fits')),
idname='id', raname='ra', decname='dec', margin=5, mask_size=(10, 10),
convolve_fwhm=0)
idname='id', raname='ra', decname='dec', margin=5, mask_size=(10, 10))
assert len(glob(str(tmpdir.join('mask-source*')))) == 13
assert len(glob(str(tmpdir.join('mask-sky*')))) == 1
......@@ -50,6 +59,15 @@ def test_create_masks(tmpdir):
assert mask.shape == (50, 50)
assert mask.sum() == 56
# test skip_existing
create_masks_from_segmap(
segfile, catalog, reffile, n_jobs=1, skip_existing=True,
masksky_name=str(tmpdir.join('mask-sky.fits')),
maskobj_name=str(tmpdir.join('mask-source-%05d.fits')),
idname='id', raname='ra', decname='dec', margin=5, mask_size=(10, 10),
convolve_fwhm=0)
# test convolve_fwhm
create_masks_from_segmap(
segfile, catalog, reffile, n_jobs=1, skip_existing=True,
masksky_name=str(tmpdir.join('mask2-sky.fits')),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment