#!/bin/bash

[ $IRSPP_INSTALL ] || { echo "Please define environment variable IRSPP_INSTALL"; exit 1; }

[ -f $IRSPP_INSTALL/bin/irspp_env.sh ] || { echo "Error: cannot find $IRSPP_INSTALL/bin/irspp_env.sh"; exit 1; }

. $IRSPP_INSTALL/bin/irspp_env.sh

TOPDIR=$(cd ..; pwd)

imagedir=$TOPDIR/images
mkdir -p $imagedir

cd $TOPDIR/output_5x5_bufr || { echo "Cannot cd to $TOPDIR/output_5x5_bufr"; exit 1; }

irs_BUFR_display_rr.py -i "$(ls *.bin)" -c 145 -r "20 70 0 35" -rmin 0 -rmax 0.1 -s 20 || exit 1

echo "Image file: $(ls *.png)"
mv *.png $imagedir
echo "Image directory: $imagedir"
