From d472006a4bbb0fc293140f3423d0e6b692ffefb2 Mon Sep 17 00:00:00 2001
From: Michael <m.langguth@fz-juelich.de>
Date: Mon, 18 Jul 2022 16:50:56 +0200
Subject: [PATCH] Add final merging step to get_era5_forecasts.sh.

---
 Jupyter_Notebooks/get_era5_forecasts.sh | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/Jupyter_Notebooks/get_era5_forecasts.sh b/Jupyter_Notebooks/get_era5_forecasts.sh
index 5c7b00c0..57ec979d 100755
--- a/Jupyter_Notebooks/get_era5_forecasts.sh
+++ b/Jupyter_Notebooks/get_era5_forecasts.sh
@@ -50,18 +50,21 @@ for hh in ${hh_list[@]}; do
         ncrename -O -d time,fcst_hour -v time,fcst_hour ${outfile} ${outfile}
         ncap2 -O -s 'fcst_hour=int(fcst_hour)' ${outfile} ${outfile}
 	
-	# add ground truth data and persistence forecast from trained model
-	patt=${indir_ref}/vfp_date_${date1}${hh0}_sample_ind*.nc
-	if ls $patt 1>/dev/null 2<&1; then
-	   file_src=`ls $patt`
-	   ncks -d fcst_hour,5,11 -v 2t_ref,2t_persistence_fcst -A ${file_src} ${outfile}
-	else 
-	   echo "Could not find reference data for ${date2}..."
-	   mv ${outfile} "${oufile/.nc/_ref_miss.nc}"
-	fi
+        # add ground truth data and persistence forecast from trained model
+        patt=${indir_ref}/vfp_date_${date1}${hh0}_sample_ind*.nc
+        if ls $patt 1>/dev/null 2<&1; then
+           file_src=`ls $patt`
+           ncks -d fcst_hour,5,11 -v 2t_ref,2t_persistence_fcst -A ${file_src} ${outfile}
+        else
+           echo "Could not find reference data for ${date2}..."
+           mv ${outfile} "${oufile/.nc/_ref_miss.nc}"
+        fi
 
         date1="$(date -u --date="$date1 tomorrow" '+%Y%m%d')"
         date2="$(date -u --date="$date2 tomorrow" '+%Y-%m-%d %H:%M:00')"
    done
 done
+
+# finally merge all data into a single file
+cdo -v mergetime ${outdir}/*_allfc.nc ${outdir}/${yr}_era5_short_range_fcst
     
-- 
GitLab