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

Last change on this file since 523 was 255, checked in by lfita, 10 years ago

Fixing 'WAKE_H' name is 'LWAKE_H'

  • Property svn:executable set to *
File size: 25.1 KB
Line 
1#!/bin/bash
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=1
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:LTHETA: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:LDTSW0:LDTLWR:'
236  stvariables=${stvariables}'LQ_TH:LLAMBDA_TH:LTNT:LTNTC:LTNTR:LTNTSCPBL'
237  sfcvariables='LSNOW:LEVAP:LPRECIP:LPLUC:LPLUL:LRH2M:T2:LRH2M:U10:V10:LPBASE:'
238  sfcvariables=${sfcvariables}'LFBASE:LCLDL:LCLDM:LPLCL:LPLFC:'
239  sfcvariables=${sfcvariables}'LCLDH:PSFC:LS_PBLH:LS_PBLT:LS_LCL:LZMAX_TH:'
240  sfcvariables=${sfcvariables}'LWAKE_H:LWAKE_S'
241
242  kvalues='2dh:hovz:tevol'
243
244  filetexn='lmdz_check.tex'
245  otex=${ofold}'/'${filetexn}
246####### ###### ##### #### ### ## #
247# Levels to interpolate
248  plevels='100000.,97500.,95000.,92500.,90000.,85000.,80000.,75000.,70000.,'
249  plevels=${plevels}'65000.,60000.,55000.,50000.,45000.,40000.,35000.,30000.,'
250  plevels=${plevels}'25000.,20000.,15000.,10000.,5000.,2500.,1000.,'
251  plevels=${plevels}'500.,250.'
252
253  tval=`echo ${point} | tr ':' ' ' | awk '{print $1}'`
254  zval=`echo ${point} | tr ':' ' ' | awk '{print $2}'`
255  yval=`echo ${point} | tr ':' ' ' | awk '{print $3}'`
256  xval=`echo ${point} | tr ':' ' ' | awk '{print $4}'`
257
258  infileS=`echo ${infile} | tr '.' ' ' | awk '{print $1}'`
259
260#######    #######
261## MAIN
262    #######
263  mkdir -p ${ofold}
264
265  vtypes=`echo ${vartypes} | tr ':' ' '`
266  kvals=`echo ${kvalues} | tr ':' ' '`
267
268# All variables
269  allvars0=''
270
271  for vt in ${vtypes}; do
272    case $vt in
273      'dt' )
274        var0s=`echo ${dtvariables} | tr ':' ' '`
275        for var0 in $var0s; do
276          allvars0=${allvars0}'LDQ'${var0}',LDT'${var0}','
277          if test ${var0} = 'CON' || test ${var0} = 'DYN' || test ${var0} = 'VDF'; then
278            allvars0=${allvars0}'LDU'${var0}',LDV'${var0}','
279          fi
280        done
281      ;;
282      'sfc' )
283        var0s=`echo ${sfcvariables} | tr ':' ' '`
284        for var0 in $var0s; do
285          allvars0=${allvars0}${var0}','
286        done
287      ;;
288      'st' )
289        var0s=`echo ${stvariables} | tr ':' ' '`
290        for var0 in $var0s; do
291          allvars0=${allvars0}${var0}','
292        done
293      ;;
294    esac
295  done
296  Lallvars0=`expr length ${allvars0}`
297  Lallvars01=`expr ${Lallvars0} - 1`
298  allvars=${allvars0:0:${Lallvars01}}
299  echo "all vars: '"${allvars}"'"
300
301  if test ${getvals} -eq 1; then
302    for kvn in ${kvals}; do
303      echo "  kind of values: "${kvn}
304      case $kvn in
305        '2dh')
306          pyvls='Time,'${tval}','${tval}',1@bottom_top,'${zval}','${zval}',1'
307        ;;
308        'hovz')
309          pyvls='south_north,'${yval}','${yval}',1@west_east,'${xval}','${xval}',1'
310        ;;
311        'tevol')
312          pyvls='bottom_top,'${zval}','${zval}',1@south_north,'${yval}','${yval}
313          pyvls=${pyvls}',1@west_east,'${xval}','${xval}',1'
314        ;;
315      esac
316      ofile=`python ${PYHOME}/nc_var.py -o DataSetSection_multidims -f ${infile}     \
317        -S ${pyvls} | grep succesfull | awk '{print $6}' | tr '"' ' '`
318      if test $? -ne 0; then
319        echo ${errmsg}
320        echo "  "${main}": python failed!"
321        echo "    python "${HOME}/nc_var.py -o DataSetSection_multidims              \
322          -f ${infile} -S ${pyvls}
323        exit
324      fi
325      case $kvn in
326        '2dh')
327# Adding CF longitudes and latitudes
328          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFlonlat_creation            \
329            -S longitude,latitude -v XLONG,XLAT
330        ;;
331        'tevol')
332# Adding CF time
333          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFtime_creation              \
334            -S 19491201000000,hours -v time
335        ;;
336        'hovz')
337# Adding CF time
338          python ${PYHOME}/nc_var.py -f ${ofile} -o WRF_CFtime_creation              \
339            -S 19491201000000,hours -v time
340# Adding variable dimension from 'bottom_top'
341          python ${PYHOME}/nc_var.py -f ${ofile} -o dimVar_creation -S bottom_top
342# Vertical interpolation
343#          dvals='T:Time,Z:bottom_top,Y:south_north,X:west_east'
344#          python ${PYHOME}/vertical_interpolation.py -f ${ofile} -o WRFp             \
345#            -i ${plevels} -k 'lin' -v ${allvars} -d ${dvals}                         \
346#            -D T:Times,Z:ZNU,Y:XLAT,X:XLONG
347#          if test $? -ne 0; then
348#            echo ${errormsg}
349#            echo "  "${main}": drawing.py fails!"
350#            echo python ${PYHOME}/vertical_interpolation.py -f ${ofile} -o WRFp \
351#             -i ${plevels} -k 'lin' -v ${allvars} -d ${dvals} \
352#             -D T:Times,Z:ZNU,Y:XLAT,X:XLONG
353#            exit
354#          fi
355#          ofilen0=`echo ${ofile} | tr '.' ' ' | awk '{print $1}'`
356#          mv vertical_interpolation_WRFp.nc ${ofilen0}_WRFp.nc
357        ;;
358      esac
359    done
360  fi
361
362#exit
363  if test $draw -eq 1; then
364  echo "Drawing..."
365  mkdir -p ${ofold}/figs
366
367  for vt in ${vtypes}; do
368    echo "variable type: "${vt}
369    case $vt in
370      'dt' )
371        var0s=`echo ${dtvariables} | tr ':' ' '`
372        vars=''
373        for var0 in $var0s; do
374          vars=${vars}'LDQ'${var0}' LDT'${var0}' '
375          if test ${var0} = 'CON' || test ${var0} = 'DYN' || test ${var0} = 'VDF'; then
376            vars=${vars}'LDU'${var0}' LDV'${var0}' '
377          fi
378        done
379      ;;
380      'sfc' )
381        vars=`echo ${sfcvariables} | tr ':' ' '`
382      ;;
383      'st' )
384        vars=`echo ${stvariables} | tr ':' ' '`
385      ;;
386    esac
387    echo ${vars}
388    for var in ${vars}; do
389      echo "  var: "${var}
390      varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} | grep all_values`
391      if test $? -ne 0; then
392        echo "  "${main}": Variable '"${var}"' not defined !!!!"
393        exit
394      fi
395      stdn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
396      cbar=`echo ${varvals} | tr ',' ' ' | awk '{print $9}'`
397      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
398      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
399
400      if test $dohov -eq 1 && ! test ${vt} = 'sfc'; then
401# Shadded vertical Hovmoller diagrams
402      filetail='south_north_B'${yval}'-E'${yval}'-I1_west_east_B'${xval}
403      filetail=${filetail}'-E'${xval}'-I1'
404
405# Let's make it easy
406      if test ${vt} = 'st';then
407        min='Saroundminmax@0.97'
408        max='Saroundminmax@0.97'
409      else
410        min='Spercentile@1'
411        max='Spercentile@1'
412      fi
413
414      if test ${var} = 'LDQEVA' || test ${var} = 'LDTEVA' || test ${var} = 'LH2O';then
415        min='Saroundminmax@0.75'
416        max='Saroundminmax@0.75'
417        if test ${var} = 'LDQEVA'; then
418          cbar='Reds'
419        else
420          cbar='Blues'
421        fi
422      fi
423
424      echo "    min: "${min}" max: "${max}
425
426      values=${stdn}':Time|-1,bottom_top|-1:varDIMbottom_top:time:'${cbar}':'
427      values=${values}${min}','${max}':vertical|temporal|evolution|:pdf:'
428      values=${values}'transpose:time|hours!since!1949-12-01|exct,12,h|'
429      values=${values}'$%d^{%H}$|date!($[DD]^{[HH]}$)|x:True'
430
431      python ${PYHOME}/drawing.py -o draw_2D_shad_time -f ${infileS}_${filetail}.nc   \
432        -S ${values} -v ${var},time
433      if test $? -ne 0; then
434        echo ${errormsg}
435        echo "  "${main}": drawing.py fails!"
436        echo python ${PYHOME}/drawing.py -o draw_2D_shad_time \
437          -f ${infileS}_${filetail}.nc -S ${values} -v ${var},time
438        exit
439      else
440        mv 2Dfields_shadow_time.pdf ${ofold}/figs/${stdn}_Hovmoller.pdf
441        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_Hovmoller.pdf & fi
442      fi
443      fi
444     
445      if test $dopt -eq 1; then
446# Point evolution
447      filetail='bottom_top_B'${zval}'-E'${zval}'-I1_south_north_B'${yval}'-E'
448      filetail=${filetail}${yval}'-I1_west_east_B'${xval}'-E'${xval}'-I1'
449
450      values=${stdn}':time|($[DD]^{[HH]}$):exct,12,h:$%d^{%H}$:time|evolution|at'
451      values=${values}'|(x='${xval}',y='${yval}',z='${zval}'):1:pdf'
452      python ${PYHOME}/drawing.py -o draw_timeSeries -f ${infileS}_${filetail}.nc     \
453        -S ${values} -v ${var},time
454      if test $? -ne 0; then
455        echo ${errormsg}
456        echo "  "${main}": drawing.py fails!"
457        echo python ${PYHOME}/drawing.py -o draw_timeSeries \
458          -f ${infileS}_${filetail}.nc -S ${values} -v ${var},time
459        exit
460      else
461        mv TimeSeries_${stdn}.pdf ${ofold}/figs/${stdn}_TimeSeries.pdf
462        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_TimeSeries.pdf & fi
463      fi
464      fi
465
466      if test $dohor -eq 1; then
467# Horizontal plot
468      filetail='Time_B'${tval}'-E'${tval}'-I1_bottom_top_B'${zval}
469      filetail=${filetail}'-E'${zval}'-I1'
470
471      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
472      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
473
474      if test ${vt} = 'dt'; then
475        min='Spercentile@1'
476        max='Spercentile@1'
477      elif test ${vt} = 'st'; then
478        min='Saroundminmax@0.97'
479        max='Saroundminmax@0.97'
480      fi
481
482      if test ${var} = 'LRH2M'; then
483        max='100.'
484      elif test ${var} = 'T2'; then
485        min='270'
486        max='300.'
487      fi
488
489      echo "    min: "${min}" max: "${max}
490
491      values=${stdn}':south_north|-1,west_east|-1:longitude:latitude:'${cbar}':'
492      values=${values}${min}','${max}':horizontal|section|at|(t='${tval}
493      values=${values}',z='${zval}'):pdf:None:'${mapv}':True'
494
495      python ${PYHOME}/drawing.py -o draw_2D_shad -f ${infileS}_${filetail}.nc        \
496        -S ${values} -v ${var}
497      if test $? -ne 0; then
498        echo ${errormsg}
499        echo "  "${main}": drawing.py fails!"
500        echo python ${PYHOME}/drawing.py -o draw_2D_shad \
501          -f ${infileS}_${filetail}.nc -S ${values} -v ${var}
502        exit
503      else
504        mv 2Dfields_shadow.pdf ${ofold}/figs/${stdn}_hor.pdf
505        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_hor.pdf & fi
506      fi
507      fi
508
509      if test $doneig -eq 1; then
510# Neighbourghood plot
511      filetail=''
512
513      min=`echo ${varvals} | tr ',' ' ' | awk '{print $5}'`
514      max=`echo ${varvals} | tr ',' ' ' | awk '{print $6}'`
515
516      if test ${vt} = 'dt'; then
517        min='Spercentile@1'
518        max='Spercentile@1'
519      elif test ${vt} = 'st'; then
520        min='Saroundminmax@0.97'
521        max='Saroundminmax@0.97'
522      fi
523
524      if test ${var} = 'LRH2M'; then
525        max='100.'
526      elif test ${var} = 'T2'; then
527        min='270'
528        max='300.'
529      fi
530
531      echo "    min: "${min}" max: "${max}
532
533      values=${stdn}':Time|-1|Times,bottom_top|'${zval}'|ZNU,south_north|'${yval}
534      values=${values}'|XLAT,west_east|'${xval}'|XLONG:south_north,west_east:5:auto:'
535#      values=${values}'time|($[DD]^{[HH]}$),time|($[DD]^{[HH]}$):exct,2,h|exct,1,d:'
536#      values=${values}'$%d^{%H}$,$%d^{%H}$:5|pts|neighbourghood|temporal|evolution:'
537      values=${values}'time|([MI]),time|($[DD]^{[HH]-[MI]}$):exct,2,i|exct,30,i:'
538      values=${values}'$%M$,$%d^{%H-%M}$:5|pts|neighbourghood|temporal|evolution:'
539      values=${values}${min}','${max}':'${cbar}':pdf:False'
540
541      python ${PYHOME}/drawing.py -o draw_Neighbourghood_evol -f ${infile}           \
542        -S ${values} -v ${var}
543      if test $? -ne 0; then
544        echo ${errormsg}
545        echo "  "${main}": drawing.py fails!"
546        echo python ${PYHOME}/drawing.py -o draw_Neighbourghood_evol \
547          -f ${infile} -S ${values} -v ${var}
548        exit
549      else
550        mv Neighbourghood_evol.pdf ${ofold}/figs/${stdn}_Neighbourghood_evol.pdf
551        if test $vis -eq 1; then evince ${ofold}/figs/${stdn}_Neighbourghood_evol.pdf & fi
552      fi
553      fi
554
555#      exit
556    done
557  done
558  fi
559
560# LaTeX file generation
561##
562#
563  if test $dolatex -eq 1; then
564  echo "  LaTeX file '"${otex}"' generation..."
565
566# Vertical pressure values
567  dvals='Time:-9|bottom_top:-1|south_north:'${yval}'|west_east:'${xval}
568  pvals=`python ${PYHOME}/nc_var.py -o varout -f ${infile} -S ${dvals} -v LPRES | awk '{print $2}'`
569  presvals=`echo ${pvals} | tr ' ' ':'`
570  vals_textab ${presvals} 3 inum 'level*pressure*(Pa)*equivalencies' pres_vals
571
572  if test ${tval} -eq -1; then tvalS='last'; fi
573
574  cat << EOF > ${otex}
575\\documentclass{article}
576\\usepackage{graphicx}
577\\usepackage[colorlinks=true,urlcolor=blue]{hyperref}
578
579\\textwidth=18cm
580\\textheight=23cm
581\\oddsidemargin=-1cm
582\\evensidemargin=-1cm
583\\topmargin=-1cm
584
585\\begin{document}
586
587\\title{checking LMDZ at time=${tval}, z=${zval}, y=${yval}, x=${xval}}
588\\author{}
589
590\\maketitle
591
592\\listoffigures
593\\newpage
594
595EOF
596  cat vals_textab.tex >> ${otex}
597
598  cat << EOF >> ${otex}
599
600\\clearpage
601
602EOF
603
604  for vt in ${vtypes}; do
605    echo "variable type: "${vt}
606    case $vt in
607      'dt' )
608        vars=`echo ${dtvariables} | tr ':' ' '`
609        ivar=1
610        for var in ${vars}; do
611          varL=`to_LaTeX ${var}`
612          varvals=`python ${PYHOME}/drawing.py -o variable_values -S LDQ${var} \
613            | grep all_values`
614#          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
615          varn=`echo ${var} | tr '[:upper:]' '[:lower:]'`
616          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
617          echo "    var: "${varn}
618
619          cat << EOF >> ${otex}
620% d[q/t]_${varn}
621%%
622
623\\begin{figure}
624\\begin{center}
625\\begin{tabular}{cc}
626\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_hor}
627&
628\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_hor}
629\\\\
630\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_Hovmoller}
631&
632\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_Hovmoller}
633\\\\
634\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_TimeSeries}
635&
636\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_TimeSeries}
637\\\\
638\\includegraphics[height=0.2\\textheight]{figs/dq${varn}_Neighbourghood_evol}
639&
640\\includegraphics[height=0.2\\textheight]{figs/dt${varn}_Neighbourghood_evol}
641\\end{tabular}
642EOF
643          if test ${ivar} -eq 1; then
644            firstvar=${varn}
645            caption='\caption{Instantaneaous value at time='${tvalS}', z='${zval}
646            caption=${caption}' level of humidity tendency due to '${varn}' ['${varL}'] (top left)'
647            caption=${caption}', thermal tendency (top right), temporal evolution of '
648            caption=${caption}'the vertical profile at yval='${yval}', xval='${xval}
649            caption=${caption}'humidity tendency (2nd row left), thermal tendency '
650            caption=${caption}'(2nd row right), temporal evolution at the given point'
651            caption=${caption}' (3rd row), evolution of a box of 5x5 centered on the '
652            caption=${caption}'point (bottom)}'
653          else
654            caption='\caption{As in figure \ref{fig:d_qt_'${firstvar}'}, but for '
655            caption=${caption}${varn}' ['${varL}']}'
656          fi
657          cat << EOF >> ${otex}
658${caption}
659\\label{fig:d_qt_${varn}}
660\\end{center}
661\\end{figure}
662\\clearpage
663EOF
664# LD[U/V]
665##
666          if test ${var} = 'CON' || test ${var} = 'DYN' || test ${var} = 'VDF'; then
667            varvals=`python ${PYHOME}/drawing.py -o variable_values -S LDU${var} \
668              | grep all_values`
669#          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
670            varn=`echo ${var} | tr '[:upper:]' '[:lower:]'`
671            ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
672            echo "    var: "${varn}
673
674            cat << EOF >> ${otex}
675% d[u/v]_${varn}
676%%
677
678\\begin{figure}
679\\begin{center}
680\\begin{tabular}{cc}
681\\includegraphics[height=0.2\\textheight]{figs/du${varn}_hor}
682&
683\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_hor}
684\\\\
685\\includegraphics[height=0.2\\textheight]{figs/du${varn}_Hovmoller}
686&
687\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_Hovmoller}
688\\\\
689\\includegraphics[height=0.2\\textheight]{figs/du${varn}_TimeSeries}
690&
691\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_TimeSeries}
692\\\\
693\\includegraphics[height=0.2\\textheight]{figs/du${varn}_Neighbourghood_evol}
694&
695\\includegraphics[height=0.2\\textheight]{figs/dv${varn}_Neighbourghood_evol}
696\\end{tabular}
697EOF
698            caption='\caption{As in figure \ref{fig:d_qt_'${firstvar}'}, but for '
699            caption=${caption}${varn}'[ '${varL}']}'
700            cat << EOF >> ${otex}
701${caption}
702\\label{fig:d_qu_${varn}}
703\\end{center}
704\\end{figure}
705\\clearpage
706EOF
707          fi
708          ivar=`expr ${ivar} + 1`
709        done
710cat << EOF >> ${otex}
711\\clearpage
712EOF
713      ;;
714      'sfc' )
715        vars=`echo ${sfcvariables} | tr ':' ' '`
716        ivar=1
717        for var in ${vars}; do
718          varL=`to_LaTeX ${var}`
719          varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} \
720            | grep all_values`         
721          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
722          echo "    var: "${varn}
723          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
724          cat << EOF >> ${otex}
725% ${varn}
726%%
727
728\\begin{figure}
729\\begin{center}
730\\begin{tabular}{ccc}
731\\includegraphics[width=0.33\\textwidth]{figs/${varn}_hor}
732&
733\\includegraphics[width=0.33\\textwidth]{figs/${varn}_TimeSeries}
734&
735\\includegraphics[width=0.33\\textwidth]{figs/${varn}_Neighbourghood_evol}
736\\end{tabular}
737EOF
738          if test ${ivar} -eq 1; then
739            firstvar=${varn}
740            caption='\caption{Instantaneaous value at time='${tvalS}' of '${varn}
741            caption=${caption}' ['${varL}'] (left), temporal evolution at the given point'
742            caption=${caption}' (middle), evolution of a box of 5x5 centered on the '
743            caption=${caption}'point (right)}'
744          else
745             caption='\caption{As in figure \ref{fig:state_'${firstvar}'}, but for '
746             caption=${caption}${varn}' ['${varL}']}'
747          fi
748          cat << EOF >> ${otex}
749${caption}
750\\label{fig:state_${varn}}
751\\end{center}
752\\end{figure}
753EOF
754          modivar=`expr ${ivar} % 3`
755          if test ${modivar} -eq 0; then
756            echo "\\clearpage" >> ${otex}
757          fi
758          ivar=`expr ${ivar} + 1`
759        done
760cat << EOF >> ${otex}
761\\clearpage
762EOF
763      ;;
764      'st' )
765        vars=`echo ${stvariables} | tr ':' ' '`
766        ivar=1
767        for var in ${vars}; do
768          varL=`to_LaTeX ${var}`
769          varvals=`python ${PYHOME}/drawing.py -o variable_values -S ${var} \
770            | grep all_values`         
771          varn=`echo ${varvals} | tr ',' ' ' | awk '{print $3}'`
772          echo "    var: "${varn}
773          ln=`echo ${varvals} | tr ',' ' ' | awk '{print $7}'`
774          cat << EOF >> ${otex}
775% ${varn}
776%%
777
778\\begin{figure}
779\\begin{center}
780\\begin{tabular}{cc}
781\\includegraphics[width=0.5\\textwidth]{figs/${varn}_hor}
782&
783\\includegraphics[width=0.5\\textwidth]{figs/${varn}_Hovmoller}
784\\\\
785\\includegraphics[width=0.5\\textwidth]{figs/${varn}_TimeSeries}
786&
787\\includegraphics[width=0.5\\textwidth]{figs/${varn}_Neighbourghood_evol}
788\\end{tabular}
789EOF
790          if test ${ivar} -eq 1; then
791            firstvar=${varn}
792            caption='\caption{Instantaneaous value at time='${tvalS}', z='${zval}
793            caption=${caption}' level of '${varn}' ['${varL}'] (top left), temporal evolution of the'
794            caption=${caption}' vertical profile at yval='${yval}', xval='${xval}
795            caption=${caption}' (top right), temporal evolution at the given point '
796            caption=${caption}' (bottom left), evolution of a box of 5x5 centered on the '
797            caption=${caption}'point (bottom right)}'
798          else
799             caption='\caption{As in figure \ref{fig:state_'${firstvar}'}, but for '
800             caption=${caption}${varn}' ['${varL}']}'
801          fi
802          cat << EOF >> ${otex}
803${caption}
804\\label{fig:state_${varn}}
805\\end{center}
806\\end{figure}
807\\clearpage
808EOF
809
810          ivar=`expr ${ivar} + 1`
811        done
812cat << EOF >> ${otex}
813\\clearpage
814EOF
815      ;;
816    esac
817  done
818
819  cat << EOF >> ${otex}
820\\end{document}
821EOF
822  otexn=`echo ${filetexn} | tr '.' ' ' | awk '{print $1}'`
823  cd ${ofold}
824  pdflatex ${otexn}
825  pdflatex ${otexn}
826  pdflatex ${otexn}
827  pdflatex ${otexn}
828  evince ${otexn}.pdf &
829  cd ${rootsh}
830  fi
831fi
832
Note: See TracBrowser for help on using the repository browser.