Commit 517d5e1a authored by Modellers Operational's avatar Modellers Operational

Update GFS download to new version of GFS model

parent 342a4c83
......@@ -7,6 +7,7 @@ set -eu
forecast_hours=$1
euryale_archivedir=$2
ceto_archive_dir=$3
base=$4
echo " ======== start ========"
echo "Getting forecast GFS data"
......@@ -15,14 +16,14 @@ cd ${euryale_archivedir}
curl_opts="--location --silent --continue-at -"
# Get a list of folders, then files within the most recent folder ($last_url):
base=ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/
last_day=${last_day:-$(curl $curl_opts -l ${base} | grep "gfs\." | tail -n 1 | cut -f2 -d'‘' | cut -f1 -d'’' | cut -f2 -d'`' | cut -f1 -d "'")}
last_url=${base}/${last_day}
#base=ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/
last_day=$(curl $curl_opts -l ${base} | grep "gfs\." | tail -n 1 | cut -f2 -d \")
last_url=${base}${last_day}/
# Find the most recent hour.
last_hour=""
for hh in {18..00..6}; do
if curl $curl_opts --output /dev/null --head --fail ${last_url}/gfs.t${hh}z.pgrb2.0p25.f000; then
if curl $curl_opts --output /dev/null --head --fail ${last_url}/${hh}/gfs.t${hh}z.pgrb2.0p25.f000; then
last_hour=$hh
break
fi
......@@ -30,11 +31,11 @@ done
if [ -z $last_hour ]; then
# Try the last-but-one day.
last_day=$(curl $curl_opts -l ${base} | grep "gfs\." | tail -n 2 | head -n 1 | cut -f2 -d'‘' | cut -f1 -d'’' | cut -f2 -d'`' | cut -f1 -d "'")
last_day=$(curl $curl_opts -l ${base} | grep "gfs\." | tail -n 2 | cut -f2 -d \")
last_url=${base}/${last_day}
# Find the most recent hour.
for hh in {18..00..6}; do
if curl $curl_opts --output /dev/null --head --fail ${last_url}/gfs.t${hh}z.pgrb2.0p25.f000; then
if curl $curl_opts --output /dev/null --head --fail ${last_url}/${hh}/gfs.t${hh}z.pgrb2.0p25.f000; then
last_hour=$hh
break
fi
......@@ -49,7 +50,8 @@ if [ -z $last_hour ]; then
exit 1
fi
latest_forecast_dir=${last_day//./_}_${last_hour}
last_day_underscore=$(echo ${last_day} | tr . _)
latest_forecast_dir=${last_day_underscore}${last_hour}_${last_hour}
if [ ! -d "$latest_forecast_dir" ]; then
mkdir $latest_forecast_dir
......@@ -57,13 +59,13 @@ if [ ! -d "$latest_forecast_dir" ]; then
cd $latest_forecast_dir
# Grab the latest files.
curl $curl_opts --remote-name ${last_url}/gfs.t${last_hour}z.pgrb2.0p25.f000 || true
curl $curl_opts --remote-name ${last_url}${last_hour}/gfs.t${last_hour}z.pgrb2.0p25.f000 || true
# Cycle the latest forecast files in a range $fxxx== between xxx=000 and
# xxx=195 with 3hours increment:
for ff in $(seq -w 0 3 $(printf %03d $forecast_hours)); do
file=gfs.t${last_hour}z.pgrb2.0p25.f${ff}
url=${last_url}/${file}
url=${last_url}${last_hour}/${file}
curl $curl_opts --remote-name $url
done
......
[command]
default = bash dima_get_new.sh 120 ${EURYALE_GFS_ARCHIVE} ${CETO_GFS_DIR}
default = bash dima_get_new.sh 120 ${EURYALE_GFS_ARCHIVE} ${CETO_GFS_DIR} ${GFS_FTP_DIR}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment