[AstroPy] Cutout2D with weird formatting

Dominik Rhiem hg.dude.hg at gmail.com
Thu Mar 25 11:44:48 EDT 2021


Dear all,

I am using FITS maps produced by a program called PyBDSF used for source
detection and removal, and I want to make cutouts from these maps. However,
the formatting of these maps is a bit weird and I am having trouble with
making Cutout2D work with it. I have attached the fits file. Some sample
code:
hdul = fits.open('test.fits')
the_map = hdul[0].data
the_header = hdul[0].header
position = (the_header['CRPIX1'], the_header['CRPIX2']) #I want the cutout
to be centred on the map
size = 400 * u.arcsec #the cutout should have a total extent of 400 arcsec
in x and y direction
wcs = WCS(header=the_header)
cutout = Cutout2D(the_map, position, size, wcs)

Which results in:
ValueError: "large_array_shape" and "small_array_shape" must have the same
number of dimensions.
Importantly, the array has a shape of (1, 1, 600, 600), i.e. the actual 2D
data array is found via:
the_map = the_map[0][0]
which is reflected in the wcs. If I try to use that definition of the array
for the cutout, I get this error:
ValueError: operands could not be broadcast together with shapes (4,) (2,)
(4,)

How can I solve either of these issues?

Sincerely,
Dominik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20210325/adc14ec4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.fits
Type: application/octet-stream
Size: 1442880 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/astropy/attachments/20210325/adc14ec4/attachment-0001.obj>


More information about the AstroPy mailing list