Skip to content

Commit

Permalink
Merge c9d839b into 169ecf3
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHancock committed Jan 6, 2021
2 parents 169ecf3 + c9d839b commit f652e64
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AegeanTools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions AegeanTools/wcs_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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]]

Expand All @@ -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

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file added tests/test_files/1904-66_SIN.lb.fits
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/test_wcs_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit f652e64

Please sign in to comment.