source: trunk/CONFIG/ORCA2_LIM/IDL_scripts/time_series.sh @ 2150

Last change on this file since 2150 was 2150, checked in by flavoni, 10 years ago

commit idl tools for post-processing, for ORCA2_LIM configuration, see ticket #724

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/sh
2#
3# AUTHOR - date
4# ===========
5# Simona Flavoni  - 02/2010 - LOCEAN
6#
7# DESCRIPTION
8# ===========
9# Graphics outputs files are written in my_IDL/PS/ps_ts/.
10#
11# A global document with all plots in Postscript, PDF or HTML file can be produced.
12#
13# EXAMPLES
14# ========
15# $ ./time_series.sh -exp1 sEXP1 -exp2 sEXP2 -ystart year1 -yend year2 -format pdf
16#
17# PROBLEMS
18# ========
19# no batch processing possible because of SAXO interactiviy Seb is working on it ...
20#
21# TODO
22# ====
23# portability on linux
24# define overriding policy
25# finalize ps and pdf production
26#
27usage=" Usage : ${command} -exp1 exp1 -exp2 exp2 -ystart start -yend end -format pdf
28 exp1 is your experience name
29 exp2 is name of experience of reference
30 ystart is the first year from which you want to compute Time Series
31 yend is the last year for which you want to compute Time Series
32 example:  ./time_series.sh -exp1 core2000 -exp2 core2000 -ystart 1 -yend 2000 -format pdf "
33#
34minargcount=10
35if [ ${#} -lt ${minargcount} ]; then
36 echo "Not enought arguments"
37 echo "${usage}"
38 exit 1
39fi
40#
41while [ ! -z "${1}" ] # ++ pb bash
42do
43 case ${1} in
44     -exp1)  exp1=${2}        shift  ;;
45     -exp2)  exp2=${2}        shift  ;;
46     -ystart)   start=${2}   shift   ;;
47     -yend)  end=${2}     shift   ;;
48     -format)   format=${2}     shift   ;;
49     -h) 
50    echo "${usage}"
51    exit
52    ;;
53     *) # other choice
54    echo "${usage}"
55    exit 1
56    ;;
57 esac
58 shift # next flag
59done
60#
61# ++ check parameters
62set -u
63#
64# define output directory for POSTCRIPT files
65#++ change directory
66#================CHANGE DIRECTORIES=====================
67psdir=/path_output_PS_time_series
68pdfdir=/path_output_PDF_time_series
69htmldir=/path_output_HTML_time_series
70#================END CHANGE DIRECTORIES=================
71# test if ${psdir} already exists
72if [ -d ${psdir} ]; then
73 echo "${psdir} already exist"
74 #+++exit 1
75else
76 mkdir -p ${psdir}
77fi 
78# test if ${pdfdir} already exists
79if [ -d ${pdfdir} ]; then
80 echo "${psdir} already exist"
81 #+++exit 1
82else
83 mkdir -p ${pdfdir}
84fi 
85
86# memorize current IDL_STARTUP file
87memo_idl_startup=${IDL_STARTUP}
88
89# generation of IDL commands file to launch several std_plots commands
90rm /tmp/time_series_multi.pro 2> /dev/null
91cat << EOF >> /tmp/time_series_multi.pro
92 psdir='${psdir}'
93 std_ts,'${exp1}','${exp2}',${start},${end},/postscript
94 exit
95EOF
96#
97idl_command='/Applications/itt/idl64/bin/idl'  # !! only on my mac
98#
99# check if IDL available
100type ${idl_command}
101status_type=${?}
102if [ ${status_type} -ne 0 ]
103then
104 echo "eee : idl not found"
105 exit 1
106fi
107# debug
108more /tmp/time_series_multi.pro
109#
110# launch IDL
111${idl_command} /tmp/time_series_multi.pro
112status_idl=${?}
113# test if idl returns ok
114# echo "iii : ${status_idl}"
115#
116# restore IDL_STARTUP file
117IDL_STARTUP=${memo_idl_startup}
118export IDL_STARTUP
119
120# produce the final document
121case ${format} in
122    pdf)
123   rm ${pdfdir}/all_ts.pdf 2> /dev/null
124   echo "psdir: ${psdir}"
125   for file in ${psdir}/*.ps ; do
126       echo "ps2pdf"
127      ps2pdf -sPAPERSIZE=a4 ${file}
128   done
129   ls ${pdfdir}
130   mv *.pdf ${pdfdir}/.
131   texexec --pdfarrange --result=/tmp/all_ts.pdf ${pdfdir}/*.pdf
132   rm -rf *.aux *.log /tmp/*.log
133   mv /tmp/all_ts.pdf ${pdfdir}/all_ts.pdf
134#commented because convert gives images of bad quality
135#  convert ${psdir}/*.ps /tmp/all_ts.pdf
136#       convert -resize 800x600 ${psdir}/${exp1}_${exp2}/ps/*.ps /tmp/all_ts.pdf
137   ;;
138    html)
139   rm /tmp/time_series.html 2> /dev/null
140# check if convert available
141   convert_command='/sw/bin/convert'  # !! only on my mac
142   type ${convert_command}
143   status_type=${?}
144   if [ ${status_type} -ne 0 ]
145   then
146       echo "eee : convert not found"
147       exit 1
148   fi
149# debug
150   
151   for file in `ls ${psdir}/*.ps | sed -e "s/\.ps//"` ; do
152       ${convert_command} -antialias  ${file}.ps  ${file}.png
153   done
154    # creation of a HTML file
155   cat << EOF > /tmp/time_series.html
156   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
157   <html xmlns="http://www.w3.org/1999/xhtml">
158   <head>
159   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
160        <hr>
161         </head>
162   <body>
163EOF
164   cat /tmp/time_series.txt >>  /tmp/time_series.html
165   cat << EOF >> /tmp/time_series.html
166<hr/>
167EOF
168   
169   cat << EOF >> /tmp/time_series.html
170
171  </body>
172  </html>
173EOF
174   more /tmp/time_series.html
175   ;;
176    *)   
177   echo " format ${format} not implemented"
178   exit 1
179   ;;
180esac
181
182    #
183exit 0
Note: See TracBrowser for help on using the repository browser.