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
No related branches found
No related tags found
No related merge requests found
#!/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`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment