This function changes the temporal frequency of climate data from daily to either monthly or yearly averages using CDO (Climate Data Operators). It supports both HPC array job processing and parallel processing for efficient computation.
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.- freq
Character string. The target temporal frequency. Valid options are:
"yearly"
or"annual"
: Calculate annual means using CDO yearmean"monthly"
: Calculate monthly means using CDO monmean
- 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.
Value
No return value. The function creates frequency-converted files in the specified output directory with "annual" or "monthly" replacing "merged" in the original filenames.
Details
The function uses CDO temporal aggregation operators to change frequency:
For yearly frequency: Uses
cdo -yearmean
to calculate annual meansFor monthly frequency: Uses
cdo -monmean
to calculate monthly means
The function can operate in different modes:
Array mode (
hpc = "array"
): Processes a single specified file (useful for HPC job arrays)Parallel mode (
hpc = "parallel"
orhpc = NA
): Processes all files in the input directory using parallel workers
Output files are renamed to reflect the new temporal frequency, replacing "merged" with either "annual" or "monthly" in the filename.
Note
Requires CDO (Climate Data Operators) to be installed and accessible from the system PATH
Input files should typically be daily frequency data for meaningful aggregation
For HPC environments, set
hpc = "array"
and specify thefile
parameterUses parallel processing when
hpc = NA
orhpc = "parallel"
Worker count is automatically determined based on available CPU cores