img_cut
- astrocut.img_cut(input_files: List[str | Path | S3Path], coordinates: SkyCoord | str, cutout_size: int | ndarray | Quantity | List[int] | Tuple[int] = 25, stretch: str = 'asinh', minmax_percent: List[int] | None = None, minmax_value: List[int] | None = None, invert: bool = False, img_format: str = '.jpg', colorize: bool = False, cutout_prefix: str = 'cutout', output_dir: str | Path = '.', extension: int | List[int] | Literal['all'] | None = None, fill_value: int | float = nan, limit_rounding_method: str = 'round', verbose=False, *, fsspec_kwargs: dict | None = None) str | List[str][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.
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.- stretchstr
Optional, default ‘asinh’. The stretch to apply to the image array. Valid values are: asinh, sinh, sqrt, log, linear
- minmax_percentarray
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.
- minmax_valuearray
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.
- invertbool
Optional, default False. If True the image is inverted (light pixels become dark and vice versa).
- img_formatstr
Optional, default ‘jpg’. The output image file type. Valid values are “jpg” and “png”.
- colorizebool
Optional, default False. If True a single color image is produced as output, and it is expected that three files are given as input.
- cutout_prefixstr
Default value “cutout”. Only used when producing a color image. A prefix to prepend to the cutout filename.
- output_dirstr
Defaul value ‘.’. The directory to save the cutout file(s) to.
- 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’.
- 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”.
- verbosebool
Default False. If true intermediate information is printed.
- fsspec_kwargsdict
Optional, default None. Keyword arguments to pass through to
s3fsfor cloud-hosted files.
- Returns:
- responsestr or list
If colorize is True, returns the single output filepath. Otherwise, returns a list of all the output filepaths.