Skip to content

Commit

Permalink
Fixes issue #35 - FITS CUNIT 'M/S' header. (#36)
Browse files Browse the repository at this point in the history
* Fixes issue #35 - FITS CUNIT 'M/S' header.

* Requires Python >=3.6

* Deprecate Python 2.7 testing

* Deprecate python 2.7 build

Co-authored-by: Benjamin Hugo <[email protected]>
  • Loading branch information
razman786 and bennahugo authored May 25, 2022
1 parent 11a4cc2 commit 14d4406
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 68 deletions.
63 changes: 0 additions & 63 deletions .travis/py2.docker

This file was deleted.

1 change: 0 additions & 1 deletion Jenkinsfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ cd $PROJECTS_DIR/meqtrees-tigger-lsm
IMAGENAME="mttiglsmpr"

# build and test
docker build -f .travis/py2.docker -t "${IMAGENAME}27:$BUILD_NUMBER" --no-cache=true .
docker build -f .travis/py3.docker -t "${IMAGENAME}36:$BUILD_NUMBER" --no-cache=true .
24 changes: 21 additions & 3 deletions Tigger/Coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from __future__ import print_function, division, absolute_import

from astropy.wcs.wcs import InvalidTransformError
import Tigger
from Tigger import startup_dprint

Expand Down Expand Up @@ -348,12 +350,28 @@ def __init__(self, header):
# pix2world then fails expecting N x 4. Using astropy wcs methods and not sub-classing FITSWCSpix
# avoids the error and a reliance on naxis.

# get astropy WCS
self.wcs = WCS(header)

# get number of axis
naxis = header['NAXIS']

# get astropy WCS
try:
self.wcs = WCS(header)
except InvalidTransformError as e:
if 'CUNIT' in str(e):
# check header for incorrect CUNIT entry 'M/S'
for iaxis in range(naxis):
name = header.get("CUNIT%d" % (iaxis + 1), '').upper()
if name.startswith("M/S"):
# correct the header
header.set("CUNIT%d" % (iaxis + 1), 'm/s')
# re-load WCS
try:
self.wcs = WCS(header)
except InvalidTransformError as e:
raise RuntimeError(f"Error WCS header {e}")
else:
raise RuntimeError(f"Error WCS header {e}")

# get ra and dec axis
self.ra_axis = self.dec_axis = None
for iaxis in range(naxis):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
extras_require=extras_require,
scripts=scripts,
package_data=package_data,
python_requires='>=2.7.0',
python_requires='>=3.6',
description="Python libraries and command-line tools for manipulating Tigger-format LSMs",
author="Oleg Smirnov",
author_email="[email protected]",
Expand Down

0 comments on commit 14d4406

Please sign in to comment.