astrocut.fits_cut(input_files, coordinates, cutout_size, correct_wcs=False, extension=None, single_outfile=True, cutout_prefix='cutout', output_dir='.', memory_only=False, verbose=False)[source]

Takes one or more fits files with the same WCS/pointing, makes the same cutout in each file, and returns the result either in a single FITS file with one cutout per extension or in individual fits files. The memory_only flag allows the cutouts to be returned as HDUList objects rather than saving to disk.

Note: No checking is done on either the WCS pointing or pixel scale. If images don’t line up the cutouts will also not line up.


List of fits image files to cutout from. The image is assumed to be in the first extension.

coordinatesstr or SkyCoord object

The position around which to cutout. It may be specified as a string (“ra dec” in degrees) or as the appropriate SkyCoord object.

cutout_sizeint, array-like, Quantity

The size of the cutout array. If cutout_size is a scalar number or a scalar Quantity, then a square cutout of cutout_size will be created. If cutout_size has two elements, they should be in (ny, nx) order. Scalar numbers in cutout_size are assumed to be in units of pixels. Quantity objects must be in pixel or angular units.


Default False. If true a new WCS will be created for the cutout that is tangent projected and does not include distortions.

extensionint, list of ints, None, or ‘all’

Optional, default None. Default is to cutout the first extension that has image data. The user can also supply one or more extensions to cutout from (integers), or ‘all’.


Default True. If true return all cutouts in a single fits file with one cutout per extension, if False return cutouts in individual fits files. If returing a single file the filename will have the form: <cutout_prefix>_<ra>_<dec>_<size x>_<size y>.fits. If returning multiple files each will be named: <original filemame base>_<ra>_<dec>_<size x>_<size y>.fits.


Default value “cutout”. Only used if single_outfile is True. A prefix to prepend to the cutout filename.


Default value ‘.’. The directory to save the cutout file(s) to.


Default value False. If set to true, instead of the cutout file(s) being written to disk the cutout(s) are returned as a list of HDUList objects. If set to True cutout_prefix and output_dir are ignored, however single_outfile can still be used to set the number of returned HDUList objects.


Default False. If true intermediate information is printed.


Default value {“anon”: True}. This parameter should be used to provide cloud credentials to access private data buckets (e.g. {“key”: “YOUR-SECRET-KEY-ID”, “secret”: “YOUR-SECRET-KEY”}).

responsestr or list

If single_outfile is True returns the single output filepath. Otherwise returns a list of all the output filepaths. If memory_only is True a list of HDUList objects is returned instead of file name(s).