Skip to content
Snippets Groups Projects
Commit 33352f6a authored by Michael Langguth's avatar Michael Langguth
Browse files

Revise get_era5_forecasts.sh for GMD-publication.

parent 764b7c70
Branches
No related tags found
No related merge requests found
#!/usr/bin/env bash #!/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 yr=$1
indir=/p/fastdata/slmet/slmet111/met_data/ecmwf/era5/grib/${yr} # some directory parameters
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/ indir=<path_to_era5_short_range_forecasts>/${yr} # directory where the ERA5-short range forecasts are located
outdir=/p/scratch/deepacf/deeprain/video_prediction_shared_folder/era5_forecast_ref/${yr} 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 if [[ ! -d "${outdir}" ]]; then
mkdir ${outdir} mkdir ${outdir}
fi fi
hh_s=6 # additional parameters
hh_e=12 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 for hh in ${hh_list[@]}; do
hh0=$(printf "%02d" ${hh}) hh0=$(printf "%02d" ${hh})
...@@ -29,6 +34,7 @@ for hh in ${hh_list[@]}; do ...@@ -29,6 +34,7 @@ for hh in ${hh_list[@]}; do
done done
done done
# merge all ERA5 forecasts in monthly netCDF-files
date1=`date -d "${yr}0101" '+%Y%m%d'` date1=`date -d "${yr}0101" '+%Y%m%d'`
date2=`date -d "${yr}0101 ${hh0}" '+%Y-%m-%d %H:%M:00'` date2=`date -d "${yr}0101 ${hh0}" '+%Y-%m-%d %H:%M:00'`
date_end=`date -d "{yr}1231 ${hh0}" '+%Y%m%d'` date_end=`date -d "{yr}1231 ${hh0}" '+%Y%m%d'`
...@@ -44,7 +50,7 @@ for hh in ${hh_list[@]}; do ...@@ -44,7 +50,7 @@ for hh in ${hh_list[@]}; do
ncrename -O -d time,fcst_hour -v time,fcst_hour ${outfile} ${outfile} ncrename -O -d time,fcst_hour -v time,fcst_hour ${outfile} ${outfile}
ncap2 -O -s 'fcst_hour=int(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 patt=${indir_ref}/vfp_date_${date1}${hh0}_sample_ind*.nc
if ls $patt 1>/dev/null 2<&1; then if ls $patt 1>/dev/null 2<&1; then
file_src=`ls $patt` file_src=`ls $patt`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment