#!/bin/sh # # AUTHOR - date # =========== # Françoise Pinsard - 01/2010 - LOCEAN # Simona Flavoni - 01/2010 - LOCEAN # # DESCRIPTION # =========== # Graphics outputs files are written in ./exp1_exp2/ps/. # # A global document with all plots in Postscript, PDF or HTML file can be produced. # # EXAMPLES # ======== # $ ./std_plots.sh -exp1 v32colib -exp2 v32colib -y 19800101_19801231 -format html # # $ ./std_plots.sh -exp1 core100 -exp2 core100 -y 00910101_01001231 -format pdf # # PROBLEMS # ======== # no batch processing possible because of SAXO interactiviy Seb is working on it ... # # TODO # ==== # portability on linux # define overriding policy # finalize ps and pdf production # usage=" Usage : ${command} -exp1 exp1 -exp2 exp2 -y start -format html example: ./std_plots.sh -exp1 core2000 -exp2 core2000 -y 1991 -format pdf exp1 is your experience name exp2 is the reference experience (if you don't have one exp2 = exp1) ystart is the first year of your 10years file output; example: 361 if you want to take file core2000_03610101_03701231_1Y_grid_T.nc" # minargcount=8 if [ ${#} -lt ${minargcount} ]; then echo "Not enought arguments" echo "${usage}" exit 1 fi # while [ ! -z "${1}" ] # ++ pb bash do case ${1} in -exp1) exp1=${2} shift ;; -exp2) exp2=${2} shift ;; -y) ystart=${2} shift ;; -format) format=${2} shift ;; -h) echo "${usage}" exit 0 ;; *) # other choice echo "${usage}" exit 1 ;; esac shift # next flag done # # ++ check parameters set -u # # define output directory for POSTCRIPT files #++ change directory #===============CHANGE DIRECTORIES========================== psdir=~/PS/${exp1}_${exp2}/ps/ pdfdir=~/PDF/${exp1}_${exp2}/pdf htmldir=~/HTML/${exp1}_${exp2}/pdf #===============END CHANGE DIRECTORIES======================= # test if ${psdir} already exists if [ -d ${psdir} ]; then echo "${psdir} already exist" #+++exit 1 else mkdir -p ${psdir} fi # test if ${pdfdir} already exists if [ -d ${pdfdir} ]; then echo "${psdir} already exist" #+++exit 1 else mkdir -p ${pdfdir} fi # memorize current IDL_STARTUP file memo_idl_startup=${IDL_STARTUP} # generation of IDL commands file to launch several std_plots commands # NOTE: $(( 10#${ystart} )) is used to have decimal, if not the number that start with 0 (for example if you put 0361) would be interpeted like alphanumerical number rm /tmp/std_plots_multi.pro 2> /dev/null cat << EOF >> /tmp/std_plots_multi.pro psdir='${psdir}' std_plots,'${exp1}','${exp2}', $(( 10#${ystart} )), /postscript exit EOF # idl_command='/Applications/itt/idl64/bin/idl' # !! only on my mac # # check if IDL available type ${idl_command} status_type=${?} if [ ${status_type} -ne 0 ] then echo "eee : idl not found" exit 1 fi # debug more /tmp/std_plots_multi.pro # # launch IDL ${idl_command} /tmp/std_plots_multi.pro status_idl=${?} # test if idl returns ok #echo "iii : ${status_idl}" # # restore IDL_STARTUP file IDL_STARTUP=${memo_idl_startup} export IDL_STARTUP # produce the final document case ${format} in pdf) rm ${pdfdir}/all_plots.pdf 2> /dev/null for file in ${psdir}/*.ps ; do echo "ps2pdf" # echo "nome file: ${file}" ps2pdf -sPAPERSIZE=a4 ${file} done # echo "dentro pdf" ls ${pdfdir} mv *.pdf ${pdfdir}/. texexec --pdfarrange --result=/tmp/all_plots.pdf ${pdfdir}/*.pdf rm -rf *.aux *.log /tmp/*.log mv /tmp/all_plots.pdf ${pdfdir} #commented because convert gives images of bad quality # convert ${psdir}/*.ps /tmp/all_plots.pdf # convert -resize 800x600 ${psdir}/${exp1}_${exp2}/ps/*.ps /tmp/all_plots.pdf ;; html) rm /tmp/std_plots.html 2> /dev/null # check if convert available convert_command='/sw/bin/convert' # !! only on my mac type ${convert_command} status_type=${?} if [ ${status_type} -ne 0 ] then echo "eee : convert not found" exit 1 fi # debug for file in `ls ${psdir}/*.ps | sed -e "s/\.ps//"` ; do ${convert_command} -antialias ${file}.ps ${file}.png done # creation of a HTML file cat << EOF > /tmp/std_plots.html
EOF cat /tmp/std_plots.txt >> /tmp/std_plots.html cat << EOF >> /tmp/std_plots.html
EOF cat << EOF >> /tmp/std_plots.html EOF more /tmp/std_plots.html ;; *) echo " format ${format} not implemented" exit 1 ;; esac # #===================== # prepare to put images on dods # +++ to finish it #LOGIN=xxxx #Tag_Name=ORCA2_LIM2 #rsh ${LOGIN}@gaya.idris.fr exec /bin/ksh < /dev/null 2>&1 # /usr/local/bin/dods_cp ${exp1} DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} > /dev/null 2>&1 #EOF #===================== # end exit 0