Skip to content

Commit

Permalink
Add some more docs for reproject_interp
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Nov 6, 2021
1 parent 43b0d8a commit f1e874f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions reproject/interpolation/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _reproject_full(array, wcs_in, wcs_out, shape_out, order=1, array_out=None,
pixel_out = np.meshgrid(*[np.arange(size, dtype=float) for size in shape_out],
indexing='ij', sparse=False, copy=False)
pixel_out = [p.ravel() for p in pixel_out]
# For each pixel in the ouput array, get the pixel value in the input WCS
pixel_in = efficient_pixel_to_pixel_with_roundtrip(wcs_out, wcs_in, *pixel_out[::-1])[::-1]
pixel_in = np.array(pixel_in)

Expand All @@ -87,6 +88,7 @@ def _reproject_full(array, wcs_in, wcs_out, shape_out, order=1, array_out=None,
else:
array_out = np.empty(shape_out).ravel()

# Interpolate array on to the pixels coordinates in pixel_in
map_coordinates(array, pixel_in, order=order, cval=np.nan,
mode='constant', output=array_out,).reshape(shape_out)

Expand Down
4 changes: 4 additions & 0 deletions reproject/interpolation/high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def reproject_interp(input_data, output_projection, shape_out=None, hdu_in=0,
Reproject data to a new projection using interpolation (this is typically
the fastest way to reproject an image).
The output pixel grid is transformed to the input pixel grid, and the
data values in ``input_data`` interpolated on to these coordinates to get
the reprojected data on the output grid.
Parameters
----------
input_data
Expand Down
18 changes: 16 additions & 2 deletions reproject/wcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,22 @@ def split_matrix(matrix):

def efficient_pixel_to_pixel(wcs1, wcs2, *inputs):
"""
Wrapper that performs a pixel -> world -> pixel transformation with two
WCS instances, and un-broadcasting arrays whenever possible for efficiency.
Wrapper that performs a pixel -> world -> pixel transformation and
un-broadcasting arrays whenever possible for efficiency.
Parameters
----------
wcs1 : `~astropy.wcs.WCS`
First WCS instance.
wcs2 : `~astropy.wcs.WCS`
Second WCS instance.
inputs : list[numpy.ndarray]
Pixels in the frame of ``wcs1``.
Returns
-------
outputs : list[numpy.ndarray]
Transformed pixels in the frame of ``wcs2``.
"""

# Shortcut for scalars
Expand Down

0 comments on commit f1e874f

Please sign in to comment.