Skip to content

Commit

Permalink
✨ commandline options added
Browse files Browse the repository at this point in the history
  • Loading branch information
cemachelen committed Feb 7, 2019
1 parent bd9e8d9 commit 6a366f9
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 18 deletions.
38 changes: 28 additions & 10 deletions Run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@
set -e #stop at first error
module load intel/17.0.0
module load python2 python-libs
# Defaults
rundate=$(date +%Y%m%d)
vizhome=~earunres

print_usage() {
echo "Usage:
-d date YMD defaults to today
-n name of viz defaults to ~earunres"
}

while getopts 'dn:hv' flag; do
case "${flag}" in
d) rundate="${OPTARG}" ;;
n) vizhome="${OPTARG}" ;;
v) verbose=true ;;
h) print_usage
exit 1 ;;
*) print_usage
exit 1 ;;
esac
done

#Read in command line arguments and set subsequent variables
if [ $# -eq 0 ]
then
rundate=$(date +%Y%m%d)
else
rundate=$1
fi
prevdate=$(date -d "$rundate - 1 day" +%Y%m%d)
middate=$(date -d "$rundate + 1 day" +%Y%m%d)
enddate=$(date -d "$rundate + 2 days" +%Y%m%d)
Expand All @@ -35,15 +49,15 @@ run3DDAT=true
runCALMET=true
runCALPUFF=true
runVIS=true

runffmpeg=false
#Set other parameters
res=1000 #Resolution (m) of intended CALPUFF grid. Should be an integer that is > 100 and < 1000
let NX=90000/$res+1
let NY=54000/$res+1
DGRIDKM=$(echo "scale=3; $res/1000" | bc)
let MESHGLAZ=1000/$res+1
# VISUALISATION PATH
VIZPATH=~/public_html/UNRESP_VIZ/
VIZPATH=$vizhome/public_html/UNRESP_VIZ/
cwd=$(pwd)

echo "### RUNNING FORECAST SYSTEM FOR DATE "${rundate}" ###"
Expand Down Expand Up @@ -325,13 +339,17 @@ if [ "$runVIS" = true ]; then
./generateMaps.py ${rundate}
cd ..
cd vis/${rundate}
if [ "$runffmpeg" = true]; then
echo "Running ffmpeg"
ffmpeg -f image2 -r 4 -i static_concrec0100%02d.png -vcodec mpeg4 -y -s 7680x4320 movie_${rundate}.mp4
fi
cd ../..
echo " ---> FINISHED ###"

echo "Adding latest VISUALISATION to website"
echo "Adding latest VISUALISATION to website at "$VIZPATH

cd vis/${rundate}
echo "Reformatting png to jpg"
mogrify -format jpg *.png
rm -f *.png
setfacl -m other:r-x *.jpg *.html
Expand Down
50 changes: 42 additions & 8 deletions updatesite.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
#!/bin/bash
# This script was created by CEMAC (University of Leeds) as part of the UNRESP
# Project to RUN VIZ SEPARATELY
#Setup environment
set -e #stop at first error
module load intel/17.0.0
module load python2 python-libs

# Defaults
rundate=$(date +%Y%m%d)
# If the vis hasn't been done yet
runVIS=false
vizhome=~earunres

print_usage() {
echo "Usage:
-d date YMD defaults to today
-n name of viz defaults to ~earunres"
}

while getopts 'dn:hv' flag; do
case "${flag}" in
d) rundate="${OPTARG}" ;;
n) vizhome="${OPTARG}" ;;
v) verbose=true ;;
h) print_usage
exit 1 ;;
*) print_usage
exit 1 ;;
esac
done

runVIS=true
runffmpeg=false
cwd=$(pwd)
FNAME=$rundate
VIZPATH=$vizhome/public_html/UNRESP_VIZ/

if [ "$runVIS" = true ]; then
echo "### RUNNING VISUALISATION TOOLS"
rm -rf ./vis/${rundate}
Expand All @@ -10,22 +42,24 @@ if [ "$runVIS" = true ]; then
./generateMaps.py ${rundate}
cd ..
cd vis/${rundate}
ffmpeg -f image2 -r 4 -i static_concrec0100%02d.png -vcodec mpeg4 -y -s 7680x4320 movie_${rundate}.mp4
if [ "$runffmpeg" = true]; then
ffmpeg -f image2 -r 4 -i static_concrec0100%02d.png -vcodec mpeg4 -y -s 7680x4320 movie_${rundate}.mp4
fi
cd ../..
echo " ---> FINISHED ###"
fi
cwd=$(pwd)
FNAME=$(date +%Y%m%d)
VIZPATH=~/public_html/UNRESP_VIZ/
cd vis/$FNAME
# mogrify -format jpg *.png
echo "### REFORMATIING AND MOVING TO "$VIZPATH
mogrify -format jpg *.png
rm -f *.png
setfacl -m other:r-x *
chmod og+rx *
if [ ! -e $VIZPATH$FNAME ]
then
mkdir $VIZPATH$FNAME
fi
#mv *.jpg *.html $VIZPATH$FNAME
mv *.jpg *.html $VIZPATH$FNAME
cd $VIZPATH
ln -sf $FNAME Today
cd $cwd
echo "DONE"

0 comments on commit 6a366f9

Please sign in to comment.