mardi 26 août 2014

Animated gifs for GFS runs

Here are two functions that generate animated gis for rain and winds in europa/north africa:

function gfs_rain {
mkdir -p /tmp/gfs && cd /tmp/gfs
i=1
wget -qO- "http://www.meteociel.fr/modeles/gfse_cartes.php?ech=6&code=code&mode=2&mode3h=1&carte=0" | grep -m 1 -oP "http://modeles.meteociel.fr/modeles/gfs/run/gfs-2-\d+-3h.png" | while read l; do
wget -c $l -O $i.png; ((i++))
done
mogrify -resize 512x341 *.png
ls | grep -oP "^\d{1}.png" | xargs -i{} mv {} 0{}
convert -delay 20 -loop 0 * gfs-rain.gif
}

function gfs_winds {
mkdir -p /tmp/gfs && cd /tmp/gfs
i=1
wget -qO- "http://www.meteociel.fr/modeles/gfse_cartes.php?ech=39&code=0&mode=14&mode3h=1" | grep -m 1 -oP "http://modeles\.meteociel\.fr/modeles/gfs/runs/.*?\.png" | while read l; do
wget -c $l -O $i.png; ((i++))
done
mogrify -resize 512x341 *.png
ls | grep -oP "^\d{1}.png" | xargs -i{} mv {} 0{}
convert -delay 20 -loop 0 * gfs-winds.gif
}