source: lmdz_wrf/trunk/tools/lmdz_check.bash @ 244

Last change on this file since 244 was 243, checked in by lfita, 10 years ago

Adding pressure table eqjuivalencies with the level number

  • Property svn:executable set to *
File size: 24.9 KB
Line 
1#!/bin/bash -x
2## e.g. # lmdz_check.bash -1:6:3:26 wrfout_d01_1979-12-01_00:00:00 /home/lluis/PY /home/lluis/etudes/WRF_LMDZ/WaquaL/LaTeX/NPv31_hgardfou/figs 0 None 0
3## e.g. # lmdz_check.bash -1:9:9:4 iphysiq1_time_step150/wrfout_d01_check.nc /home/lfita/PY iphysiq1_time_step150/check 1 None 0
4if test $1 = '-h'; then
5  echo "**********************************"
6  echo "***   Shell script to analyze  ***"
7  echo "*** LMDZ runs at a given point ***"
8  echo "**********************************"
9  echo "lmdz_check.bash [point](as Time:z:y:x, -1 last value) [infile] [pyhome] \
10    (place with pthon scripts) [ofold](output folder) [getvals](0, no; 1: yes, \
11    whether to compute intermediary files) [mapv](None, no; map characteristics:[proj],[res])"
12  echo "  [point]: as Time:z:y:x, (-1 for last value, python style (0 based))"
13  echo "  [infile]: file to use"
14  echo "  [pyhome]: place with pthon scripts"
15  echo "  [ofold]: output folder"
16  echo "  [getvals]: 0, no; 1: yes, whether to compute intermediary files"
17  echo "  [mapv]: None, no; map characteristics:[proj],[res]"
18  echo "  [visualize]: 0, no; 1: yes, whether to visualize results"
19else
20
21function vals_textab() {
22# Function to provide an LaTeX like table from a series of ':' separated values
23#   values= list of values
24#   ncols= number of columns
25#   labels= which labels
26#     'inum': integer ascending numbers
27#     'labs@'[labels]: as a list of given ':' separated labels
28#   caption= text as caption '*' for spaces
29#   tablabel= text as label of the table
30
31# Output in `vals_textab.tex' as:
32#   A LaTeX table as \verb+[ilabel]:+ & [ivalue] & ... & [Ncol]
33  errmsg='ERROR -- error -- ERROR -- error'
34  fname='vals_textab'
35
36  values=$1
37  ncols=$2
38  labels=$3
39  caption=$4
40  tablabel=$5
41
42  vals=`echo ${values} | tr ':' ' '`
43  cap=`echo ${caption} | tr '*' ' '`
44
45  Nvals=`echo ${vals} | wc -w | awk '{print $1}'`
46
47  ofile='vals_textab.tex'
48
49  icol=1
50  tabfmt=''
51  while test ${icol} -le ${ncols}; do
52    tabfmt=${tabfmt}'lc'
53    icol=`expr ${icol} + 1`
54  done
55
56  labk=${labels:0:4}
57  case ${labk} in
58    'inum')
59      in=1
60      while test ${in} -le ${Nvals}; do
61        labvals=${labvals}${in}':'
62        in=`expr ${in} + 1`
63      done
64    ;;
65    'labs')
66      labvals=`echo ${labels} | tr '@' ' ' | awk '{print $2}'`
67    ;;
68    *)
69      echo ${errmsg}
70      echo "  "${fname}": kind of labels '"${labk}"' not ready!!"
71      exit
72    ;;
73  esac
74
75  cat << EOF > ${ofile}
76\\begin{table}
77\\caption{${cap}}
78\\label{tab:${tablabel}}
79\\begin{center}
80\\begin{tabular}{${tabfmt}}
81EOF
82  Nmultivalscols=`expr ${Nvals} % ${ncols}`
83  if test ${Nmultivalscols} -ne 0; then
84    Nvals0=`expr ${Nvals} - ${Nmultivalscols}`
85  else
86    Nvals0=${Nvals}
87  fi
88
89  ival=1
90  line=''
91
92  while test ${ival} -le ${Nvals}; do
93    modival=`expr ${ival} % ${ncols}`
94    vali=`echo ${values} | tr ':' '\n' | head -n ${ival} | tail -n 1`
95    labi=`echo ${labvals} | tr ':' '\n' | head -n ${ival} | tail -n 1`
96
97    if test ${modival} -eq 0; then
98      line=${line}'\verb+'${labi}':+ & '${vali}' \\ '
99      echo ${line} >> ${ofile}
100      line=''
101    else
102      line=${line}'\verb+'${labi}':+ & '${vali}' & '
103    fi
104
105    ival=`expr ${ival} + 1`
106  done
107
108  if test ${Nmultivalscols} -ne 0; then
109    Nemptycols=`expr ${ncols} - ${Nmultivalscols}`
110    if test ${Nemptycols} -ne 0; then
111      iecol=1
112      while test ${iecol} -lt ${Nemptycols}; do
113        line=${line}' & & '
114        iecol=`expr ${iecol} + 1`
115      done
116    fi
117    line=${line}' & \\ '
118    echo ${line} >> ${ofile}
119  fi
120
121  cat << EOF >> ${ofile}
122\\end{tabular}
123\\end{center}
124\\end{table}
125EOF
126
127  return
128}
129
130function to_LaTeX() {
131#   Function to transform an ASCII to LaTeX
132    asc=$1
133
134# Characters to find ('\' must be de first)
135    findchars='\\:_:%:&'
136
137# ASCII chains to substitue with
138    substchars='\backslash:\_:\%:\&'
139
140    fchars=`echo ${findchars} | tr ':' ' '`
141
142    foundv=0
143    for chv in ${fchars}; do
144      found=`expr index ${asc} ${chv}`
145      if test ${found} -ne 0; then 
146        foundv=1
147        break
148      fi
149    done
150
151    if test ${foundv} -eq 0; then 
152      echo ${asc}
153      return 
154    fi 
155
156    ich=1
157    newasc=''
158
159    Lasc=`expr length ${asc}`
160    partasc=${asc}
161    for chv in ${fchars}; do
162      Lpartasc=${Lasc}
163      while test ${Lpartasc} -gt 0; do
164        found=`expr index ${partasc} ${chv}`
165        if test ${found} -ne 0; then
166          newpart=`echo ${partasc} | tr ${chv} ' ' | awk '{print $1}'`
167          Lnewpart=`expr length ${newpart}`
168          Lnewpart1=`expr ${Lnewpart} + 1`
169          Lwithoutnewpart=`expr ${Lpartasc} - ${Lnewpart} - 1`
170          partasc=${partasc:${Lnewpart1}:${Lwithoutnewpart}}
171          newchar=`echo ${substchars} | tr ':' '\n' | head -n ${ich} | tail -n 1`
172          newasc=${newasc}${newpart}${newchar}
173          Lpartasc=`expr length ${partasc}`
174        else
175          Lnewpart=`expr length ${newpart}'0'`
176          if test ${Lnewpart} -gt 1; then
177            newasc=${newasc}${partasc}
178          fi
179          Lpartasc=-1
180          Lnewasc=`expr length ${newasc}'0'`
181          if test ${Lnewpart} -eq 1; then
182            partasc=${asc}
183          else
184            partasc=${newasc}
185          fi
186          newpart=''
187        fi
188      done
189      Lpartasc=`expr length ${newasc}`
190      ich=`expr ${ich} + 1`
191    done
192    echo ${newasc}
193
194    return
195}
196
197####### ###### ##### #### ### ## #
198
199  rootsh=`pwd`
200  errmsg='ERROR -- error -- ERROR -- error'
201  main='lmdz_check.bash'
202
203  point=$1
204  infile=$2
205  PYHOME=$3
206  ofold=$4
207  getvals=$5
208  mapv=$6
209  vis=$7
210
211# To paint figures
212  draw=0
213
214# To generate Hovmoller graph
215  dohov=1
216
217# To generate point graph
218  dopt=1
219
220# To generate horizontal graph
221  dohor=1
222
223# To generate neighbourghood evol graph
224  doneig=1
225
226# To generate LaTeX
227  dolatex=1
228
229  vartypes='dt:st:sfc'
230
231  dtvariables='AJS:CON:DYN:EVA:LSCST:LSCTH:LSC:PHY:THE:VDF:WAK'
232  stvariables='QVAPOR:QCLOUD:LGEOP:LTEMP:LVITU:LVITV:LVITW:LRHUM:LH2O:LPR_CON_I:'
233  stvariables=${stvariables}'LPR_CON_L:LPR_LSC_I:LPR_LSC_L:LLWCON:LIWCON:LPTCONV:'
234  stvariables=${stvariables}'LVPRECIP:LRNEB:LRNEBCON:LRNEBLS:LTKE:LWAKE_OMG:'
235  stvariables=${stvariables}'LWAKE_DELTAQ:LWAKE_DELTAT'
236  sfcvariables='LSNOW:LEVAP:LPRECIP:LPLUC:LPLUL:LRH2M:T2:U10:V10:LCLDL:LCLDM:'
237  sfcvariables=${sfcvariables}'LCLDH:PSFC:LS_PBLH:LS_PBLT:LS_LCL:LZMAX_TH'
238
239  kvalues='2dh:hovz:tevol'
240
241  filetexn='lmdz_check.tex'
242  otex=${ofold}'/'${filetexn}
243####### ###### ##### #### ### ## #
244# Levels to interpolate
245  plevels='100000.,97500.,95000.,92500.,90000.,85000.,80000.,75000.,70000.,'
246  plevels=${plevels}'65000.,60000.,55000.,50000.,45000.,40000.,35000.,30000.,'
247  plevels=${plevels}'25000.,20000.,15000.,10000.,5000.,2500.,1000.,'
248  plevels=${plevels}'500.,250.'
249
250  tval=`echo ${point} | tr ':' ' ' | awk '{print $1}'`
251  zval=`echo ${point} | tr ':' ' ' | awk '{print $2}'`
252  yval=`echo ${point} | tr ':' ' ' | awk '{print $3}'`
253  xval=`echo ${point} | tr ':' ' ' | awk '{print $4}'`
254
255  infileS=`echo ${infile} | tr '.' ' ' | awk '{print $1}'`
256
257#######    #######
258## MAIN
259    #######
260  mkdir -p ${ofold}
261
262  vtypes=`echo ${vartypes} | tr ':' ' '`
263  kvals=`echo ${kvalues} | tr ':' ' '`
264
265# All variables
266  allvars0=''
267
268  for vt in ${vtypes}; do
269    case $vt in
270      'dt' )
271        var0s=`echo ${dtvariables} | tr ':' ' '`
272        for var0 in $var0s; do
273          allvars0=${allvars0}'LDQ'${var0}',LDT'${var0}','
274          if test ${var0} = 'CON' || test ${var0} = 'DYN' || test ${var0} = 'VDF'; then
275            allvars0=${allvars0}'LDU'${var0}',LDV'${var0}','
276          fi
277        done
278      ;;
279      'sfc' )
280        var0s=`echo ${sfcvariables} | tr ':' ' '`
281        for var0 in $var0s; do
282          allvars0=${allvars0}${var0}','
283        done
284      ;;
285      'st' )
286        var0s=`echo ${stvariables} | tr ':' ' '`
287        for var0 in $var0s; do
288          allvars0=${allvars0}${var0}','
289        done
290      ;;
291    esac
292  done
293  Lallvars0=`expr length ${allvars0}`
294  Lallvars01=`expr ${Lallvars0} - 1`
295  allvars=${allvars0:0:${Lallvars01}}
296  echo "all vars: '"${allvars}"'"
297
298  if test ${getvals} -eq 1; then
299    for kvn in ${kvals}; do
300      echo "  kind of values: "${kvn}
301      case $kvn in
302        '2dh')
303          pyvls='Time,'${tval}','${tval}',1@bottom_top,'${zval}','${zval}',1'
304        ;;
305        'hovz')
306          pyvls='south_north,'${yval}','${yval}',1@west_east,'${xval}','${xval}',1'
307        ;;
308        'tevol')
309          pyvls='bottom_top,'${zval}','${zval}',1@south_north,'${yval}','${yval}
310          pyvls=${pyvls}',1@west_east,'${xval}','${xval}',1'
311        ;;
312      esac
313      ofile=`python ${PYHOME}/nc_var.py -o DataSetSection_multidims -f ${infile}     \
314        -S ${pyvls} | grep succesfull | awk '{print $6}' | tr '"' ' '`
315      if test $? -ne 0; then
316        echo ${errmsg}
317        echo "  "${main}": python failed!"
318        echo "    python "${HOME}/nc_var.py -o DataSetSection_multidims              \
319          -f ${infile} -S ${pyvls}
320        exit
321      fi
322      case $kvn in
323        '2dh')
324# Adding CF longitudes and latitudes
325          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFlonlat_creation            \
326            -S longitude,latitude -v XLONG,XLAT
327        ;;
328        'tevol')
329# Adding CF time
330          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFtime_creation              \
331            -S 19491201000000,hours -v time
332        ;;
333        'hovz')
334# Adding CF time
335          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFtime_creation              \
336            -S 19491201000000,hours -v time
337# Adding variable dimension from 'bottom_top'
338          python ${PYHOME}/nc_var.py -f ${ofile} -o dimVar_creation -S bottom_top
339# Vertical interpolation
340#          dvals='T:Time,Z:bottom_top,Y:south_north,X:west_east'
341#          python ${PYHOME}/vertical_interpolation.py -f ${ofile} -o WRFp             \
342#            -i ${plevels} -k 'lin' -v ${allvars} -d ${dvals}                         \
343#            -D T:Times,Z:ZNU,Y:XLAT,X:XLONG
344#          if test $? -ne 0; then
345#            echo ${errormsg}
346#            echo "  "${main}": drawing.py fails!"
347#            echo python ${PYHOME}/vertical_interpolation.py -f ${ofile} -o WRFp \
348#             -i ${plevels} -k 'lin' -v ${allvars} -d ${dvals} \
349#             -D T:Times,Z:ZNU,Y:XLAT,X:XLONG
350#            exit
351#          fi
352#          ofilen0=`echo ${ofile} | tr '.' ' ' | awk '{print $1}'`
353#          mv vertical_interpolation_WRFp.nc ${ofilen0}_WRFp.nc
354        ;;
355      esac
356    done
357  fi
358
359#exit
360  if test $draw -eq 1; then
361  echo "Drawing..."
362  mkdir -p ${ofold}/figs
363
364  for vt in ${vtypes}; do
365    echo "variable type: "${vt}
366    case $vt in
367      'dt' )
368        var0s=`echo ${dtvariables} | tr ':' ' '`
369        vars=''
370        for var0 in $var0s; do
371          vars=${vars}'LDQ'${var0}' LDT'${var0}' '
372          if test ${var0} = 'CON' || test ${var0} = 'DYN' || test ${var0} = 'VDF'; then
373            vars=${vars}'LDU'${var0}' LDV'${var0}' '
374          fi
375        done
376      ;;
377      'sfc' )
378        vars=`echo ${sfcvariables} | tr ':' ' '`
379      ;;
380      'st' )
381        vars=`echo ${stvariables} | tr ':' ' '`
382      ;;
383    esac
384    echo ${vars}
385    for var in ${vars}; do
386      echo "  var: "${var}
387      varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} | grep all_values`
388      if test $? -ne 0; then
389        echo "  "${main}": Variable '"${var}"' not defined !!!!"
390        exit
391      fi
392      stdn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
393      cbar=`echo ${varvals} | tr ',' ' ' | awk '{print $9}'`
394      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
395      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
396
397      if test $dohov -eq 1 && ! test ${vt} = 'sfc'; then
398# Shadded vertical Hovmoller diagrams
399      filetail='south_north_B'${yval}'-E'${yval}'-I1_west_east_B'${xval}
400      filetail=${filetail}'-E'${xval}'-I1'
401
402# Let's make it easy
403      if test ${vt} = 'st';then
404        min='Saroundminmax@0.97'
405        max='Saroundminmax@0.97'
406      else
407        min='Spercentile@1'
408        max='Spercentile@1'
409      fi
410
411      if test ${var} = 'LDQEVA' || test ${var} = 'LDTEVA' || test ${var} = 'LH2O';then
412        min='Saroundminmax@0.75'
413        max='Saroundminmax@0.75'
414        if test ${var} = 'LDQEVA'; then
415          cbar='Reds'
416        else
417          cbar='Blues'
418        fi
419      fi
420
421      echo "    min: "${min}" max: "${max}
422
423      values=${stdn}':Time|-1,bottom_top|-1:varDIMbottom_top:time:'${cbar}':'
424      values=${values}${min}','${max}':vertical|temporal|evolution|:pdf:'
425      values=${values}'transpose:time|hours!since!1949-12-01|exct,12,h|'
426      values=${values}'$%d^{%H}$|date!($[DD]^{[HH]}$)|x:True'
427
428      python ${PYHOME}/drawing.py -o draw_2D_shad_time -f ${infileS}_${filetail}.nc   \
429        -S ${values} -v ${var},time
430      if test $? -ne 0; then
431        echo ${errormsg}
432        echo "  "${main}": drawing.py fails!"
433        echo python ${PYHOME}/drawing.py -o draw_2D_shad_time \
434          -f ${infileS}_${filetail}.nc -S ${values} -v ${var},time
435        exit
436      else
437        mv 2Dfields_shadow_time.pdf ${ofold}/figs/${stdn}_Hovmoller.pdf
438        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_Hovmoller.pdf & fi
439      fi
440      fi
441     
442      if test $dopt -eq 1; then
443# Point evolution
444      filetail='bottom_top_B'${zval}'-E'${zval}'-I1_south_north_B'${yval}'-E'
445      filetail=${filetail}${yval}'-I1_west_east_B'${xval}'-E'${xval}'-I1'
446
447      values=${stdn}':time|($[DD]^{[HH]}$):exct,12,h:$%d^{%H}$:time|evolution|at'
448      values=${values}'|(x='${xval}',y='${yval}',z='${zval}'):1:pdf'
449      python ${PYHOME}/drawing.py -o draw_timeSeries -f ${infileS}_${filetail}.nc     \
450        -S ${values} -v ${var},time
451      if test $? -ne 0; then
452        echo ${errormsg}
453        echo "  "${main}": drawing.py fails!"
454        echo python ${PYHOME}/drawing.py -o draw_timeSeries \
455          -f ${infileS}_${filetail}.nc -S ${values} -v ${var},time
456        exit
457      else
458        mv TimeSeries_${stdn}.pdf ${ofold}/figs/${stdn}_TimeSeries.pdf
459        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_TimeSeries.pdf & fi
460      fi
461      fi
462
463      if test $dohor -eq 1; then
464# Horizontal plot
465      filetail='Time_B'${tval}'-E'${tval}'-I1_bottom_top_B'${zval}
466      filetail=${filetail}'-E'${zval}'-I1'
467
468      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
469      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
470
471      if test ${vt} = 'dt'; then
472        min='Spercentile@1'
473        max='Spercentile@1'
474      elif test ${vt} = 'st'; then
475        min='Saroundminmax@0.97'
476        max='Saroundminmax@0.97'
477      fi
478
479      if test ${var} = 'LRH2M'; then
480        max='100.'
481      elif test ${var} = 'T2'; then
482        min='270'
483        max='300.'
484      fi
485
486      echo "    min: "${min}" max: "${max}
487
488      values=${stdn}':south_north|-1,west_east|-1:longitude:latitude:'${cbar}':'
489      values=${values}${min}','${max}':horizontal|section|at|(t='${tval}
490      values=${values}',z='${zval}'):pdf:None:'${mapv}':True'
491
492      python ${PYHOME}/drawing.py -o draw_2D_shad -f ${infileS}_${filetail}.nc        \
493        -S ${values} -v ${var}
494      if test $? -ne 0; then
495        echo ${errormsg}
496        echo "  "${main}": drawing.py fails!"
497        echo python ${PYHOME}/drawing.py -o draw_2D_shad \
498          -f ${infileS}_${filetail}.nc -S ${values} -v ${var}
499        exit
500      else
501        mv 2Dfields_shadow.pdf ${ofold}/figs/${stdn}_hor.pdf
502        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_hor.pdf & fi
503      fi
504      fi
505
506      if test $doneig -eq 1; then
507# Neighbourghood plot
508      filetail=''
509
510      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
511      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
512
513      if test ${vt} = 'dt'; then
514        min='Spercentile@1'
515        max='Spercentile@1'
516      elif test ${vt} = 'st'; then
517        min='Saroundminmax@0.97'
518        max='Saroundminmax@0.97'
519      fi
520
521      if test ${var} = 'LRH2M'; then
522        max='100.'
523      elif test ${var} = 'T2'; then
524        min='270'
525        max='300.'
526      fi
527
528      echo "    min: "${min}" max: "${max}
529
530      values=${stdn}':Time|-1|Times,bottom_top|'${zval}'|ZNU,south_north|'${yval}
531      values=${values}'|XLAT,west_east|'${xval}'|XLONG:south_north,west_east:5:auto:'
532#      values=${values}'time|($[DD]^{[HH]}$),time|($[DD]^{[HH]}$):exct,2,h|exct,1,d:'
533#      values=${values}'$%d^{%H}$,$%d^{%H}$:5|pts|neighbourghood|temporal|evolution:'
534      values=${values}'time|([MI]),time|($[DD]^{[HH]-[MI]}$):exct,2,i|exct,30,i:'
535      values=${values}'$%M$,$%d^{%H-%M}$:5|pts|neighbourghood|temporal|evolution:'
536      values=${values}${min}','${max}':'${cbar}':pdf:False'
537
538      python ${PYHOME}/drawing.py -o draw_Neighbourghood_evol -f ${infile}           \
539        -S ${values} -v ${var}
540      if test $? -ne 0; then
541        echo ${errormsg}
542        echo "  "${main}": drawing.py fails!"
543        echo python ${PYHOME}/drawing.py -o draw_Neighbourghood_evol \
544          -f ${infile} -S ${values} -v ${var}
545        exit
546      else
547        mv Neighbourghood_evol.pdf ${ofold}/figs/${stdn}_Neighbourghood_evol.pdf
548        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_Neighbourghood_evol.pdf & fi
549      fi
550      fi
551
552#      exit
553    done
554  done
555  fi
556
557# LaTeX file generation
558##
559#
560  if test $dolatex -eq 1; then
561  echo "  LaTeX file '"${otex}"' generation..."
562
563# Vertical pressure values
564  dvals='Time:-9|bottom_top:-1|south_north:'${yval}'|west_east:'${xval}
565  pvals=`python ${PYHOME}/nc_var.py -o varout -f ${infile} -S ${dvals} -v LPRES | awk '{print $2}'`
566  presvals=`echo ${pvals} | tr ' ' ':'`
567  vals_textab ${presvals} 3 inum 'level*pressure*(Pa)*equivalencies' pres_vals
568
569  if test ${tval} -eq -1; then tvalS='last'; fi
570
571  cat << EOF > ${otex}
572\\documentclass{article}
573\\usepackage{graphicx}
574\\usepackage[colorlinks=true,urlcolor=blue]{hyperref}
575
576\\textwidth=18cm
577\\textheight=23cm
578\\oddsidemargin=-1cm
579\\evensidemargin=-1cm
580\\topmargin=-1cm
581
582\\begin{document}
583
584\\title{checking LMDZ at time=${tval}, z=${zval}, y=${yval}, x=${xval}}
585\\author{}
586
587\\maketitle
588
589\\listoffigures
590\\newpage
591
592EOF
593  cat vals_textab.tex >> ${otex}
594
595  cat << EOF >> ${otex}
596
597\\clearpage
598
599EOF
600
601  for vt in ${vtypes}; do
602    echo "variable type: "${vt}
603    case $vt in
604      'dt' )
605        vars=`echo ${dtvariables} | tr ':' ' '`
606        ivar=1
607        for var in ${vars}; do
608          varL=`to_LaTeX ${var}`
609          varvals=`python ${PYHOME}/drawing.py -o variable_values -S LDQ${var} \
610            | grep all_values`
611#          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
612          varn=`echo ${var} | tr '[:upper:]' '[:lower:]'`
613          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
614          echo "    var: "${varn}
615
616          cat << EOF >> ${otex}
617% d[q/t]_${varn}
618%%
619
620\\begin{figure}
621\\begin{center}
622\\begin{tabular}{cc}
623\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_hor}
624&
625\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_hor}
626\\\\
627\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_Hovmoller}
628&
629\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_Hovmoller}
630\\\\
631\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_TimeSeries}
632&
633\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_TimeSeries}
634\\\\
635\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_Neighbourghood_evol}
636&
637\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_Neighbourghood_evol}
638\\end{tabular}
639EOF
640          if test ${ivar} -eq 1; then
641            firstvar=${varn}
642            caption='\caption{Instantaneaous value at time='${tvalS}', z='${zval}
643            caption=${caption}' level of humidity tendency due to '${varn}' ['${varL}'] (top left)'
644            caption=${caption}', thermal tendency (top right), temporal evolution of '
645            caption=${caption}'the vertical profile at yval='${yval}', xval='${xval}
646            caption=${caption}'humidity tendency (2nd row left), thermal tendency '
647            caption=${caption}'(2nd row right), temporal evolution at the given point'
648            caption=${caption}' (3rd row), evolution of a box of 5x5 centered on the '
649            caption=${caption}'point (bottom)}'
650          else
651            caption='\caption{As in figure \ref{fig:d_qt_'${firstvar}'}, but for '
652            caption=${caption}${varn}' ['${varL}']}'
653          fi
654          cat << EOF >> ${otex}
655${caption}
656\\label{fig:d_qt_${varn}}
657\\end{center}
658\\end{figure}
659\\clearpage
660EOF
661# LD[U/V]
662##
663          if test ${var} = 'CON' || test ${var} = 'DYN' || test ${var} = 'VDF'; then
664            varvals=`python ${PYHOME}/drawing.py -o variable_values -S LDU${var} \
665              | grep all_values`
666#          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
667            varn=`echo ${var} | tr '[:upper:]' '[:lower:]'`
668            ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
669            echo "    var: "${varn}
670
671            cat << EOF >> ${otex}
672% d[u/v]_${varn}
673%%
674
675\\begin{figure}
676\\begin{center}
677\\begin{tabular}{cc}
678\\includegraphics[height=0.2\\textheight]{figs/du${varn}_hor}
679&
680\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_hor}
681\\\\
682\\includegraphics[height=0.2\\textheight]{figs/du${varn}_Hovmoller}
683&
684\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_Hovmoller}
685\\\\
686\\includegraphics[height=0.2\\textheight]{figs/du${varn}_TimeSeries}
687&
688\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_TimeSeries}
689\\\\
690\\includegraphics[height=0.2\\textheight]{figs/du${varn}_Neighbourghood_evol}
691&
692\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_Neighbourghood_evol}
693\\end{tabular}
694EOF
695            caption='\caption{As in figure \ref{fig:d_qt_'${firstvar}'}, but for '
696            caption=${caption}${varn}'[ '${varL}']}'
697            cat << EOF >> ${otex}
698${caption}
699\\label{fig:d_qu_${varn}}
700\\end{center}
701\\end{figure}
702\\clearpage
703EOF
704          fi
705          ivar=`expr ${ivar} + 1`
706        done
707cat << EOF >> ${otex}
708\\clearpage
709EOF
710      ;;
711      'sfc' )
712        vars=`echo ${sfcvariables} | tr ':' ' '`
713        ivar=1
714        for var in ${vars}; do
715          varL=`to_LaTeX ${var}`
716          varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} \
717            | grep all_values`         
718          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
719          echo "    var: "${varn}
720          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
721          cat << EOF >> ${otex}
722% ${varn}
723%%
724
725\\begin{figure}
726\\begin{center}
727\\begin{tabular}{ccc}
728\\includegraphics[width=0.33\\textwidth]{figs/${varn}_hor}
729&
730\\includegraphics[width=0.33\\textwidth]{figs/${varn}_TimeSeries}
731&
732\\includegraphics[width=0.33\\textwidth]{figs/${varn}_Neighbourghood_evol}
733\\end{tabular}
734EOF
735          if test ${ivar} -eq 1; then
736            firstvar=${varn}
737            caption='\caption{Instantaneaous value at time='${tvalS}' of '${varn}
738            caption=${caption}' ['${varL}'] (left), temporal evolution at the given point'
739            caption=${caption}' (middle), evolution of a box of 5x5 centered on the '
740            caption=${caption}'point (right)}'
741          else
742             caption='\caption{As in figure \ref{fig:state_'${firstvar}'}, but for '
743             caption=${caption}${varn}' ['${varL}']}'
744          fi
745          cat << EOF >> ${otex}
746${caption}
747\\label{fig:state_${varn}}
748\\end{center}
749\\end{figure}
750EOF
751          modivar=`expr ${ivar} % 3`
752          if test ${modivar} -eq 0; then
753            echo "\\clearpage" >> ${otex}
754          fi
755          ivar=`expr ${ivar} + 1`
756        done
757cat << EOF >> ${otex}
758\\clearpage
759EOF
760      ;;
761      'st' )
762        vars=`echo ${stvariables} | tr ':' ' '`
763        ivar=1
764        for var in ${vars}; do
765          varL=`to_LaTeX ${var}`
766          varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} \
767            | grep all_values`         
768          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
769          echo "    var: "${varn}
770          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
771          cat << EOF >> ${otex}
772% ${varn}
773%%
774
775\\begin{figure}
776\\begin{center}
777\\begin{tabular}{cc}
778\\includegraphics[width=0.5\\textwidth]{figs/${varn}_hor}
779&
780\\includegraphics[width=0.5\\textwidth]{figs/${varn}_Hovmoller}
781\\\\
782\\includegraphics[width=0.5\\textwidth]{figs/${varn}_TimeSeries}
783&
784\\includegraphics[width=0.5\\textwidth]{figs/${varn}_Neighbourghood_evol}
785\\end{tabular}
786EOF
787          if test ${ivar} -eq 1; then
788            firstvar=${varn}
789            caption='\caption{Instantaneaous value at time='${tvalS}', z='${zval}
790            caption=${caption}' level of '${varn}' ['${varL}'] (top left), temporal evolution of the'
791            caption=${caption}' vertical profile at yval='${yval}', xval='${xval}
792            caption=${caption}' (top right), temporal evolution at the given point '
793            caption=${caption}' (bottom left), evolution of a box of 5x5 centered on the '
794            caption=${caption}'point (bottom right)}'
795          else
796             caption='\caption{As in figure \ref{fig:state_'${firstvar}'}, but for '
797             caption=${caption}${varn}' ['${varL}']}'
798          fi
799          cat << EOF >> ${otex}
800${caption}
801\\label{fig:state_${varn}}
802\\end{center}
803\\end{figure}
804\\clearpage
805EOF
806
807          ivar=`expr ${ivar} + 1`
808        done
809cat << EOF >> ${otex}
810\\clearpage
811EOF
812      ;;
813    esac
814  done
815
816  cat << EOF >> ${otex}
817\\end{document}
818EOF
819  otexn=`echo ${filetexn} | tr '.' ' ' | awk '{print $1}'`
820  cd ${ofold}
821  pdflatex ${otexn}
822  pdflatex ${otexn}
823  pdflatex ${otexn}
824  pdflatex ${otexn}
825  evince ${otexn}.pdf &
826  cd ${rootsh}
827  fi
828fi
829
Note: See TracBrowser for help on using the repository browser.