diff --git a/AegeanTools/__init__.py b/AegeanTools/__init__.py index 09ad562f..e78d6f87 100755 --- a/AegeanTools/__init__.py +++ b/AegeanTools/__init__.py @@ -11,7 +11,7 @@ """ __author__ = 'Paul Hancock' __version__ = '2.2.3' -__date__ = '2020-07-23' +__date__ = '2021-01-06' __citation__ = """ % If your work makes use of AegeanTools please cite the following papers as appropriate: diff --git a/AegeanTools/wcs_helpers.py b/AegeanTools/wcs_helpers.py index 5a034392..f7a4b3d1 100644 --- a/AegeanTools/wcs_helpers.py +++ b/AegeanTools/wcs_helpers.py @@ -87,6 +87,10 @@ def __init__(self, wcs, beam, pixscale, refpix, psf_file=None): self._psf_map = None # image data for the psf self._psf_wcs = None # wcs for the psf map + # until we can determine the difference between ra/dec based only on the wcs + # we must avoid using this sorting option + self.ra_dec_order = False + # the psf in pixel coords, at the reference coordinate self._psf_a = None self._psf_b = None @@ -100,6 +104,7 @@ def __init__(self, wcs, beam, pixscale, refpix, psf_file=None): self.beam.b, self.beam.pa) + # This construct gives us an attribute 'self.psf_map' which is only loaded on demand @property def psf_map(self): @@ -203,7 +208,7 @@ def pix2sky(self, pixel): """ x, y = pixel # wcs and python have opposite ideas of x/y - return self.wcs.all_pix2world([[y, x]], 1, ra_dec_order=True)[0] + return self.wcs.all_pix2world([[y, x]], 1, ra_dec_order=self.ra_dec_order)[0] def sky2pix(self, pos): """ @@ -221,7 +226,7 @@ def sky2pix(self, pos): The (x,y) pixel coordinates """ - pixel = self.wcs.all_world2pix([pos], 1, ra_dec_order=True) + pixel = self.wcs.all_world2pix([pos], 1, ra_dec_order=self.ra_dec_order) # wcs and python have opposite ideas of x/y return [pixel[0][1], pixel[0][0]] @@ -243,7 +248,7 @@ def psf_sky2pix(self, pos): """ # wcs and python have opposite ideas of x/y if self.psf_wcs is not None: - pixel = self.psf_wcs.all_world2pix([pos], 1, ra_dec_order=True) + pixel = self.psf_wcs.all_world2pix([pos], 1, ra_dec_order=self.ra_dec_order) return [pixel[0][1], pixel[0][0]] return None diff --git a/CHANGELOG.md b/CHANGELOG.md index ef24e642..1416b56a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v 2.2.3 +======= +Aegean +- Fixed a bug that caused a crash if the input file was in galactic coordinates + v 2.2.2 ======= Aegean diff --git a/tests/test_files/1904-66_SIN.lb.fits b/tests/test_files/1904-66_SIN.lb.fits new file mode 100644 index 00000000..018000e4 Binary files /dev/null and b/tests/test_files/1904-66_SIN.lb.fits differ diff --git a/tests/test_wcs_helpers.py b/tests/test_wcs_helpers.py index 041e62af..e9d7bf6d 100755 --- a/tests/test_wcs_helpers.py +++ b/tests/test_wcs_helpers.py @@ -159,6 +159,17 @@ def test_psf_funcs(): return +def test_galactic_coords(): + """Test that we can work with galactic coordinates""" + fname = 'tests/test_files/1904-66_SIN.lb.fits' + header = fits.getheader(fname) + try: + helper = WCSHelper.from_header(header) + except ValueError as e: + raise AssertionError("galactic coordinates break WCSHelper") + return + + if __name__ == "__main__": # introspect and run all the functions starting with 'test' for f in dir():