
Calculate anomalies relative to the baseline mean
Source:R/htr_calc_anomalies.R
htr_calc_anomalies.Rd
This function calculates climate anomalies by subtracting baseline mean values from projection data using CDO (Climate Data Operators). It processes multiple climate model files in parallel, matching variables, frequencies, and models between the projection data and baseline means.
Arguments
- indir
Character string. Directory containing merged NetCDF files to be time-sliced. Files should be continuous time series created by
htr_merge_files()
.- mndir
Character string. The directory where the baseline mean files are stored. Files should follow CMIP6 naming conventions with variable, frequency, and model information in the filename.
- outdir
Character string. Directory where time-sliced files will be saved.
Value
No return value. The function creates anomaly files in the specified output directory with "anomalies" replacing "merged" in the original filenames.
Details
The function uses the CDO sub
operator to subtract baseline means from
projection files. It automatically matches files based on variable, frequency,
and model metadata extracted from CMIP6-formatted filenames. The process runs
in parallel using multiple CPU cores for efficient processing of large datasets.
The workflow involves:
Extracting metadata from baseline mean files
Finding corresponding projection files for each variable-frequency-model combination
Subtracting the appropriate baseline mean from each projection file using CDO
Saving results with "anomalies" in the filename
Note
Requires CDO (Climate Data Operators) to be installed and accessible from the system PATH
Input files must follow CMIP6 naming conventions for proper metadata extraction
Baseline mean files and projection files must have matching variable, frequency, and model names
Uses parallel processing with (number of CPU cores - 2) workers