From c9a94e2f96c54fcf4348b05dae37c2e672feab47 Mon Sep 17 00:00:00 2001 From: PaulHancock Date: Sun, 7 Jun 2020 20:40:26 +0800 Subject: [PATCH 1/4] create test for #117 --- tests/test_source_finder.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/test_source_finder.py b/tests/test_source_finder.py index a9e68e6c..6b89042f 100755 --- a/tests/test_source_finder.py +++ b/tests/test_source_finder.py @@ -9,6 +9,7 @@ from AegeanTools import source_finder as sf from AegeanTools.wcs_helpers import Beam, WCSHelper from AegeanTools import models, flags +from AegeanTools.models import classify_catalog from copy import deepcopy import numpy as np import logging @@ -46,7 +47,6 @@ def test_psf_with_nans(): return - def test_misc(): """Test some random things""" sf.IslandFittingData() @@ -258,8 +258,31 @@ def test_esimate_lmfit_parinfo(): return +def test_island_contours(): + """Test that island contours are correct""" + log = logging.getLogger("Aegean") + sfinder = sf.SourceFinder(log=log) + filename = 'tests/test_files/synthetic_test.fits' + nsrc = 98 + nisl = 97 + ntot = nsrc+nisl + + # vanilla source finding + found = sfinder.find_sources_in_image(filename, cores=1, rms=0.5, bkg=0, doislandflux=True) + + components, islands, simples = classify_catalog(found) + isle_0_contour = np.array([(41, 405), (41, 406), (41, 407), (42, 407), (42, 408), (42, 409), (43, 409), (43, 410), + (44, 410), (45, 410), (46, 410), (47, 410), (47, 409), (48, 409), (48, 408), (49, 408), + (49, 407), (49, 406), (49, 405), (48, 405), (48, 404), (48, 403), (47, 403), (46, 403), + (45, 403), (44, 403), (43, 403), (43, 404), (42, 404), (42, 405)]) + if not np.all(np.array(islands[0].contour) == isle_0_contour): + raise AssertionError("Island contour for island 0 is incoorect") + return + + # for 3.0 functionality + def test_find_islands(): im = np.ones((10,12), dtype=np.float32) bkg = np.zeros_like(im) @@ -351,10 +374,9 @@ def test_estimate_parinfo_image(): if __name__ == "__main__": - #test_psf_with_nans() - #test_estimate_parinfo_image() - #import sys - #sys.exit() + test_island_contours() + import sys + sys.exit() # introspect and run all the functions starting with 'test' for f in dir(): #['test_find_islands', 'test_estimate_parinfo_image', 'test_find_and_prior_sources']: if f.startswith('test'): From 4523f4ed1a6d8bbf44d97944f04cfd6dd0658191 Mon Sep 17 00:00:00 2001 From: PaulHancock Date: Sun, 7 Jun 2020 20:41:13 +0800 Subject: [PATCH 2/4] fix bug #117 --- AegeanTools/source_finder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AegeanTools/source_finder.py b/AegeanTools/source_finder.py index 50c003c6..c4014030 100755 --- a/AegeanTools/source_finder.py +++ b/AegeanTools/source_finder.py @@ -1008,8 +1008,8 @@ def result_to_components(self, result, model, island_data, isflags): area = height * width source.area = area * source.pixels / source.x_width / source.y_width # area is in deg^2 - # create contours - msq = MarchingSquares(idata) + # create contours around the data which was used in fitting + msq = MarchingSquares(kappa_sigma) source.contour = [(a[0] + xmin, a[1] + ymin) for a in msq.perimeter] # calculate the maximum angular size of this island, brute force method source.max_angular_size = 0 From 93fd5b5a1e375c08d31d73b8a35caba65e868235 Mon Sep 17 00:00:00 2001 From: PaulHancock Date: Sun, 7 Jun 2020 20:42:29 +0800 Subject: [PATCH 3/4] update date --- AegeanTools/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AegeanTools/__init__.py b/AegeanTools/__init__.py index eca9e3dd..07768bb4 100755 --- a/AegeanTools/__init__.py +++ b/AegeanTools/__init__.py @@ -11,7 +11,7 @@ """ __author__ = 'Paul Hancock' __version__ = '2.2.2' -__date__ = '2020-06-06' +__date__ = '2020-06-07' __citation__ = """ % If your work makes use of AegeanTools please cite the following papers as appropriate: From cb9e0b2ed70dfe9dad819a2d8f23c613eada38bc Mon Sep 17 00:00:00 2001 From: PaulHancock Date: Sun, 7 Jun 2020 20:42:45 +0800 Subject: [PATCH 4/4] include bugfix for #117 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1ed4db2..c4b35625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v 2.2.2 ======= Aegean - Fixed a bug that could cause a crash if the psf map had nan values +- Fixed a bug that caused island contours to just be boxes. MIMAS - added new functionality, `--mask2mim`, which will convert a fits file into a region file.