From 3ebc2b91011b850606fc742f6c94c4a4dd3376b7 Mon Sep 17 00:00:00 2001 From: Felix Kleinert <f.kleinert@fz-juelich.de> Date: Mon, 14 Feb 2022 14:56:20 +0100 Subject: [PATCH] cdo helper script --- mlair/helpers/mergetime_cdo_files.sh | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 mlair/helpers/mergetime_cdo_files.sh diff --git a/mlair/helpers/mergetime_cdo_files.sh b/mlair/helpers/mergetime_cdo_files.sh new file mode 100644 index 00000000..91459be1 --- /dev/null +++ b/mlair/helpers/mergetime_cdo_files.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# This scipt uses cdo mergetime to combine hourly files into two files per month +# example file: wrfout_d01_2009-02-03_07:00:00.nc + +for i in "$@"; do + case $i in + -s=*|--startyear=*) + startyear="${i#*=}" + shift # past argument=value + ;; + -e=*|--endyear=*) + endyear="${i#*=}" + shift # past argument=value + ;; + -f=*|--filestarter=*) + filestarter="${i#*=}" + shift # past argument=value + ;; + -p=*|--datapath=*) + datapath="${i#*=}" + shift # past argument=value + ;; + -n=*|--newpath=*) + newpath="${i#*=}" + shift # past argument=value + ;; + --default) + DEFAULT=YES + shift # past argument with no value + ;; + *) + # unknown option + ;; + esac +done + +# source mergetime_cdo_files.sh -s=2009 -e=2009 -f=wrfout_d01_ +# source mergetime_cdo_files.sh -s=2009 -e=2009 -f=wrfout_d01_ -p=hourly/ -n=monthly/ + +for year in $(seq "$startyear" "$endyear") +do + echo "$year" + for month in $(seq -w 1 12) + do + echo "##########################################" + echo "Processing: cdo mergetime ${datapath}${filestarter}${year}-${month}-[0-1][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_first_part.nc &" + # cdo mergetime ${datapath}${filestarter}${year}-${month}-[0-1][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_first_part.nc & + echo "Processing: cdo mergetime ${datapath}${filestarter}${year}-${month}-[2-3][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_second_part.nc &" +# cdo mergetime ${datapath}${filestarter}${year}-${month}-[2-3][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_second_part.nc & + done +done + +echo "############ YOUR OPTIONS ############" +echo "startyear: $startyear" +echo "endyear: $endyear" +echo "filestarter: $filestarter" +echo "datapath: $datapath" +echo "newpath: $newpath" \ No newline at end of file -- GitLab