Skip to content

Add remap function using xESMF for regridding in goesgcp #1

@helvecioneto

Description

@helvecioneto

Description:
We need to implement a remap function in goesgcp to enable regridding capabilities using the xesmf library. This will allow users to interpolate data onto different grids efficiently, similar to CDO's remapbil function.

Implementation Steps

  1. Install Dependency: Ensure xesmf is added as an optional dependency in requirements.txt.
  2. Define the Function: Implement a remap function inside goesgcp/main.py that:
    • Accepts an input NetCDF file.
    • Defines or loads a target grid.
    • Uses xesmf for bilinear interpolation.
    • Saves the output to a new NetCDF file.
  3. Integrate with CLI: Add a new CLI command (--remap) to enable this feature.
  4. Test Cases: Create test cases to validate the interpolation results.
  5. Update Documentation: Add examples of how to use the new remap function in the README.

Example Code Outline

import xarray as xr
import xesmf as xe

def remap(input_file: str, output_file: str, target_grid: dict):
    ds = xr.open_dataset(input_file)
    ds_out = xr.Dataset(target_grid)
    regridder = xe.Regridder(ds, ds_out, "bilinear")
    ds_remap = regridder(ds)
    ds_remap.to_netcdf(output_file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions