dctools.processing.interpolation.interpolate_scipy

dctools.processing.interpolation.interpolate_scipy(ds, target_grid, var_names=None, depth_name='depth', lat_name='latitude', lon_name='longitude', tol_depth=0.001, output_mode='lazy', output_path=None, zarr_target_chunks=None, pairwise=False)

Interpolate an xarray Dataset onto a target grid using SciPy interpolation.

Parameters:
  • ds (xr.Dataset) – Input xarray Dataset (must contain latitude and longitude dimensions).

  • target_grid (dict of {str: Sequence}) – Dictionary defining the target grid coordinates. Must include keys for latitude and longitude.

  • var_names (sequence of str, optional) – List of variable names to interpolate. If None, all variables with latitude and longitude dimensions are used.

  • depth_name (str, default="depth") – Name of the depth dimension in the Dataset.

  • lat_name (str, default="latitude") – Name of the latitude dimension in the Dataset.

  • lon_name (str, default="longitude") – Name of the longitude dimension in the Dataset.

  • tol_depth (float, default=1e-3) – Tolerance for depth selection during interpolation.

  • output_mode ({'zarr', 'lazy', 'inmemory'}, default='zarr') – Output mode: - ‘zarr’: write to a Zarr file, - ‘lazy’: return a lazily evaluated Dataset, - ‘inmemory’: return an in-memory Dataset.

  • output_path (str, optional) – Path to the output file if output_mode is ‘zarr’. If None, a temporary file is created.

  • zarr_target_chunks (dict, optional) – Chunking configuration for writing to Zarr.

  • pairwise (bool, default=False) – If True, performs pairwise interpolation (Grid-to-Track) instead of Cartesian (Grid-to-Grid). Requires target_grid[‘lat’] and target_grid[‘lon’] to have the same length.

Returns:

Interpolated xarray Dataset on the target grid.

Return type:

xr.Dataset