credit.grid#

Generate SCRIP-format NetCDF files for use with ESMFRegridWeightGen.

Supports two grid types:

- Rectilinear  : 1D lon + 1D lat arrays (uniform, regional, or Gaussian spacing)
- Curvilinear  : 2D lon + 2D lat arrays (HRRR, GOES, ocean tripolar, etc.)

All functions produce SCRIP files containing both cell centers and cell corners, making them compatible with all ESMFRegridWeightGen methods (bilinear, patch, nearest-neighbor, 1st- and 2nd-order conservative).

Entry points:

scrip_from_netcdf(nc_file, scrip_file, grid_name=None, mask_var=None)
    Auto-detects grid type from file; preferred entry point.

scrip_from_rectilinear(lon_1d, lat_1d, grid_name, grid_file, mask=None)
scrip_from_curvilinear(lon_2d, lat_2d, grid_name, grid_file, mask=None)
    Direct API for when coordinates are already in hand.

Dependencies:

numpy, xarray

Attributes#

Functions#

scrip_from_rectilinear(lon_1d, lat_1d, grid_name, ...)

Generate a SCRIP file for a rectilinear (regular lat/lon) grid.

scrip_from_curvilinear(lon_2d, lat_2d, grid_name, ...)

Generate a SCRIP file for a curvilinear grid.

scrip_from_netcdf(nc_file, scrip_file[, grid_name, ...])

Auto-detect grid type from a NetCDF file and write a SCRIP file.

Module Contents#

credit.grid.scrip_from_rectilinear(lon_1d, lat_1d, grid_name, grid_file, mask=None)#

Generate a SCRIP file for a rectilinear (regular lat/lon) grid.

Parameters:
  • lon_1d (array-like, shape (nlon,))

  • lat_1d (array-like, shape (nlat,))

  • grid_name (str)

  • grid_file (str)

  • mask (array-like, shape (nlat, nlon), optional 1=valid, 0=masked.)

Return type:

xr.Dataset

credit.grid.scrip_from_curvilinear(lon_2d, lat_2d, grid_name, grid_file, mask=None)#

Generate a SCRIP file for a curvilinear grid.

Parameters:
  • lon_2d (array-like, shape (ny, nx))

  • lat_2d (array-like, shape (ny, nx))

  • grid_name (str)

  • grid_file (str)

  • mask (array-like, shape (ny, nx), optional 1=valid, 0=masked.)

Return type:

xr.Dataset

credit.grid.scrip_from_netcdf(nc_file, scrip_file, grid_name=None, mask_var=None)#

Auto-detect grid type from a NetCDF file and write a SCRIP file.

Coordinate names supported: lon/lat, longitude/latitude. 1D coordinates → rectilinear. 2D coordinates → curvilinear.

Parameters:
  • nc_file (str Path to input NetCDF file.)

  • scrip_file (str Path for output SCRIP file.)

  • grid_name (str, optional Defaults to the input filename stem.)

  • mask_var (str, optional Variable to use as mask (1=valid, 0=masked).)

Return type:

xr.Dataset

credit.grid.parser#