Skip to content

Add remap function using xESMF for regridding in goesgcp #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
helvecioneto opened this issue Feb 3, 2025 · 0 comments
Open

Add remap function using xESMF for regridding in goesgcp #1

helvecioneto opened this issue Feb 3, 2025 · 0 comments

Comments

@helvecioneto
Copy link
Owner

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant