Soundings Replot Utility for RASP

Having been asked to add some RASP sounding plots in Northern Ireland, it became apparent that a script to just test just the ones added would make life easier (than replotting sounding by hour from the command line).Then it became an idea to just have this to replot all soundings (as potentially to do them later on a differnet host).

The script below is the result, fixed for one model with fixed start end points. These can of course be extended/changed as approriate.

#!/bin/bash
# Script expects a model as the first parameter,
# e.g. "sound_plot.sh EI12"
# Also expects "replot" to be available in $HOMEDIR/GM and it works

# Set where the RASP setup lives
HOMEDIR=/home/rasp

# Set where are commands are ... useful to put full path if run
# from a cron job. Ensure they exist, or add a check for it.
REPLOT_CMD=$HOMEDIR/GM/replot
SEQ_CMD=/usr/bin/seq

# Check we got a model and date to plot
if [ $# -eq 2 ]
then
echo "Using input as '$1'"
echo "Using '$REPLOT_CMD' to replot"
echo "Using date as '$2'"
else
echo "Provide a model to try. E.g. UK12 2015-04-03"
exit
fi

case $1 in
EI12) # We'll do just the one here
# Set the start and end sounding number (as in soundingXX)
val1=1
val2=19
SEQ1=$(SEQ_CMD -s " " $val1 $val2)
# Set the start end of hours to use
val3=7
val4=19
SEQ2=$(SEQ_CMD -f "%02g" -s " " $val3 $val4)
# Set the model to use and clear out the temp folder where
# we will put the results
MODEL=$1
;;
*)
echo "Don't know this model to work out start and finish: $1"
exit
;;
esac

# Now sort out the results folder ...
MODEL_FOLDER=$HOMEDIR/$MODEL
TMP_FOLDER=$HOMEDIR/$MODEL/tmp
# Clear it out
rm -rf $TMP_FOLDER
mkdir $TMP_FOLDER

# Output what we set
START_SND=$(printf '%d' "$val3")
END_SND=$(printf '%d' "$val4")
START_HR=$(printf '%02d' "$val1")
END_HR=$(printf '%02d' "$val2")

echo "Sounding sequence: sounding$SEQ1"
echo "Hour sequence: $SEQ2"
echo "Sending results to: $TMP_FOLDER"
echo "Using date of: $2"

#Now do plots, assuming no gaps though
for SND_NAME in $SEQ1
do
SOUNDING_NAME=sounding$SND_NAME
for PROC_HR in $SEQ2
do
echo "$REPLOT_CMD -r $MODEL -d $TMP_FOLDER -p $SOUNDING_NAME -l $TMP_FOLDER -w $MODEL_FOLDER/wrfout_d02_$2_$PROC_HR\:00\:00"
$HOMEDIR/GM/replot -r $MODEL -d $TMP_FOLDER -p $SOUNDING_NAME -l $TMP_FOLDER -w $MODEL_FOLDER/wrfout_d02_$2_$PROC_HR\:00\:00
done
done