astrocut.img_cut(input_files, coordinates, cutout_size, stretch='asinh', minmax_percent=None, minmax_value=None, invert=False, img_format='jpg', colorize=False, cutout_prefix='cutout', output_dir='.', drop_after=None, 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 as a single color image or in individual image files.

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.


Optional, default ‘asinh’. The stretch to apply to the image array. Valid values are: asinh, sinh, sqrt, log, linear


Optional, default [0.5,99.5]. Interval based on a keeping a specified fraction of pixels (can be asymmetric) when scaling the image. The format is [lower percentile, upper percentile], where pixel values below the lower percentile and above the upper percentile are clipped. Only one of minmax_percent and minmax_value should be specified.


Optional. Interval based on user-specified pixel values when scaling the image. The format is [min value, max value], where pixel values below the min value and above the max value are clipped. Only one of minmax_percent and minmax_value should be specified.


Optional, default False. If True the image is inverted (light pixels become dark and vice versa).


Optional, default ‘jpg’. The output image file type. Valid values are “jpg” and “png”.


Optional, default False. If True a single color image is produced as output, and it is expected that three files are given as input.


Default value “cutout”. Only used when producing a color image. A prefix to prepend to the cutout filename.


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


Default False. If true intermediate information is printed.

responsestr or list

If colorize is True returns the single output filepath. Otherwise returns a list of all the output filepaths.