reproject_image#

niriss_tools.isophotal.reproject_image(input_path, output_path, output_wcs, output_shape, input_hdu_index=0, method='adaptive', conserve_flux=True, compress=True, overwrite=False, prefix='repr_', preliminary_buffer=250, **reproject_kwargs)[source]#

Reproject an image to a new WCS.

A wrapper around reproject, for file handling and default parameters. If reproject_adaptive is used as the method, the flux is conserved by default (conserve_flux=True). For other methods, the input is assumed to be in surface brightness units.

Parameters:
input_pathPathLike

The path of the original image.

output_pathPathLike

The path of the output file. If a directory is passed, the output filename will be the same as the input, with the addition of prefix.

output_wcsWCS

The new WCS onto which the image will be reprojected.

output_shapetuple[int,int]

The shape of the reprojected image.

input_hdu_indexint, optional

The index of the HDU containing the input image, by default 0.

method{“interp”, “adaptive”, “exact”}

The reprojection method to use, by default "adaptive".

conserve_fluxbool, optional

If True (default), the input flux will be conserved. This will only work if method="adaptive".

compressbool, optional

If True (default), the output file will be compressed and saved with the extension “.fits.gz”.

overwritebool, optional

Overwrite the file if it exists already, by default False.

prefixstr, optional

The string to prepend to the output filename, by default "repr_". Only used if output_path is a directory.

preliminary_bufferint | None, optional

For very large images, perform a rough initial crop, padded by preliminary_buffer, before the full reprojection. By default, this is set to 250 pixels.

**reproject_kwargsdict, optional

Additional keyword arguments to pass to the reproject function.

Returns:
PathLike

The path of the reprojected image.

Raises:
ValueError

An error will be raised if the method argument is not valid.

Notes

To reproject a segmentation map, call this function with method=interp and order="nearest-neighbour".