fits_cut
- astrocut.fits_cut(input_files: List[Union[str, Path, S3Path]], coordinates: Union[SkyCoord, str], cutout_size: Union[int, ndarray, Quantity, List[int], Tuple[int]] = 25, correct_wcs: bool = False, extension: Optional[Union[int, List[int], Literal['all']]] = None, single_outfile: bool = True, cutout_prefix: str = 'cutout', output_dir: Union[str, Path] = '.', memory_only: bool = False, fill_value: Union[int, float] = nan, limit_rounding_method: str = 'round', verbose=False) Union[str, List[str], List[HDUList]][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
HDUListobjects 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.
This function is maintained for backwards compatibility. For maximum flexibility, we recommend using
FITSCutoutdirectly.- Parameters
- input_fileslist
List of fits image files to cutout from. The image is assumed to be in the first extension.
- coordinatesstr or
SkyCoordobject The position around which to cutout. It may be specified as a string (“ra dec” in degrees) or as the appropriate
SkyCoordobject.- cutout_sizeint, array-like,
Quantity The size of the cutout array. If
cutout_sizeis a scalar number or a scalarQuantity, then a square cutout ofcutout_sizewill be created. Ifcutout_sizehas two elements, they should be in(ny, nx)order. Scalar numbers incutout_sizeare assumed to be in units of pixels.Quantityobjects must be in pixel or angular units.- 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
HDUListobjects. If set to True cutout_prefix and output_dir are ignored, however single_outfile can still be used to set the number of returnedHDUListobjects.- fill_valueint | float
Value to fill the cutout with if the cutout is outside the image.
- limit_rounding_methodstr
Method to use for rounding the cutout limits. Options are ‘round’, ‘ceil’, and ‘floor’.
- verbosebool
Default False. If true intermediate information is printed.
- 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
HDUListobjects is returned instead of file name(s).