
Regrid Earth System Model outputs to a common spatial grid
Source:R/htr_regrid_esm.R
htr_regrid_esm.Rd
This function regrids climate model outputs from their native grids to a common regular latitude-longitude grid using CDO (Climate Data Operators). This is essential for comparing and combining data from different climate models that use different spatial grids.
Arguments
- hpc
Character string or NA. Indicates High Performance Computing mode:
NA
: Standard processing mode"array"
: HPC array job mode (requiresfile
parameter)"parallel"
: HPC parallel mode
- file
Character string or NA. Specific file to process when
hpc = "array"
. Not used in other modes.- indir
Character string. Directory containing merged NetCDF files to be time-sliced. Files should be continuous time series created by
htr_merge_files()
.- outdir
Character string. Directory where time-sliced files will be saved.
- cell_res
Numeric. Spatial resolution in degrees for the target grid (e.g., 0.25 for quarter-degree resolution, 1.0 for one-degree resolution). Default is 0.25 degrees.
- layer
Character string. Description of the data layer being regridded (e.g., "annual", "monthly", "anomalies"). This is used for filename generation and progress reporting.
Value
No return value. The function creates regridded files in the specified output directory with "Regridded" added to the layer name in the filename (e.g., "annual" becomes "RegriddedAnnual").
Details
Different climate models use various spatial grids (regular lat-lon, curvilinear, unstructured, etc.), making direct comparison difficult. This function standardizes all data to a regular latitude-longitude grid using CDO interpolation methods.
The function uses different CDO remapping operators based on the variable type:
Precipitation (
pr
): Uses conservative remapping (remapcon
) to preserve total precipitation amountsOther variables: Uses bilinear interpolation (
remapbil
) for smooth interpolation
The process:
Creates a blank raster template at the specified resolution
For each input file, determines the appropriate remapping method
Applies CDO remapping:
cdo -s -L -remapXXX,template input output
Updates filenames to include "Regridded" prefix
Cleans up the temporary template file
The -s
flag suppresses CDO messages, and -L
enables netCDF4 compression.
Note
Requires CDO (Climate Data Operators) to be installed and accessible from the system PATH
Creates a temporary grid template file that is automatically cleaned up
Uses conservative remapping for precipitation to preserve mass conservation
Uses bilinear interpolation for other variables (consider
remapdis
for some applications)Progress messages show the model and scenario being processed
Uses parallel processing when
hpc
is not set to "array"
References
CDO User Guide: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf CDO remapbil operator: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#page=115 CDO remapcon operator: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#page=116 Grid remapping methods: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#section.1.3.2