earth2studio.utils.interp
.LatLonInterpolation#
- class earth2studio.utils.interp.LatLonInterpolation(lat_in, lon_in, lat_out, lon_out)[source]#
Bilinear interpolation between arbitrary grids.
The mapped values can be on arbitrary grid, but the output grid should be contained within the input grid.
Initializing the interpolation object can be somewhat slow, but interpolation is fast and can run on the GPU once initialized. Therefore, prefer to reuse the interpolation object when possible.
To run the interpolation on the GPU, use the .to() method of the interpolator to move it to the GPU before running the interpolation.
- Parameters:
lat_in (torch.Tensor | ArrayLike) – Tensor [H_in, W_in] of input latitude coordinates
lon_in (torch.Tensor | ArrayLike) – Tensor [H_in, W_in] of input longitude coordinates
lat_out (torch.Tensor | ArrayLike) – Tensor [H_out, W_out] of output latitude coordinates
lon_out (torch.Tensor | ArrayLike) – Tensor [H_out, W_out] of output longitude coordinates
- forward(values)[source]#
Perform bilinear interpolation for values.
- Parameters:
values (torch.Tensor) – Input values of shape […, H_in, W_in] defined over (lat_in, lon_in) that will be interpolated onto (lat_out, lon_out) grid.
- Returns:
result – Tensor of shape […, H_out, W_out] of interpolated values on lat1, lon1 grid.
- Return type:
torch.Tensor