[AstroPy] Convolving FITS images

Adam Ginsburg adam.g.ginsburg at gmail.com
Mon Oct 20 06:35:51 EDT 2014


It seems that you have a data cube or some non-two-dimensional FITS
file.  If that's unexpected, try:

data = fits.getdata('filename.fits').squeeze()

which will remove any length-1 dimensions.  But you should examine
your data (look at data.shape) for the dimensionality issue.

As for the other issue, the most recent version of aplpy gives a more
helpful message and tells you that you should directly pass in a
kernel with the kernel= keyword (i.e., pass in the Gaussian2DKernel to
aplpy directly).  So, it was my mistake originally - the `smooth`
keyword in aplpy should be limited to integers.

On Mon, Oct 20, 2014 at 12:26 PM, Rene Plume <rplume at ucalgary.ca> wrote:
> Hi Adam et al.
>
> When I use the following command sequence to convolve my data:
>
>
> from astropy.io import fits
> data = fits.getdata('filename.fits')
> header = fits.getheader('filename.fits')
>
> from astropy.convolution import convolve,Gaussian2DKernel
> fwhm = 5
> smoothed = convolve(data, Gaussian2DKernel(stddev=fwhm/2.35))
>
>
> I get the following error messages:
> # Check that the number of dimensions is compatible
>     144     if array_internal.ndim != kernel_internal.ndim:
> --> 145         raise Exception('array and kernel have differing number of '
>     146                         'dimensions.')
>     147
>
> Exception: array and kernel have differing number of dimensions.
>
>
>
> When I use the next two commands, however, I get:
>
> # Alternatively, display and smooth simultaneously:
> fig = aplpy.FITSFigure('filename.fits')
> fig.show_grayscale(smooth=fwhm/2.35)
> # but this is less flexible
>
>
> TypeError: x_size should be an integer
>
> But when I put in an actual integer (say 3), these two steps work just fine.
>
> Any thoughts?
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>



-- 
Adam Ginsburg
Fellow, European Southern Observatory
http://www.adamgginsburg.com/



More information about the AstroPy mailing list