Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions bdsf/shapelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,7 @@ def shapelet_image(basis, beta, centre, hc, nx, ny, size):
order nx,ny on an image of size size. Does what getcartim.f does in fBDSM. nx,ny -> 0-nmax
Centre is by Python convention, for retards who count from zero. """
from math import sqrt,pi
try:
from scipy import factorial
except ImportError:
try:
from scipy.misc.common import factorial
except ImportError:
try:
from scipy.misc import factorial
except ImportError:
from scipy.special import factorial
from scipy.special import factorial

hcx = hc[nx,:]
hcy = hc[ny,:]
Expand Down
20 changes: 10 additions & 10 deletions test/compare_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __init__(self, imagefile):
self.shift = 0.
self.noise = 1.

self.header = astropy.io.fits.open(imagefile)[0].header
self.header = astropy.io.fits.getheader(imagefile)
self.find_beam()
self.find_freq()
self.flatten()
Expand Down Expand Up @@ -269,16 +269,16 @@ def find_freq(self):

def flatten(self):
""" Flatten a fits file so that it becomes a 2D image. Return new header and data """
f = astropy.io.fits.open(self.imagefile)
fits_data = astropy.io.fits.getdata(self.imagefile)

naxis = f[0].header['NAXIS']
naxis = self.header['NAXIS']
if naxis < 2:
raise RuntimeError('Can\'t make map from this')
if naxis == 2:
self.img_hdr = f[0].header
self.img_data = f[0].data
self.img_hdr = self.header
self.img_data = fits_data
else:
w = astropy.wcs.WCS(f[0].header)
w = astropy.wcs.WCS(self.header)
wn = astropy.wcs.WCS(naxis=2)
wn.wcs.crpix[0] = w.wcs.crpix[0]
wn.wcs.crpix[1] = w.wcs.crpix[1]
Expand All @@ -289,16 +289,16 @@ def flatten(self):

header = wn.to_header()
header["NAXIS"] = 2
header["NAXIS1"] = f[0].header['NAXIS1']
header["NAXIS2"] = f[0].header['NAXIS2']
header["NAXIS1"] = self.header['NAXIS1']
header["NAXIS2"] = self.header['NAXIS2']
header["FREQ"] = self.freq
header['RESTFREQ'] = self.freq
header['BMAJ'] = self.beam[0]
header['BMIN'] = self.beam[1]
header['BPA'] = self.beam[2]
copy = ('EQUINOX', 'EPOCH')
for k in copy:
r = f[0].header.get(k)
r = self.header.get(k)
if r:
header[k] = r

Expand All @@ -309,7 +309,7 @@ def flatten(self):
else:
dataslice.append(0)
self.img_hdr = header
self.img_data = f[0].data[tuple(dataslice)]
self.img_data = fits_data[tuple(dataslice)]
self.min_value = float(np.nanmin(self.img_data))
self.max_value = float(np.nanmax(self.img_data))
self.mean_value = float(np.nanmean(self.img_data))
Expand Down