1 | #!/bin/sh |
---|
2 | # |
---|
3 | # AUTHOR - date |
---|
4 | # =========== |
---|
5 | # Françoise Pinsard - 01/2010 - LOCEAN |
---|
6 | # Simona Flavoni - 01/2010 - LOCEAN |
---|
7 | # |
---|
8 | # DESCRIPTION |
---|
9 | # =========== |
---|
10 | # Graphics outputs files are written in ./exp1_exp2/ps/. |
---|
11 | # |
---|
12 | # A global document with all plots in Postscript, PDF or HTML file can be produced. |
---|
13 | # |
---|
14 | # EXAMPLES |
---|
15 | # ======== |
---|
16 | # $ ./std_plots.sh -exp1 v32colib -exp2 v32colib -y 19800101_19801231 -format html |
---|
17 | # |
---|
18 | # $ ./std_plots.sh -exp1 core100 -exp2 core100 -y 00910101_01001231 -format pdf |
---|
19 | # |
---|
20 | # PROBLEMS |
---|
21 | # ======== |
---|
22 | # no batch processing possible because of SAXO interactiviy Seb is working on it ... |
---|
23 | # |
---|
24 | # TODO |
---|
25 | # ==== |
---|
26 | # portability on linux |
---|
27 | # define overriding policy |
---|
28 | # finalize ps and pdf production |
---|
29 | # |
---|
30 | usage=" Usage : ${command} -exp1 exp1 -exp2 exp2 -y start -format html |
---|
31 | example: ./std_plots.sh -exp1 core2000 -exp2 core2000 -y 1991 -format pdf |
---|
32 | exp1 is your experience name |
---|
33 | exp2 is the reference experience (if you don't have one exp2 = exp1) |
---|
34 | 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" |
---|
35 | # |
---|
36 | minargcount=8 |
---|
37 | if [ ${#} -lt ${minargcount} ]; then |
---|
38 | echo "Not enought arguments" |
---|
39 | echo "${usage}" |
---|
40 | exit 1 |
---|
41 | fi |
---|
42 | # |
---|
43 | while [ ! -z "${1}" ] # ++ pb bash |
---|
44 | do |
---|
45 | case ${1} in |
---|
46 | -exp1) exp1=${2} shift ;; |
---|
47 | -exp2) exp2=${2} shift ;; |
---|
48 | -y) ystart=${2} shift ;; |
---|
49 | -format) format=${2} shift ;; |
---|
50 | -h) |
---|
51 | echo "${usage}" |
---|
52 | exit 0 |
---|
53 | ;; |
---|
54 | *) # other choice |
---|
55 | echo "${usage}" |
---|
56 | exit 1 |
---|
57 | ;; |
---|
58 | esac |
---|
59 | shift # next flag |
---|
60 | done |
---|
61 | # |
---|
62 | # ++ check parameters |
---|
63 | set -u |
---|
64 | # |
---|
65 | # define output directory for POSTCRIPT files |
---|
66 | #++ change directory |
---|
67 | #===============CHANGE DIRECTORIES========================== |
---|
68 | psdir=~/PS/${exp1}_${exp2}/ps/ |
---|
69 | pdfdir=~/PDF/${exp1}_${exp2}/pdf |
---|
70 | htmldir=~/HTML/${exp1}_${exp2}/pdf |
---|
71 | #===============END CHANGE DIRECTORIES======================= |
---|
72 | # test if ${psdir} already exists |
---|
73 | if [ -d ${psdir} ]; then |
---|
74 | echo "${psdir} already exist" |
---|
75 | #+++exit 1 |
---|
76 | else |
---|
77 | mkdir -p ${psdir} |
---|
78 | fi |
---|
79 | # test if ${pdfdir} already exists |
---|
80 | if [ -d ${pdfdir} ]; then |
---|
81 | echo "${psdir} already exist" |
---|
82 | #+++exit 1 |
---|
83 | else |
---|
84 | mkdir -p ${pdfdir} |
---|
85 | fi |
---|
86 | |
---|
87 | # memorize current IDL_STARTUP file |
---|
88 | memo_idl_startup=${IDL_STARTUP} |
---|
89 | |
---|
90 | # generation of IDL commands file to launch several std_plots commands |
---|
91 | # 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 |
---|
92 | rm /tmp/std_plots_multi.pro 2> /dev/null |
---|
93 | cat << EOF >> /tmp/std_plots_multi.pro |
---|
94 | psdir='${psdir}' |
---|
95 | std_plots,'${exp1}','${exp2}', $(( 10#${ystart} )), /postscript |
---|
96 | exit |
---|
97 | EOF |
---|
98 | # |
---|
99 | idl_command='/Applications/itt/idl64/bin/idl' # !! only on my mac |
---|
100 | # |
---|
101 | # check if IDL available |
---|
102 | type ${idl_command} |
---|
103 | status_type=${?} |
---|
104 | if [ ${status_type} -ne 0 ] |
---|
105 | then |
---|
106 | echo "eee : idl not found" |
---|
107 | exit 1 |
---|
108 | fi |
---|
109 | # debug |
---|
110 | more /tmp/std_plots_multi.pro |
---|
111 | # |
---|
112 | # launch IDL |
---|
113 | ${idl_command} /tmp/std_plots_multi.pro |
---|
114 | status_idl=${?} |
---|
115 | # test if idl returns ok |
---|
116 | #echo "iii : ${status_idl}" |
---|
117 | # |
---|
118 | # restore IDL_STARTUP file |
---|
119 | IDL_STARTUP=${memo_idl_startup} |
---|
120 | export IDL_STARTUP |
---|
121 | |
---|
122 | # produce the final document |
---|
123 | case ${format} in |
---|
124 | pdf) |
---|
125 | rm ${pdfdir}/all_plots.pdf 2> /dev/null |
---|
126 | for file in ${psdir}/*.ps ; do |
---|
127 | echo "ps2pdf" |
---|
128 | # echo "nome file: ${file}" |
---|
129 | ps2pdf -sPAPERSIZE=a4 ${file} |
---|
130 | done |
---|
131 | # echo "dentro pdf" |
---|
132 | ls ${pdfdir} |
---|
133 | mv *.pdf ${pdfdir}/. |
---|
134 | texexec --pdfarrange --result=/tmp/all_plots.pdf ${pdfdir}/*.pdf |
---|
135 | rm -rf *.aux *.log /tmp/*.log |
---|
136 | mv /tmp/all_plots.pdf ${pdfdir} |
---|
137 | #commented because convert gives images of bad quality |
---|
138 | # convert ${psdir}/*.ps /tmp/all_plots.pdf |
---|
139 | # convert -resize 800x600 ${psdir}/${exp1}_${exp2}/ps/*.ps /tmp/all_plots.pdf |
---|
140 | ;; |
---|
141 | html) |
---|
142 | rm /tmp/std_plots.html 2> /dev/null |
---|
143 | # check if convert available |
---|
144 | convert_command='/sw/bin/convert' # !! only on my mac |
---|
145 | type ${convert_command} |
---|
146 | status_type=${?} |
---|
147 | if [ ${status_type} -ne 0 ] |
---|
148 | then |
---|
149 | echo "eee : convert not found" |
---|
150 | exit 1 |
---|
151 | fi |
---|
152 | # debug |
---|
153 | |
---|
154 | for file in `ls ${psdir}/*.ps | sed -e "s/\.ps//"` ; do |
---|
155 | ${convert_command} -antialias ${file}.ps ${file}.png |
---|
156 | done |
---|
157 | # creation of a HTML file |
---|
158 | cat << EOF > /tmp/std_plots.html |
---|
159 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
---|
160 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
161 | <head> |
---|
162 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
163 | <hr> |
---|
164 | </head> |
---|
165 | <body> |
---|
166 | EOF |
---|
167 | cat /tmp/std_plots.txt >> /tmp/std_plots.html |
---|
168 | cat << EOF >> /tmp/std_plots.html |
---|
169 | <hr/> |
---|
170 | EOF |
---|
171 | |
---|
172 | cat << EOF >> /tmp/std_plots.html |
---|
173 | |
---|
174 | </body> |
---|
175 | </html> |
---|
176 | EOF |
---|
177 | more /tmp/std_plots.html |
---|
178 | ;; |
---|
179 | *) |
---|
180 | echo " format ${format} not implemented" |
---|
181 | exit 1 |
---|
182 | ;; |
---|
183 | esac |
---|
184 | |
---|
185 | # |
---|
186 | #===================== |
---|
187 | # prepare to put images on dods |
---|
188 | # +++ to finish it |
---|
189 | #LOGIN=xxxx |
---|
190 | #Tag_Name=ORCA2_LIM2 |
---|
191 | #rsh ${LOGIN}@gaya.idris.fr exec /bin/ksh <<EOF |
---|
192 | # cd ${homegaya}/IGCM_OUT/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} |
---|
193 | # /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} > /dev/null 2>&1 |
---|
194 | # /usr/local/bin/dods_cp ${exp1} DODS/pub/${LOGIN}/${Tag_Name}/CORE2/INTERAN/plots_pdf/${exp1} > /dev/null 2>&1 |
---|
195 | #EOF |
---|
196 | #===================== |
---|
197 | # end |
---|
198 | exit 0 |
---|