From 33352f6a0d8784422d883d9cc9ebb901272ed0b2 Mon Sep 17 00:00:00 2001 From: Michael <m.langguth@fz-juelich.de> Date: Mon, 18 Jul 2022 14:00:50 +0200 Subject: [PATCH] Revise get_era5_forecasts.sh for GMD-publication. --- Jupyter_Notebooks/get_era5_forecasts.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Jupyter_Notebooks/get_era5_forecasts.sh b/Jupyter_Notebooks/get_era5_forecasts.sh index f01bc770..5c7b00c0 100644 --- a/Jupyter_Notebooks/get_era5_forecasts.sh +++ b/Jupyter_Notebooks/get_era5_forecasts.sh @@ -1,19 +1,24 @@ #!/usr/bin/env bash +# This bash-script reads the 2m temperature from ERA5 short-range forecasts files, crops the data to the largest target domain (see Dataset ID 1-3) and then performs a merging step with the ground truth and the persistence forecast data provided by from the postprocessing of a trained model (see prostprocess-step of workflow.) + +# Parse script argument yr=$1 -indir=/p/fastdata/slmet/slmet111/met_data/ecmwf/era5/grib/${yr} -indir_ref=/p/project/deepacf/deeprain/video_prediction_shared_folder/results/era5-Y2007-2019M01to12-92x56-3840N0000E-2t_tcc_t_850/savp/20210901T090059_gong1_savp_cv12/ -outdir=/p/scratch/deepacf/deeprain/video_prediction_shared_folder/era5_forecast_ref/${yr} +# some directory parameters +indir=<path_to_era5_short_range_forecasts>/${yr} # directory where the ERA5-short range forecasts are located +indir_ref=<path_to_postprocessed_model> # directory where the results of a trained model are located (to get persistence forecast and ground truth data) +outdir=<path_to_output> # output directory if [[ ! -d "${outdir}" ]]; then mkdir ${outdir} fi -hh_s=6 -hh_e=12 +# additional parameters +hh_s=6 # start of lead time range in hours +hh_e=12 # end of lead time range in hours -declare -a hh_list=(18) +declare -a hh_list=(18) # initialization hour of ERA5 forecasts to evaluate (either 6 or 18) for hh in ${hh_list[@]}; do hh0=$(printf "%02d" ${hh}) @@ -29,12 +34,13 @@ for hh in ${hh_list[@]}; do done done + # merge all ERA5 forecasts in monthly netCDF-files date1=`date -d "${yr}0101" '+%Y%m%d'` date2=`date -d "${yr}0101 ${hh0}" '+%Y-%m-%d %H:%M:00'` date_end=`date -d "{yr}1231 ${hh0}" '+%Y%m%d'` while [[ "$date1" -le "$date_end" ]]; do - outfile=${outdir}/${date1}${hh0}_allfc.nc + outfile=${outdir}/${date1}${hh0}_allfc.nc echo "Merging forecats for run at ${date2}..." cdo mergetime ${outdir}/${date1}_${hh}00_*.nc ${outfile} echo "Manipulate attributes and dimensions..." @@ -44,7 +50,7 @@ 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 reference data as possible + # 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` -- GitLab