reproject_interp#

reproject.reproject_interp(input_data, output_projection, shape_out=None, hdu_in=0, order='bilinear', roundtrip_coords=True, output_array=None, output_footprint=None, return_footprint=True, block_size=None, non_reprojected_dims=None, parallel=False, return_type=None, dask_method=None, zarr_path=None)[source]#

Reproject data to a new projection using interpolation (this is typically the fastest way to reproject an image).

Parameters:
input_dataobject

The input data to reproject. This can be:

If the data array contains more dimensions than are described by the input header or WCS, the extra dimensions (assumed to be the first dimensions) are taken to represent multiple images with the same coordinate information. The coordinate transformation will be computed once and then each image will be reprojected, offering a speedup over reprojecting each image individually.

output_projectionBaseLowLevelWCS or BaseHighLevelWCS or Header

The output projection, which can be either a BaseLowLevelWCS, BaseHighLevelWCS, or a Header instance.

shape_outtuple, optional

If output_projection is a WCS instance, the shape of the output data should be specified separately.

hdu_inint or str, optional

If input_data is a FITS file or an HDUList instance, specifies the HDU to use.

orderint or str, optional

The order of the interpolation. This can be any of the following strings:

  • ‘nearest-neighbor’

  • ‘bilinear’

  • ‘biquadratic’

  • ‘bicubic’

or an integer. A value of 0 indicates nearest neighbor interpolation.

roundtrip_coordsbool

Whether to verify that coordinate transformations are defined in both directions.

output_arrayNone or ndarray

An array in which to store the reprojected data. This can be any numpy array including a memory map, which may be helpful when dealing with extremely large files.

output_footprintndarray, optional

An array in which to store the footprint of reprojected data. This can be any numpy array including a memory map, which may be helpful when dealing with extremely large files.

return_footprintbool

Whether to return the footprint in addition to the output array.

block_sizetuple or ‘auto’, optional

The size of blocks in terms of output array pixels that each block will handle reprojecting. Extending out from (0,0) coords positively, block sizes are clamped to output space edges when a block would extend past edge. Specifying 'auto' means that reprojection will be done in blocks with the block size automatically determined. If block_size is not specified or set to None, the reprojection will not be carried out in blocks.

non_reprojected_dimstuple, optional

Leading dimensions of the data that should not be reprojected but for which a one-to-one mapping between input and output pixels is assumed. This makes it possible to broadcast a reprojection over these dimensions even when the input and output WCS have the same number of dimensions as the data. The dimensions must be the leading ones, given as a tuple of sequential integers starting from zero (e.g. (0,) or (0, 1)). This currently requires passing a block_size whose entries along the reprojected dimensions match shape_out (optionally combined with parallel to compute the blocks concurrently).

parallelbool or int or str, optional

If True, the reprojection is carried out in parallel, and if a positive integer, this specifies the number of threads to use. The reprojection will be parallelized over output array blocks specified by block_size (if the block size is not set, it will be determined automatically). To use the currently active dask scheduler (e.g. dask.distributed), set this to 'current-scheduler'.

return_type{‘numpy’, ‘dask’, ‘zarr’}, optional

Whether to return numpy or dask arrays, or to write the output to a zarr array on disk. If 'zarr', zarr_path must also be given; the output is then computed in blocks (using dask, on the synchronous scheduler when parallel is False), block_size defaults to 'auto' when not specified, and dask arrays backed by the zarr array are returned.

dask_method{‘memmap’, ‘none’}, optional
Method to use when input array is a dask array. The methods are:
  • 'memmap': write out the entire input dask array to a temporary memory-mapped array. This requires enough disk space to store the entire input array.

  • 'none' (default): use native dask interpolation, which avoids having to write the array to disk.

zarr_pathstr, optional

Path to use for the output zarr array when return_type='zarr'. This must be a path that does not already exist.

Returns:
array_newndarray

The reprojected array.

footprintndarray

Footprint of the input array in the output array. Values of 0 indicate no coverage or valid values in the input image, while values of 1 indicate valid values.