Skip to content

Commit

Permalink
Merge pull request #121 from PaulHancock/dev-aegean
Browse files Browse the repository at this point in the history
bigfix for #117
  • Loading branch information
PaulHancock committed Jun 7, 2020
2 parents ce7d375 + cb9e0b2 commit 4302ae9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AegeanTools/__init__.py
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions AegeanTools/source_finder.py
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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.
Expand Down
32 changes: 27 additions & 5 deletions tests/test_source_finder.py
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +47,6 @@ def test_psf_with_nans():
return



def test_misc():
"""Test some random things"""
sf.IslandFittingData()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit 4302ae9

Please sign in to comment.