From dfef77e660fddab06dd80ef477bc7103547cabf1 Mon Sep 17 00:00:00 2001 From: dwhan89 Date: Tue, 13 Mar 2018 07:07:44 -0700 Subject: [PATCH 1/2] extent functionality --- flipper/liteMap.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flipper/liteMap.py b/flipper/liteMap.py index 48272ac..779cbb4 100644 --- a/flipper/liteMap.py +++ b/flipper/liteMap.py @@ -541,7 +541,14 @@ def get_area(self, unit='deg'): assert(unit in ['deg', 'rad']) return self.area if unit is 'deg' else self.area * (np.pi/180.)**2 + def getExtent(self, unit='deg'): + # return x-axis, y-axis extension (i.e. width and height of the map) + assert(unit in ['deg', 'rad']) + + extent = [self.Nx*self.pixScaleX, self.Ny*self.pixScaleY] + if unit is 'deg': extent = [ x * (180./np.pi) for x in extent] + return extent def liteMapsFromEnlibFits(fname): hdu = pyfits.open(fname)[0] From 97946b00ab92a295ff89d221ce51cd7944fdde16 Mon Sep 17 00:00:00 2001 From: dwhan89 Date: Thu, 31 May 2018 12:35:04 -0700 Subject: [PATCH 2/2] switching to interp1d for interpolation stability --- flipper/liteMap.py | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/flipper/liteMap.py b/flipper/liteMap.py index 779cbb4..e1c40eb 100644 --- a/flipper/liteMap.py +++ b/flipper/liteMap.py @@ -12,8 +12,6 @@ import astropy.wcs import astropy.io.fits as pyfits -#import astropy.wcs as pywcs -#import pyfits import flipper.fft as fftfast import astLib @@ -26,7 +24,7 @@ import healpy import utils import time -from scipy.interpolate import splrep,splev +from scipy.interpolate import interp1d class gradMap: """ @brief Class describing gradient of a liteMap @@ -111,19 +109,10 @@ def fillWithGaussianRandomField(self,ell,Cell,bufferFactor = 1): iy, ix = np.mgrid[0:Ny,0:Nx] modLMap[iy,ix] = np.sqrt(ly[iy]**2+lx[ix]**2) - s = splrep(ell,Cell,k=3) - ll = np.ravel(modLMap) - kk = splev(ll,s) + kk = interp1d(ell, Cell, bounds_error=False, fill_value=0.)(ll) id = np.where(ll>ell.max()) - kk[id] = 0. - #add a cosine ^2 falloff at the very end - #id2 = np.where( (ll> (ell.max()-500)) & (ll 1: ell = np.ravel(twodPower.modLMap) Cell = np.ravel(twodPower.powerMap) - print ell - print Cell - s = splrep(ell,Cell,k=3) - - ll = np.ravel(modLMap) - kk = splev(ll,s) - - + kk = interp1d(ell, Cell, bounds_error=False, fill_value=0.)(ll) id = np.where(ll>ell.max()) - kk[id] = 0. - # add a cosine ^2 falloff at the very end - # id2 = np.where( (ll> (ell.max()-500)) & (ll