fits_cut
- 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.
- Parameters
- input_fileslist
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 scalarQuantity
, then a square cutout ofcutout_size
will be created. Ifcutout_size
has two elements, they should be in(ny, nx)
order. Scalar numbers incutout_size
are assumed to be in units of pixels.Quantity
objects must be in pixel or angular units.- correct_wcsbool
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’.
- single_outfilebool
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.
- cutout_prefixstr
Default value “cutout”. Only used if single_outfile is True. A prefix to prepend to the cutout filename.
- output_dirstr
Default value ‘.’. The directory to save the cutout file(s) to.
- memory_onlybool
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 returnedHDUList
objects.- verbosebool
Default False. If true intermediate information is printed.
- fsspec_kwargsany
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”}).
- Returns
- 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).