Search This Blog

Friday, July 6, 2012

Cruise specific sea surface temperature/salinity animations

I'm currently sitting offshore south of Iceland about to pass over the Mid-Atlantic Ridge.  We're shooting EM302 multibeam and, as always, I'm curious about what to expect from the ocean's temperature and salinity.

The RTOFS grids that I've been playing with for the past while have come in handy again.  I wrote a script to pull down the imagery that's generated on a daily basis on the RTOFS website and a bit of sorcery with ImageMagick's "convert" program massages it into a little animation for me to see the sea surface temperature and salinity every day.

Here's an example:

And here's the script:


dir=`date '+%Y%m%d'`

rm -rf $dir
mkdir $dir
cd $dir

for field in temperature salinity; do

        echo "Doing field" $field

        for hour in 024 048; do
                echo "Doing nowcast" $hour

        for hour in 024 048 072 096 120 144; do
                echo "Doing forecast" $hour

for file in *.png; do

        prefix=`basename $file .png`
        convert -crop 1840x120+0+1131 $file scale.ppm

        # I have to convert to .ppm to toss out rotation info in png header such that 
        # the crop operation works?  Otherwise, the crop geometry is in the original unrotated
        # image geometry.
        convert -rotate 135 $file temp.ppm
        convert -crop 450x360+600+1000 temp.ppm temp2.ppm

        label=`echo $file | awk -F_ '{print '$dir',$3,$4}' `

        convert -draw "image Over 0,310 450,52 scale.ppm" -fill white -stroke black -pointsize 24 -draw "text 10,30 '$label'" temp2.ppm $file


for temperature_file in *temperature*png; do
        output_file=`echo $temperature_file | sed -e 's/temperature/TS/' `
        salinity_file=`echo $temperature_file | sed -e 's/temperature/salinity/' `

        convert -extent 900x360 -draw "image Over 450,0 450,360 $salinity_file" $temperature_file $output_file

convert -loop 0 -delay 50 rtofs_arctic_temperature_f*png temperature_animation.gif
convert -loop 0 -delay 50 rtofs_arctic_salinity_f*png salinity_animation.gif
convert -loop 0 -delay 50 rtofs_arctic_TS_f*png TS_animation.gif

rm temp.ppm temp2.ppm scale.ppm

No comments:

Post a Comment