#!/bin/sh # https://www.ecmwf.int/en/forecasts/datasets/wmo-essential ## 0.5 degree resolution ## NB : files have jpeg compression #nmcli c up IRIDIUM-12345 #export http_proxy=http://192.168.3.37:3119 ## web proxy for Iridium GO ! #ofn0=~/sail.d/grib.d/g2sub.d/gribs.d/ ofn0=$HOME/sail.d/grib-data.d/ #var0="_(u|v|t|msl|gh)_" # winds at 850hPa (approx 1.5 km) ? #exp0="_(0|24|48|72|96|120)h(|_em)_(t|msl|gh)_" #exp0="_(an|(0|24|48|72|96|120|144|168|192)h_em)_(t|msl|gh)_" # em => ens mean #exp0="_em_(msl|gh)_" # em => ens mean => over 7 hours to run exp0="h_(msl|gh)_" # regular => over 6 hours to run when0=now when0="390 min ago" ## 6h to run the regular model ?? some way to find "newest" ?? when0="450 min ago" ## 7h05m to run the "ens mean" model ?? some way to find "newest" ?? trun0=12 ### ECMWF models are run every 12 hours user0=wmo pw0=essential host0=dissemination.ecmwf.int dir0=%Y%m%d%H ofn0+=ecmwf_$dir0 #ofn0+=-$(echo "$exp0" | tr '()|' '--+' ) # tag w/ var regex #??# tr: range-endpoints of '--+' are in reverse collating sequence order url0=ftp://$user0:$pw0@$host0/${dir0}0000 dat0=$(date +%s -d "$when0") dat0=$(expr $dat0 - $dat0 % \( $trun0 \* 60 \* 60 \)) ## quantitize to $trun0 hours url0=$(date -u -d@$dat0 +$url0) ofn0=$(date -u -d@$dat0 +$ofn0) rm $ofn0.grib2 tmp0=$(mktemp /tmp/tmp-get-ecm.XXXXX) unset TZ ## "stat" in GMT echo curl -l $url0/ ## NB : this "curl directory listing" technique doesn't work for Iridium Go : too slow (use curl "{}[]" ??) curl -l --compressed $url0/ | grep grib2 | egrep "$exp0" | \ sort -t_ -k 6n | while read fn0 rest0 ; do echo fn : $fn0 code0=$(curl -R -w %{http_code} --compressed $url0/$fn0 -o $tmp0) if test $code0 = 226 ; then stat -c "stat : %y" $tmp0 cat $tmp0 >> $ofn0.grib2 else echo code : $code0 >> $ofn0.log file $tmp0 >> $ofn0.log echo url0/fn0 : $url0/$fn0 >> $ofn0.log cat $tmp0 >> $ofn0.log fi done rm $tmp0 wgrib2 $ofn0.grib2 -netcdf $ofn0.nc ls -tl $ofn0.*