From 6a366f94d26c879cfaa5d92cbfaa9c267370eccb Mon Sep 17 00:00:00 2001 From: hlburns Date: Thu, 7 Feb 2019 11:02:02 +0000 Subject: [PATCH] :sparkles: commandline options added --- Run.sh | 38 ++++++++++++++++++++++++++++---------- updatesite.sh | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/Run.sh b/Run.sh index 98be389..c9d5cee 100755 --- a/Run.sh +++ b/Run.sh @@ -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) @@ -35,7 +49,7 @@ 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 @@ -43,7 +57,7 @@ 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}" ###" @@ -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 diff --git a/updatesite.sh b/updatesite.sh index 508d5e0..fb55468 100755 --- a/updatesite.sh +++ b/updatesite.sh @@ -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} @@ -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"