From 49aa8e512893447b7430a25427a7b051b0206786 Mon Sep 17 00:00:00 2001 From: Mathew Madhavacheril Date: Wed, 3 Jan 2018 17:45:18 -0500 Subject: [PATCH 1/3] to_flipper fix --- enmap.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/enmap.py b/enmap.py index cd81001..7e7c2d8 100644 --- a/enmap.py +++ b/enmap.py @@ -1116,13 +1116,21 @@ def to_flipper(imap, omap=None, unpack=True): on started with. """ import flipper + import pyfits if imap.wcs.wcs.cdelt[0] > 0: imap = imap[...,::-1] # flipper wants a different kind of wcs object than we have. header = imap.wcs.to_header(relax=True) header['NAXIS'] = 2 header['NAXIS1'] = imap.shape[-1] header['NAXIS2'] = imap.shape[-2] - flipwcs = flipper.liteMap.astLib.astWCS.WCS(header, mode="pyfits") + + cardList = pyfits.Header() + keys = ['NAXIS','NAXIS1','NAXIS2','CTYPE1','CTYPE2','CRVAL1','CRVAL2','CRPIX1','CRPIX2','CDELT1','CDELT2','CUNIT1','CUNIT2'] + for key in keys: + cardList.append(pyfits.Card(key, header[key])) + hh = pyfits.Header(cards=cardList) + + flipwcs = flipper.liteMap.astLib.astWCS.WCS(hh, mode="pyfits") iflat = imap.preflat if omap is None: omap = np.empty(iflat.shape[:-2],dtype=object) From 4d284da5239a1a67f65c03ede80a251864faf4c5 Mon Sep 17 00:00:00 2001 From: Mathew Madhavacheril Date: Sun, 25 Feb 2018 20:48:51 -0500 Subject: [PATCH 2/3] flipper import fixes --- enmap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/enmap.py b/enmap.py index 7e7c2d8..1861e4c 100644 --- a/enmap.py +++ b/enmap.py @@ -1115,7 +1115,8 @@ def to_flipper(imap, omap=None, unpack=True): by from_flipper does not give back an exactly identical map to the one on started with. """ - import flipper + import flipper.liteMap as lm + from astLib import astWCS import pyfits if imap.wcs.wcs.cdelt[0] > 0: imap = imap[...,::-1] # flipper wants a different kind of wcs object than we have. @@ -1130,12 +1131,12 @@ def to_flipper(imap, omap=None, unpack=True): cardList.append(pyfits.Card(key, header[key])) hh = pyfits.Header(cards=cardList) - flipwcs = flipper.liteMap.astLib.astWCS.WCS(hh, mode="pyfits") + flipwcs = astWCS.WCS(hh, mode="pyfits") iflat = imap.preflat if omap is None: omap = np.empty(iflat.shape[:-2],dtype=object) for i, m in enumerate(iflat): - omap[i] = flipper.liteMap.liteMapFromDataAndWCS(iflat[i], flipwcs) + omap[i] = lm.liteMapFromDataAndWCS(iflat[i], flipwcs) omap = omap.reshape(imap.shape[:-2]) if unpack and omap.ndim == 0: return omap.reshape(-1)[0] else: return omap From 2107e7408771a71763b1d12f2d65f3723cb1d42e Mon Sep 17 00:00:00 2001 From: Mathew Madhavacheril Date: Tue, 27 Feb 2018 09:58:28 -0500 Subject: [PATCH 3/3] tabs fix --- enmap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enmap.py b/enmap.py index 1861e4c..890b78f 100644 --- a/enmap.py +++ b/enmap.py @@ -1116,7 +1116,7 @@ def to_flipper(imap, omap=None, unpack=True): on started with. """ import flipper.liteMap as lm - from astLib import astWCS + from astLib import astWCS import pyfits if imap.wcs.wcs.cdelt[0] > 0: imap = imap[...,::-1] # flipper wants a different kind of wcs object than we have.