diff --git a/.travis/py2.docker b/.travis/py2.docker deleted file mode 100644 index f5fb0cb..0000000 --- a/.travis/py2.docker +++ /dev/null @@ -1,63 +0,0 @@ -FROM kernsuite/base:6 - -RUN docker-apt-install python-casacore casacore-data makems casarest \ - python-pip git wget meqtrees meqtrees-timba owlcat - -WORKDIR /src -RUN wget https://codeload.github.com/ska-sa/pyxis/tar.gz/refs/tags/v1.7.1 && \ - tar zxvf v1.7.1 && \ - rm v1.7.1 -RUN pip install -e ./pyxis-1.7.1 - -WORKDIR /code -ADD . /code/tigger-lsm -RUN pip install ./tigger-lsm - -# basic install tests -RUN flag-ms.py --help -RUN meqtree-pipeliner.py --help -RUN pyxis --help - -# run end to end test when built -RUN pip install nose -WORKDIR /src/pyxis-1.7.1/Pyxis/recipes/meqtrees-batch-test -RUN python -m "nose" - -####################################### -# run oleg's new tests -####################################### -ENV GITHUB_WORKSPACE=/code/tigger-lsm -# Test conversion to .txt models -RUN tigger-convert $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.lsm.html /tmp/output.txt -f \ - --output-format "name ra_d dec_d i q u v i q u v spi rm emaj_s emin_s pa_d freq0" -RUN tigger-convert $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.lsm.html /tmp/output.recentred.txt -f --center 85.5deg,49.9deg --rename \ - --output-format "name ra_d dec_d i q u v i q u v spi rm emaj_s emin_s pa_d freq0" -RUN echo "Checking reference LSM" -RUN diff $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.reference.txt /tmp/output.txt -RUN echo "Checking recentred reference LSM" -RUN diff $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.recentred.reference.txt /tmp/output.recentred.txt - -#Test reverse conversion to .lsm.html models -RUN tigger-convert /tmp/output.txt /tmp/output.lsm.html -f - -#Test .gaul conversions -RUN tigger-convert $GITHUB_WORKSPACE/test/deep4.gaul /tmp/deep4.lsm.html -f -RUN tigger-convert $GITHUB_WORKSPACE/test/deep4.gaul /tmp/deep4.txt -f --output-format "name ra_d dec_d i q u v spi rm emaj_s emin_s pa_d freq0" -RUN diff $GITHUB_WORKSPACE/test/deep4.reference.txt /tmp/deep4.txt - -# Test .AIPSCC conversions -RUN gunzip <$GITHUB_WORKSPACE/test/3C147-L-A-CLEAN.fits.gz >/tmp/3C147-L-A-CLEAN.fits -RUN tigger-convert /tmp/3C147-L-A-CLEAN.fits /tmp/3C147-L-A-CLEAN.fits.lsm.html -f -RUN tigger-convert /tmp/3C147-L-A-CLEAN.fits.lsm.html /tmp/3C147-L-A-CLEAN.txt -f --output-format "name ra_d dec_d i q u v" -RUN zdiff $GITHUB_WORKSPACE/test/3C147-L-A-CLEAN.txt.gz /tmp/3C147-L-A-CLEAN.txt - -# Testing tigger-restore and tigger-make-brick -RUN cp $GITHUB_WORKSPACE/test/3C147tmp.fits /tmp -RUN tigger-make-brick $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.lsm.html /tmp/3C147tmp.fits -RUN tigger-restore -f $GITHUB_WORKSPACE/test/3C147tmp.fits $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.lsm.html /tmp/restored.fits - -#Test tigger-tag -RUN tigger-tag $GITHUB_WORKSPACE/test/3C147-HI6.refmodel.lsm.html 'r<0.5d' inner=1 -o /tmp/tmp.lsm.html -f - -ENTRYPOINT ["meqtree-pipeliner.py"] -CMD ["--help"] diff --git a/Jenkinsfile.sh b/Jenkinsfile.sh index a1a35ba..06555f6 100644 --- a/Jenkinsfile.sh +++ b/Jenkinsfile.sh @@ -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 . diff --git a/Tigger/Coordinates.py b/Tigger/Coordinates.py index 6f35dc1..a75dcc4 100644 --- a/Tigger/Coordinates.py +++ b/Tigger/Coordinates.py @@ -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 @@ -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): diff --git a/setup.py b/setup.py index cbfe6df..d6764b9 100644 --- a/setup.py +++ b/setup.py @@ -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="osmirnov@gmail.com",