Command Line Interface (CLI)¶
xregrid provides a powerful command-line interface for regridding NetCDF files without writing any Python code.
Basic Usage¶
The basic syntax for the CLI is:
Where:
- <src_file> is the path to your source NetCDF file.
- <target> can be either:
- A path to a target NetCDF file defining the grid.
- A numerical resolution in degrees (e.g., 1.0 for a 1-degree grid).
Examples¶
Regrid to a 1-degree global grid:
Regrid to a specific target file:
Regrid to a 0.5-degree regional grid:
Options¶
General Options¶
--method: Regridding method. Choices:bilinear,conservative,nearest_s2d,nearest_d2s,patch(default:bilinear).--output,-o: Path to the output NetCDF file (default:output.nc).--extent: Target grid extent asmin_lat,max_lat,min_lon,max_lon. Only used if<target>is a resolution.--periodic: Set for global grids with periodic boundaries.--skipna: Handle NaNs by re-normalizing weights.--reuse-weights: Reuse weights if the weights file already exists.--weights-file: Path to the weights file (default:weights.nc).
Dask Parallelization¶
The CLI can leverage Dask to parallelize weight generation and application, which is essential for very large datasets.
--dask-local <N>: Start a local Dask cluster withNworkers.--dask-scheduler <ADDRESS>: Connect to an existing Dask scheduler.--dask-jobqueue <MACHINE>: Usedask-jobqueueto submit jobs to an HPC cluster (e.g.,hera,jet).--dask-account <ACCOUNT>: Specify the SLURM account fordask-jobqueue.
Example with Local Dask Cluster¶
Tips¶
- When using
--extentwith negative values, use the equals sign to avoid parsing issues:--extent=-90,90,0,360. - For global regridding, always use
--periodicand ensure your target grid is global (default if only resolution is provided).