1 | #!/bin/bash |
---|
2 | # L. Fita, June 2016. Generic script to plot model outputs |
---|
3 | |
---|
4 | main='model_graphics.bash' |
---|
5 | |
---|
6 | # All purpouse |
---|
7 | ######## ###### ##### #### ### ## # |
---|
8 | |
---|
9 | function list_pairs() { |
---|
10 | # Function to provide two lists from one in order to obtain all the possibles pairs |
---|
11 | # listv= ':' separated list of values to construct de couples |
---|
12 | # $ list_pairs 1:2:3:4:5:6:7:8:9 |
---|
13 | # list_pairs: newlists= 1|2|3|4|5|6|7|8|:2|3|4|5|6|7|8|9| |
---|
14 | # list_pairs: pairs= 1|2:1|3:1|4:1|5:1|6:1|7:1|8:1|9:2|3:2|4:2|5:2|6:2|7:2|8:2|9:3|4:3|5:3|6:3|7:3|8:3|9:4|5:4|6:4|7:4|8:4|9:5|6:5|7:5|8:5|9:6|7:6|8:6|9:7|8:7|9:8|9 |
---|
15 | |
---|
16 | fname='list_pairs' |
---|
17 | |
---|
18 | listv=$1 |
---|
19 | |
---|
20 | lv=`echo ${listv} | tr ':' ' '` |
---|
21 | Nlv=`echo ${listv} | tr ':' ' ' | wc -w | awk '{print $1}'` |
---|
22 | |
---|
23 | if test ${Nlv} -lt 2; then |
---|
24 | echo ${errormsg} |
---|
25 | echo " "${fname}": too few values from list, at least 2 are required!" |
---|
26 | echo " provided list: "${listv} |
---|
27 | exit |
---|
28 | fi |
---|
29 | |
---|
30 | Nlv_1=`expr ${Nlv} - 1` |
---|
31 | |
---|
32 | newlist1=`echo ${listv} | tr ':' '\n' | head -n ${Nlv_1} | tr '\n' '|'` |
---|
33 | newlist2=`echo ${listv} | tr ':' '\n' | tail -n ${Nlv_1} | tr '\n' '|'` |
---|
34 | |
---|
35 | pairs='' |
---|
36 | ipair=1 |
---|
37 | il1=1 |
---|
38 | while test ${il1} -le ${Nlv_1}; do |
---|
39 | lv1=`echo ${listv} | tr ':' '\n' | head -n ${il1} | tail -n 1` |
---|
40 | il2=`expr ${il1} + 1` |
---|
41 | while test ${il2} -le ${Nlv}; do |
---|
42 | lv2=`echo ${listv} | tr ':' '\n' | head -n ${il2} | tail -n 1` |
---|
43 | if test ${ipair} -eq 1; then |
---|
44 | pairs=${lv1}'|'${lv2} |
---|
45 | else |
---|
46 | pairs=${pairs}':'${lv1}'|'${lv2} |
---|
47 | fi |
---|
48 | |
---|
49 | ipair=`expr ${ipair} + 1` |
---|
50 | il2=`expr ${il2} + 1` |
---|
51 | done |
---|
52 | |
---|
53 | il1=`expr ${il1} + 1` |
---|
54 | done |
---|
55 | |
---|
56 | echo " "${fname}": newlists= "${newlist1}':'${newlist2} |
---|
57 | echo " "${fname}": pairs= "${pairs} |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | function uploadvars() { |
---|
62 | # Function to upload variables to the system from an ASCII file as: |
---|
63 | # [varname] = [value] |
---|
64 | fileval=$1 |
---|
65 | errormsg='ERROR -- error -- ERROR -- error' |
---|
66 | |
---|
67 | if test ! -f ${fileval}; then |
---|
68 | echo ${errormsg} |
---|
69 | echo " "${fname}": file '"${fileval}"' does not exist!!" |
---|
70 | exit |
---|
71 | fi |
---|
72 | |
---|
73 | Nlin=`wc -l ${fileval} | awk '{print $1}'` |
---|
74 | |
---|
75 | ilin=1 |
---|
76 | while test ${ilin} -le ${Nlin}; do |
---|
77 | line=`head -n ${ilin} ${fileval} | tail -n 1` |
---|
78 | varname=`echo ${line} | tr '=' ' ' | awk '{print $1}'` |
---|
79 | value=`echo ${line} | tr '=' ' ' | awk '{print $2}'` |
---|
80 | Lvarname=`expr length ${varname}'0'` |
---|
81 | |
---|
82 | if test ${Lvarname} -gt 1 && test ! ${varname:0:1} = '#'; then |
---|
83 | export ${varname}=${value} |
---|
84 | fi |
---|
85 | ilin=`expr ${ilin} + 1` |
---|
86 | done |
---|
87 | } |
---|
88 | |
---|
89 | function isInlist() { |
---|
90 | # Function to check whether a value is in a list |
---|
91 | list=$1 |
---|
92 | value=$2 |
---|
93 | |
---|
94 | is=`echo ${list} | tr ':' '\n' | awk '{print "@"$1"@"}' | grep '@'${value}'@' | wc -w` |
---|
95 | if test ${is} -eq 1 |
---|
96 | then |
---|
97 | true |
---|
98 | else |
---|
99 | false |
---|
100 | fi |
---|
101 | } |
---|
102 | |
---|
103 | function ferrmsg() { |
---|
104 | # Function to exit and write an error message |
---|
105 | # comdexit: code number exit from the last execution |
---|
106 | # ref: script/reference from which error occurs |
---|
107 | # msg: message to write ('!' for spaces, '#' for end of line) |
---|
108 | comdexit=$1 |
---|
109 | ref=$2 |
---|
110 | msg=$3 |
---|
111 | |
---|
112 | if test ${comdexit} -ne 0; then |
---|
113 | echo "ERROR -- error -- ERROR -- error" |
---|
114 | echo " "${ref}": "$(echo ${msg} | tr '!' ' ' | tr '#' '\n')" !!" |
---|
115 | exit |
---|
116 | fi |
---|
117 | } |
---|
118 | |
---|
119 | function ferrmsgF() { |
---|
120 | # Function to exit and write an error message and remove a file |
---|
121 | # comdexit: code number exit from the last execution |
---|
122 | # ref: script/reference from which error occurs |
---|
123 | # msg: message to write ('!' for spaces, '#' for end of line) |
---|
124 | # FileName: name of the file to remove in case of error |
---|
125 | comdexit=`expr $1 + 0` |
---|
126 | ref=$2 |
---|
127 | msg=$3 |
---|
128 | FileName=$4 |
---|
129 | |
---|
130 | if test ${comdexit} -ne 0; then |
---|
131 | echo "ERROR -- error -- ERROR -- error" |
---|
132 | echo " "${ref}": "$(echo ${msg} | tr '!' ' ' | tr '\#' '\n')" !!" |
---|
133 | rm ${FileName} >& /dev/null |
---|
134 | exit |
---|
135 | fi |
---|
136 | } |
---|
137 | |
---|
138 | function list_add_label(){ |
---|
139 | # Function to add the label to a list |
---|
140 | # list= ':' separated list to wchich add a ticket |
---|
141 | # label= label to add to the list |
---|
142 | # ch= character to separate list values and new label |
---|
143 | # pos= position of the label ('beg': beginning, 'end': ending) |
---|
144 | # $ list_add_label 1:2:3:4:5 abc # beg |
---|
145 | # abc#1:abc#2:abc#3:abc#4:abc#5 |
---|
146 | |
---|
147 | fname='list_add_label' |
---|
148 | |
---|
149 | list=$1 |
---|
150 | label=$2 |
---|
151 | ch=$3 |
---|
152 | pos=$4 |
---|
153 | |
---|
154 | ival=1 |
---|
155 | lvs=`echo ${list} | tr ':' ' '` |
---|
156 | |
---|
157 | newlist='' |
---|
158 | for listv in ${lvs}; do |
---|
159 | if test ${pos} = 'beg'; then |
---|
160 | nlv=${label}${ch}${listv} |
---|
161 | else |
---|
162 | nlv=${listv}${ch}${label} |
---|
163 | fi |
---|
164 | if test ${ival} -eq 1; then |
---|
165 | newlist=${nlv} |
---|
166 | else |
---|
167 | newlist=${newlist}':'${nlv} |
---|
168 | fi |
---|
169 | ival=`expr ${ival} + 1` |
---|
170 | done |
---|
171 | |
---|
172 | echo ${newlist} |
---|
173 | } |
---|
174 | |
---|
175 | function stats_filename() { |
---|
176 | # Function to provide the name of a given statisitcs file |
---|
177 | # CFvarn= CF variable name |
---|
178 | # fkind= kind of the file |
---|
179 | # headf= head of the file |
---|
180 | # $ stats_filename ta xmean wrfout |
---|
181 | # ta_wrfout_xmean.nc |
---|
182 | # $ stats_filename ta pinterp@last@xmean wrfout |
---|
183 | # ta_wrfout_pinterp_last_xmean.nc |
---|
184 | fname='stats_filename' |
---|
185 | |
---|
186 | CFvarn=$1 |
---|
187 | fkind=$2 |
---|
188 | headf=$3 |
---|
189 | |
---|
190 | # Number of operations in a combo file they are '@' separated |
---|
191 | nopers=`echo ${fkind} | tr '@' ' ' | wc -w | awk '{print $1}'` |
---|
192 | |
---|
193 | if test $(index_string ${fkind} pinterp) -ne -1; then |
---|
194 | fhead=${headf}'p' |
---|
195 | else |
---|
196 | fhead=${headf} |
---|
197 | fi |
---|
198 | |
---|
199 | if test ${nopers} -eq 1; then |
---|
200 | filename=${CFvarn}'_'${fhead}'_'${fkind} |
---|
201 | else |
---|
202 | opers=`echo ${fkind} | tr '@' ' '` |
---|
203 | filename=${CFvarn}'_'${fhead} |
---|
204 | for op in ${opers}; do |
---|
205 | filename=${filename}'_'${op} |
---|
206 | done |
---|
207 | fi |
---|
208 | |
---|
209 | echo ${filename}.nc |
---|
210 | } |
---|
211 | |
---|
212 | function index_string(){ |
---|
213 | # Function to provide the index of a given word inside a string |
---|
214 | # string= string to find in |
---|
215 | # word= word to find |
---|
216 | # $ index_string 123abc456ab789bca0 bca |
---|
217 | # 14 |
---|
218 | fname='index_string' |
---|
219 | string=$1 |
---|
220 | word=$2 |
---|
221 | |
---|
222 | if test $# -ne 2; then |
---|
223 | echo ${errmsg} |
---|
224 | echo " "$fname}": wrong number of arguments !!" |
---|
225 | echo " 2 are required and "$#" are given!" |
---|
226 | echo " passed: "$0 |
---|
227 | exit |
---|
228 | fi |
---|
229 | |
---|
230 | |
---|
231 | Lstring=`expr length ${string}` |
---|
232 | Lword=`expr length ${word}` |
---|
233 | |
---|
234 | if test ${Lstring} -lt 1; then |
---|
235 | echo ${errmsg} |
---|
236 | echo " "$fname}": wrong string '"${string}"' !!" |
---|
237 | exit |
---|
238 | fi |
---|
239 | |
---|
240 | if test ${Lword} -lt 1; then |
---|
241 | echo ${errmsg} |
---|
242 | echo " "$fname}": wrong word '"${word}"' !!" |
---|
243 | exit |
---|
244 | fi |
---|
245 | |
---|
246 | Lfinalstring=`expr ${Lstring} - ${Lword}` |
---|
247 | |
---|
248 | iw=0 |
---|
249 | index=-1 |
---|
250 | while test ${iw} -le ${Lfinalstring}; do |
---|
251 | if test ${string:${iw}:${Lword}} = ${word}; then |
---|
252 | index=${iw} |
---|
253 | break |
---|
254 | fi |
---|
255 | iw=`expr ${iw} + 1` |
---|
256 | done |
---|
257 | |
---|
258 | echo ${index} |
---|
259 | return |
---|
260 | } |
---|
261 | |
---|
262 | function list_filter() { |
---|
263 | # Function to filter by a value a list |
---|
264 | # list: list to filter |
---|
265 | # value: value to filter with |
---|
266 | # $ list_filter '1|i:2|ii:3|iii:4|iv:5|v:1|I:2|II:3|III:4|iv:5|v' 3 |
---|
267 | # 3|iii:3|III |
---|
268 | fname='list_filter' |
---|
269 | |
---|
270 | list=$1 |
---|
271 | varn=$2 |
---|
272 | |
---|
273 | lvs=`echo ${list} | tr ':' ' '` |
---|
274 | |
---|
275 | newlist='' |
---|
276 | il=1 |
---|
277 | for lv in ${lvs}; do |
---|
278 | if test $(index_string ${lv} ${varn}) -ne -1; then |
---|
279 | if test ${il} -eq 1; then |
---|
280 | newlist=${lv} |
---|
281 | else |
---|
282 | newlist=${newlist}':'${lv} |
---|
283 | fi |
---|
284 | il=`expr ${il} + 1` |
---|
285 | fi |
---|
286 | done |
---|
287 | |
---|
288 | echo ${newlist} |
---|
289 | |
---|
290 | return |
---|
291 | } |
---|
292 | |
---|
293 | function join_lists() { |
---|
294 | # Function to join lists without repeating values |
---|
295 | # list1: first list to join |
---|
296 | # list2: second list to join |
---|
297 | # $ join_lists 1:2:3:4:5:6:7:8 a:b:3:c:5:6:7:9 |
---|
298 | # 1:2:3:4:5:6:7:8:a:b:c:9 |
---|
299 | |
---|
300 | fname='join_lists' |
---|
301 | list1=$1 |
---|
302 | list2=$2 |
---|
303 | |
---|
304 | ls1s=`echo ${list1} | tr ':' ' '` |
---|
305 | ls2s=`echo ${list2} | tr ':' ' '` |
---|
306 | |
---|
307 | newlist=${list1} |
---|
308 | for ls2 in ${ls2s}; do |
---|
309 | if ! $(isInlist ${list1} ${ls2}); then |
---|
310 | newlist=${newlist}':'${ls2} |
---|
311 | fi |
---|
312 | done |
---|
313 | |
---|
314 | echo ${newlist} |
---|
315 | } |
---|
316 | |
---|
317 | # Specific |
---|
318 | ######## ###### ##### #### ### ## # |
---|
319 | |
---|
320 | function variable_compute(){ |
---|
321 | # Function to retrieve the computation way of a given variable using a series of |
---|
322 | # test files |
---|
323 | # iwdir= directory with the test files |
---|
324 | # var= name of the variable to test |
---|
325 | # filtests= '@' separated list of '[head]|[file] test files |
---|
326 | fname='variable_compute' |
---|
327 | |
---|
328 | iwdir=$1 |
---|
329 | var=$2 |
---|
330 | filtests=$3 |
---|
331 | |
---|
332 | ftsts=`echo ${filtests} |tr '@' ' '` |
---|
333 | cancompute=true |
---|
334 | |
---|
335 | for ftest in ${ftsts}; do |
---|
336 | headerf=`echo ${ftest} | tr '|' ' ' | awk '{print $1}'` |
---|
337 | filen=`echo ${ftest} | tr '|' ' ' | awk '{print $2}'` |
---|
338 | compute=`${pyHOME}/nc_var.py -o computevar_model -f ${iwdir}/${filen} -S ${var}` |
---|
339 | ferrmsg $? ${main} "python!'computevar_model'!failed!#"$(echo ${compute} | \ |
---|
340 | tr ' ' '!') |
---|
341 | varmod=`echo ${compute} | tr ' ' '#' | tr '|' ' ' | awk '{print $2}' | \ |
---|
342 | tr '@' ' ' | awk '{print $2}' | tr '=' ' ' | awk '{print $2}'` |
---|
343 | vardiag=`echo ${compute} | tr ' ' '#' | tr '|' ' ' | awk '{print $2}' | \ |
---|
344 | tr '@' ' ' | awk '{print $3}' | tr '=' ' ' | awk '{print $2}'` |
---|
345 | echo " "${var}" mod:"${varmod}" diag: "${vardiag} |
---|
346 | if test ${varmod} = 'None' && test ${vardiag} = 'None'; then |
---|
347 | cancompute=false |
---|
348 | else |
---|
349 | cancompute=true |
---|
350 | # Should be considered that variable can also be computed by both ways? |
---|
351 | break |
---|
352 | fi |
---|
353 | done |
---|
354 | if ! ${cancompute}; then |
---|
355 | msg="there!is!no!way!to!compute!'"${var}"'!for!model!"${mod} |
---|
356 | # Too extrict! |
---|
357 | # ferrmsg 1 ${main} ${msg} |
---|
358 | echo ${warnmsg} |
---|
359 | echo $(echo $msg | tr '!' ' ') |
---|
360 | fi |
---|
361 | |
---|
362 | # a ';' list 'varcompute' it is created for each variable giving: |
---|
363 | # [var]|[vark]|[headerf][varmod]|[vardiag] |
---|
364 | # This list will be used to compute a new file for each variable |
---|
365 | varcomp=${var}'|'${vark}'|'${headerf}'|'${varmod}'|'${vardiag} |
---|
366 | |
---|
367 | echo "varcomp= "${varcomp} |
---|
368 | } |
---|
369 | |
---|
370 | function compvars_listconstruct() { |
---|
371 | # Function to construct the list of variables to compute |
---|
372 | # VarKinds= ':' separated list of kind variables to compute |
---|
373 | # TestFiles= ':' list of files to test how to compute the variable |
---|
374 | ## |
---|
375 | fname='compvars_listconstruct' |
---|
376 | |
---|
377 | VarKinds=$1 |
---|
378 | TestFiles=$2 |
---|
379 | |
---|
380 | varks=`echo ${VarKinds} | tr ':' ' '` |
---|
381 | |
---|
382 | combo=false |
---|
383 | ik=1 |
---|
384 | itotv=1 |
---|
385 | for vark in ${varks}; do |
---|
386 | if test ! ${vark} = 'diff'; then |
---|
387 | echo " "${vark}" ..." |
---|
388 | case ${vark} in |
---|
389 | 'acc') |
---|
390 | varvks=${varacc} |
---|
391 | ;; |
---|
392 | 'combo') |
---|
393 | combo=true |
---|
394 | varvcombo=${varcombo} |
---|
395 | varcos=`echo ${varvcombo} | tr ':' ' '` |
---|
396 | varvks='' |
---|
397 | ivco=1 |
---|
398 | for vco in ${varcos}; do |
---|
399 | vn=`echo ${vco} | tr '@' ' ' | awk '{print $1}'` |
---|
400 | if test ${ivco} -eq 1; then |
---|
401 | varvks=${vco} |
---|
402 | else |
---|
403 | varvks=${varvks}':'${vco} |
---|
404 | fi |
---|
405 | ivco=`expr ${ivco} + 1` |
---|
406 | done |
---|
407 | ;; |
---|
408 | 'direct') |
---|
409 | varvks=${vardirect} |
---|
410 | ;; |
---|
411 | 'last') |
---|
412 | varvks=${varlast} |
---|
413 | ;; |
---|
414 | 'Lmean') |
---|
415 | varvks=${varLmean} |
---|
416 | ;; |
---|
417 | 'Lsec') |
---|
418 | varvks=${varLsec} |
---|
419 | ;; |
---|
420 | 'lmean') |
---|
421 | varvks=${varlmean} |
---|
422 | ;; |
---|
423 | 'lsec') |
---|
424 | varvks=${varlsec} |
---|
425 | ;; |
---|
426 | 'pinterp') |
---|
427 | varvks=${varpinterp} |
---|
428 | ;; |
---|
429 | 'tmean') |
---|
430 | varvks=${vartmean} |
---|
431 | ;; |
---|
432 | 'xmean') |
---|
433 | varvks=${varxmean} |
---|
434 | ;; |
---|
435 | 'ymean') |
---|
436 | varvks=${varymean} |
---|
437 | ;; |
---|
438 | 'zsum') |
---|
439 | varvks=${varzsum} |
---|
440 | ;; |
---|
441 | '*') |
---|
442 | echo ${errmsg} |
---|
443 | echo " "${main}": variable kind '"${vark}"' not ready!!" |
---|
444 | exit |
---|
445 | ;; |
---|
446 | esac |
---|
447 | |
---|
448 | # Do we have variables for this kind? |
---|
449 | Lvarvks=`expr length ${varvks}'0'` |
---|
450 | if test ${Lvarvks} -lt 2; then |
---|
451 | ferrmsg 1 ${main} "variable!kind!"${vark}"!without!variables" |
---|
452 | fi |
---|
453 | if test ${ik} -eq 1; then |
---|
454 | allvars=${varvks} |
---|
455 | else |
---|
456 | allvars=${allvars}':'${varvks} |
---|
457 | fi |
---|
458 | ik=`expr ${ik} + 1` |
---|
459 | vars=`echo ${varvks} | tr ':' ' '` |
---|
460 | |
---|
461 | # Variables loop |
---|
462 | ## |
---|
463 | iv=1 |
---|
464 | for var in ${vars}; do |
---|
465 | echo " "${var} |
---|
466 | # How to compute it? |
---|
467 | varcomp=`variable_compute ${iwdir} ${var} ${TestFiles} | grep varcomp | \ |
---|
468 | awk '{print $2}'` |
---|
469 | |
---|
470 | if test ${itotv} -eq 1; then |
---|
471 | varcompute=${varcomp} |
---|
472 | else |
---|
473 | varcompute=${varcompute}';'${varcomp} |
---|
474 | fi |
---|
475 | |
---|
476 | iv=`expr ${iv} + 1` |
---|
477 | itotv=`expr ${itotv} + 1` |
---|
478 | |
---|
479 | # end loop of variables |
---|
480 | done |
---|
481 | fi |
---|
482 | # end of kind of variables |
---|
483 | done |
---|
484 | |
---|
485 | echo ${fname}" varcompute= "${varcompute}_${itotv}_${combo} |
---|
486 | } |
---|
487 | |
---|
488 | function WRF_toCF() { |
---|
489 | # Function to pass a WRF original file to CF-conventions |
---|
490 | # wrff= WRF file |
---|
491 | # wrfvl= WRF longitude var name (it might come from WPS!) |
---|
492 | # wrfvL= WRF latitude var name (it might come from WPS!) |
---|
493 | |
---|
494 | wrff=$1 |
---|
495 | wrfvl=$2 |
---|
496 | wrfvL=$3 |
---|
497 | |
---|
498 | fdims=`${pyHOME}/nc_var.py -o idims -f ${wrff} | grep alldims | tr '=' ' ' | \ |
---|
499 | awk '{print $3}'` |
---|
500 | |
---|
501 | CFdims='west_east@lon:south_north@lat:Time@time' |
---|
502 | CFds=`echo ${CFdims} | tr ':' ' '` |
---|
503 | |
---|
504 | pyout=`${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ |
---|
505 | -f ${wrff} -v time` |
---|
506 | pyn=$? |
---|
507 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
508 | ferrmsgF ${pyn} ${fname} "python!'WRF_CFtime_creation'!failed"${Spyout} ${wrff} |
---|
509 | |
---|
510 | pyout=`${pyHOME}/nc_var.py -o WRF_CFlonlat_creation -v ${wrfvl},${wrfvL} \ |
---|
511 | -f ${wrff} -S lon,lat` |
---|
512 | pyn=$? |
---|
513 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
514 | ferrmsgF ${pyn} ${fname} "python!'WRF_CFlonlat_creation'!failed"${Spyout} ${wrff} |
---|
515 | |
---|
516 | for CFd in ${CFds}; do |
---|
517 | cd=`echo ${CFd} | tr '@' ' ' | awk '{print $2}'` |
---|
518 | wd=`echo ${CFd} | tr '@' ' ' | awk '{print $1}'` |
---|
519 | if $(isInlist ${fdims} ${wd}); then |
---|
520 | pyout=`${pyHOME}/nc_var.py -o chdimname -f ${wrff} -S ${wd}':'${cd}` |
---|
521 | pyn=$? |
---|
522 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
523 | ferrmsgF ${pyn} ${fname} "python!'chdimname'!'"${wd}"'!failed#"${Spyout} ${wrff} |
---|
524 | fi |
---|
525 | done |
---|
526 | |
---|
527 | # CF attributes |
---|
528 | dimvars='lon:lat:time:Times' |
---|
529 | |
---|
530 | allfilevars=`python ${pyHOME}/nc_var.py -o ivars -f ${wrff} | grep allvars | awk '{print $3}'` |
---|
531 | allvs=`echo ${allfilevars} | tr ':' ' '` |
---|
532 | for vn in ${allvs}; do |
---|
533 | if ! $(isInlist ${dimvars} ${vn}); then |
---|
534 | varattrs=`python ${pyHOME}/generic.py -o variables_values -S ${vn}` |
---|
535 | stn=`echo ${varattrs} | tr ':' ' ' | awk '{print $2}'` |
---|
536 | lon=`echo ${varattrs} | tr ':' ' ' | awk '{print $5}' | tr '|' '!'` |
---|
537 | un=`echo ${varattrs} | tr ':' ' ' | awk '{print $6}' | tr '|' '!'` |
---|
538 | |
---|
539 | pyout=`python ${pyHOME}/nc_var.py -o varaddattr -f ${wrff} -S 'standard_name|'${stn} -v ${vn}` |
---|
540 | pyn=$? |
---|
541 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
542 | ferrmsgF ${pyn} ${fname} "python!'varaddattr'!'standard_name'!failed#"${Spyout} ${wrff} |
---|
543 | pyout=`python ${pyHOME}/nc_var.py -o varaddattr -f ${wrff} -S 'long_name|'${lon} -v ${vn}` |
---|
544 | pyn=$? |
---|
545 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
546 | ferrmsgF ${pyn} ${fname} "python!'varaddattr'!'long_name'!failed#"${Spyout} ${wrff} |
---|
547 | pyout=`python ${pyHOME}/nc_var.py -o varaddattr -f ${wrff} -S 'units|'${un} -v ${vn}` |
---|
548 | pyn=$? |
---|
549 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
550 | ferrmsgF ${pyn} ${fname} "python!'varaddattr'!'units'!failed#"${Spyout} ${wrff} |
---|
551 | fi |
---|
552 | done |
---|
553 | } |
---|
554 | |
---|
555 | function cleaning_varsfile() { |
---|
556 | # Function to keep only a list of variables from a file |
---|
557 | # filen= file to clean |
---|
558 | # keepvars= ':' separated list of variables to keep |
---|
559 | fname='cleaning_varsfile' |
---|
560 | |
---|
561 | filen=$1 |
---|
562 | keepvars=$2 |
---|
563 | |
---|
564 | fvars=`${pyHOME}/nc_var.py -o ivars -f ${filen} | grep allvars | tr '=' ' ' | \ |
---|
565 | awk '{print $3}'` |
---|
566 | fvs=`echo ${fvars} | tr ':' ' '` |
---|
567 | |
---|
568 | for fv in ${fvs}; do |
---|
569 | if ! $(isInlist ${keepvars} ${fv}); then |
---|
570 | pyout=`python ${pyHOME}/nc_var.py -o varrm -v ${fv} -f ${filen}` |
---|
571 | pyn=$? |
---|
572 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
573 | ferrmsg ${pyn} ${fname} "python!'varrm'!'${fv}'!failed#"${Spyout} |
---|
574 | fi |
---|
575 | done |
---|
576 | } |
---|
577 | |
---|
578 | function compute_variable() { |
---|
579 | # Function to compute a variable |
---|
580 | # idir: directory with the input files |
---|
581 | # usefiles: ',' list of files as [headerf]@[file1]|...|[fileN] |
---|
582 | # odir: directory to write the output files |
---|
583 | # cvar: [CFvarn]|[varkind]|[headerf]|[varmod]|[vardiag] |
---|
584 | # [CFvarn]: CF name of the variable |
---|
585 | # [vark]: kind of variable: |
---|
586 | # acc: temporal accumulated values |
---|
587 | # diff: differences between models |
---|
588 | # direct: no statistics |
---|
589 | # last: last temporal value |
---|
590 | # Lmean: latitudinal mean values |
---|
591 | # Lsec: latitudinal section (latitudinal value must be given, [var]@[lat]) |
---|
592 | # lsec: longitudinal section (longitudinal value must be given, [var]@[lat]) |
---|
593 | # lmean: longitudinal mean values |
---|
594 | # pinterp: pressure interpolation (to the given $plevels) |
---|
595 | # tmean: temporal mean values |
---|
596 | # tmean: temporal mean values |
---|
597 | # xmean: x-axis mean values |
---|
598 | # ymean: y-axis mean values |
---|
599 | # zsum: vertical aggregated values |
---|
600 | # [headerf]: header of the files to use |
---|
601 | # [modvar]: variable to use from the file |
---|
602 | # [diagvar]: variable computed from the diagnostics (diagnostic.py) |
---|
603 | # mdim: name of the dimensions in the model |
---|
604 | # mvdim: name of the vaariable-dimensions in the model |
---|
605 | # scratch: whether is has to be done from the scratch or not |
---|
606 | fname='compute_variable' |
---|
607 | idir=$1 |
---|
608 | usefiles=$2 |
---|
609 | odir=$3 |
---|
610 | cvar=$4 |
---|
611 | mdim=$5 |
---|
612 | mvdim=$6 |
---|
613 | scratch=$7 |
---|
614 | |
---|
615 | CFvarn=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'` |
---|
616 | vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'` |
---|
617 | headerf=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'` |
---|
618 | modvar=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'` |
---|
619 | diagvar=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'` |
---|
620 | |
---|
621 | cfiles=`echo ${usefiles} | tr ',' '\n' | grep ${headerf} | tr '|' ' ' | \ |
---|
622 | awk '{print $2}' | tr '@' ' '` |
---|
623 | |
---|
624 | # dimensions |
---|
625 | dnx=`echo ${mdim} | tr ',' ' ' | awk '{print $1}'` |
---|
626 | dny=`echo ${mdim} | tr ',' ' ' | awk '{print $2}'` |
---|
627 | # var-dimensions |
---|
628 | vdnx=`echo ${mvdim} | tr ',' ' ' | awk '{print $1}'` |
---|
629 | vdny=`echo ${mvdim} | tr ',' ' ' | awk '{print $2}'` |
---|
630 | |
---|
631 | cd ${odir} |
---|
632 | |
---|
633 | # Computing separately and then joinging for all files |
---|
634 | Ntotfiles=`echo ${cfiles} | wc -w | awk '{print $1}'` |
---|
635 | ifile=1 |
---|
636 | |
---|
637 | for cf in ${cfiles}; do |
---|
638 | ifS=`printf "%0${Ntotfiles}d" ${ifile}` |
---|
639 | |
---|
640 | # Computing variable |
---|
641 | # Changing file head when it is a pressure-interpolated variable |
---|
642 | if test ${vark} == 'pinterp'; then |
---|
643 | fhead=${headerf}p |
---|
644 | else |
---|
645 | fhead=${headerf} |
---|
646 | fi |
---|
647 | |
---|
648 | filen=${odir}/${CFvarn}_${fhead}_${ifile}-${Ntotfiles}.nc |
---|
649 | if ${scratch}; then |
---|
650 | rm ${filen} >& /dev/null |
---|
651 | rm ${odir}/${CFvarn}_${fhead}.nc >& /dev/null |
---|
652 | fi |
---|
653 | |
---|
654 | if test ! -f ${filen} && test ! -f ${odir}/${CFvarn}_${fhead}.nc; then |
---|
655 | # Since model direct values are retrieved from `variables_valules.dat' which was initially coincived |
---|
656 | # as a way to only give variable attributes, range and color bars, if a variable has a diagnostic |
---|
657 | # way to be computed, the later one will be preferred |
---|
658 | |
---|
659 | if test ! ${modvar} = 'None' && test ${diagvar} = 'None'; then |
---|
660 | # model variable |
---|
661 | values=${modvar}',0,-1,-1' |
---|
662 | vs=${modvar},${vdnx},${vdny},${vdnz},${vdnt} |
---|
663 | pyout=`${pyHOME}/nc_var.py -f ${cf} -o DataSetSection_multivars -v ${vs} \ |
---|
664 | -S ${values} | grep succesfull | awk '{print $6}' | tr '"' ' '` |
---|
665 | pyn=$? |
---|
666 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
667 | ferrmsg ${pyn} ${fname} "python!'DataSetSection_multivars'!failed"${Spyout} |
---|
668 | mv ${pyout} ${filen} |
---|
669 | |
---|
670 | # Keeping the operations |
---|
671 | pyins=${pyHOME}"/nc_var.py -f "${cf}" -o DataSetSection_multivars -v "${vs} |
---|
672 | pyins=${pyins}" -S "${values} |
---|
673 | echo " " >> ${odir}/all_computevars.inf |
---|
674 | echo "# ${CFvarn}" "${modvar}" >> ${odir}/all_computevars.inf |
---|
675 | echo ${pyins} >> ${odir}/all_computevars.inf |
---|
676 | |
---|
677 | pyout=`${pyHOME}/nc_var.py -f ${filen} -o chvarname -v ${modvar} -S ${CFvarn}` |
---|
678 | pyn=$? |
---|
679 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
680 | ferrmsgF ${pyn} ${fname} "python!'chvarname'!failed"${Spyout} ${filen} |
---|
681 | else |
---|
682 | # diagnostic variable |
---|
683 | dims=${dnt}@${vdnt},${dnz}@${vdnz},${dny}@${vdny},${dnx}@${vdnx} |
---|
684 | diagn=`echo ${diagvar} | tr ':' '\n' | head -n 1` |
---|
685 | Ndiagvars=`echo ${diagvar} | tr ':' ' ' | wc -w | awk '{print $1}'` |
---|
686 | idiagv=2 |
---|
687 | diagc='' |
---|
688 | while test ${idiagv} -le ${Ndiagvars}; do |
---|
689 | diag1=`echo ${diagvar} | tr ':' '\n' | head -n ${idiagv} | tail -n 1` |
---|
690 | if test ${idiagv} -eq 2; then |
---|
691 | diagc=${diag1} |
---|
692 | else |
---|
693 | diagc=${diagc}'@'${diag1} |
---|
694 | fi |
---|
695 | idiagv=`expr ${idiagv} + 1` |
---|
696 | done |
---|
697 | pyout=`python ${pyHOME}/diagnostics.py -f ${cf} -d ${dims} -v ${diagn}'|'${diagc}` |
---|
698 | pyn=$? |
---|
699 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
700 | ferrmsg ${pyn} ${fname} "python!'diagnostics'!failed#"${Spyout} |
---|
701 | mv diagnostics.nc ${filen} |
---|
702 | |
---|
703 | # Keeping the operations |
---|
704 | pyins=${pyHOME}"/diagnostics.py -f "${cf}" -d "${dims}" -v '"${diagn}"|" |
---|
705 | pyins=${pyins}${diagc}"'" |
---|
706 | echo " " >> ${odir}/all_computevars.inf |
---|
707 | echo "# ${CFvarn}" "${diagvar}" >> ${odir}/all_computevars.inf |
---|
708 | echo ${pyins} >> ${odir}/all_computevars.inf |
---|
709 | fi |
---|
710 | |
---|
711 | # adding CF lon,lat,time in WRF files |
---|
712 | if test ${headerf:0:3} = 'wrf'; then |
---|
713 | WRF_toCF ${filen} ${vdnx} ${vdny} |
---|
714 | fi |
---|
715 | # Attaching necessary variables for the pressure interpolation |
---|
716 | if test ${vark} == 'pinterp'; then |
---|
717 | requiredinterpvars='P:PB:PSFC:PH:PHB:HGT:T:QVAPOR:' |
---|
718 | rqvs=`echo ${requiredinterpvars} | tr ':' ' '` |
---|
719 | echo " "${fname}": adding variables: "${rqvs}" to allow pressure interpolation" |
---|
720 | for rqv in ${rqvs}; do |
---|
721 | pyout=`${pyHOME}/nc_var.py -o fvaradd -S ${cf},${rqv} -f ${filen}` |
---|
722 | pyn=$? |
---|
723 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
724 | ferrmsgF ${pyn} ${fname} "python!'fvaradd'!failed#"${Spyout} ${filen} |
---|
725 | done |
---|
726 | fi |
---|
727 | fi |
---|
728 | |
---|
729 | ifile=`expr ${ifile} + 1` |
---|
730 | # End of files |
---|
731 | done |
---|
732 | |
---|
733 | # Joining variable files |
---|
734 | filen=${odir}/${CFvarn}_${fhead}.nc |
---|
735 | if ${scratch}; then rm ${filen} >& /dev/null; fi |
---|
736 | |
---|
737 | if test ! -f ${filen}; then |
---|
738 | pyout=`python ${pyHOME}/nc_var.py -f ${CFvarn}'_'${fhead}'_,-,.nc' \ |
---|
739 | -o netcdf_fold_concatenation_HMT -S ./,time -v all` |
---|
740 | pyn=$? |
---|
741 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
742 | ferrmsg ${pyn} ${fname} "python!'netcdf_fold_concatenation_HMT'!failed#"${Spyout} |
---|
743 | mv netcdf_fold_concatenated_HMT.nc ${filen} |
---|
744 | if test -f ${filen}; then |
---|
745 | rm ${CFvarn}_${fhead}_*-*.nc |
---|
746 | fi |
---|
747 | fi |
---|
748 | } |
---|
749 | |
---|
750 | function compute_vars() { |
---|
751 | # Function to compute variables |
---|
752 | # Iwdir= input folder |
---|
753 | # Owdir= output folder |
---|
754 | # Files= files to use |
---|
755 | # Moddims= list of names of dimensions of the file |
---|
756 | # Modvdims= list of names of the dimensions variables of the file |
---|
757 | # VarCompute= list of variables to compute as ';' list of |
---|
758 | # [CFvarn]|[varkind]|[headerf]|[varmod]|[vardiag] |
---|
759 | # Filescratch= wether files have to be compute from the scratch or not |
---|
760 | fname='compute_vars' |
---|
761 | |
---|
762 | Iwdir=$1 |
---|
763 | Owdir=$2 |
---|
764 | Files=$3 |
---|
765 | Moddims=$4 |
---|
766 | Modvdims=$5 |
---|
767 | VarCompute=$6 |
---|
768 | Filescratch=$7 |
---|
769 | |
---|
770 | cd $Owdir |
---|
771 | ic=1 |
---|
772 | isc=1 |
---|
773 | cvars=`echo ${VarCompute} | tr ';' ' '` |
---|
774 | for cvar in ${cvars}; do |
---|
775 | CFv=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'` |
---|
776 | vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'` |
---|
777 | fileh=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'` |
---|
778 | modv=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'` |
---|
779 | diagv=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'` |
---|
780 | if ${dbg}; then echo " "${CFv}"; "${modv}" "${diagv}; fi |
---|
781 | |
---|
782 | if test ! ${modv} = 'None' || test ! ${diagv} = 'None'; then |
---|
783 | compute_variable ${Iwdir} ${Files} ${Owdir} ${cvar} ${Moddims} ${Modvdims} \ |
---|
784 | ${Filescratch} |
---|
785 | ic=`expr ${ic} + 1` |
---|
786 | |
---|
787 | if test ! ${vark} = 'diff' && test ! ${vark} = 'combo'; then |
---|
788 | if test ${vark} = 'pinterp'; then |
---|
789 | fhead=${fileh}'p' |
---|
790 | else |
---|
791 | fhead=${fileh} |
---|
792 | fi |
---|
793 | compute_statistics ${iwdir} ${CFv}_${fhead}.nc ${owdir} ${cvar} \ |
---|
794 | ${moddims} ${modvdims} ${filescratch} |
---|
795 | isc=`expr ${isc} + 1` |
---|
796 | else |
---|
797 | if test ${vark} = 'diff'; then |
---|
798 | echo " "${main}": differences will be calculated when all the " \ |
---|
799 | "model/experiments will be done !" |
---|
800 | elif test ${vark} = 'combo'; then |
---|
801 | echo " "${main}": combos will be calculated later when all the " \ |
---|
802 | "variables will be done !" |
---|
803 | fi |
---|
804 | fi |
---|
805 | else |
---|
806 | if ${dbg}; then echo " not '"${CFv}"' for model '"${mod}"' !!"; fi |
---|
807 | fi |
---|
808 | |
---|
809 | # exit |
---|
810 | # end of computing vars |
---|
811 | done |
---|
812 | } |
---|
813 | |
---|
814 | function compute_statistics(){ |
---|
815 | # Function to compute different statistics |
---|
816 | # idir: directory with the input files |
---|
817 | # usefiles: ',' list of files to use [file1],...,[fileN] |
---|
818 | # odir: directory to write the output files |
---|
819 | # cvar: [CFvarn]|[varkind]|[headerf]|[varmod]|[vardiag] |
---|
820 | # [CFvarn]: CF name of the variable |
---|
821 | # [vark]: kind of variable: |
---|
822 | # acc: temporal accumulated values |
---|
823 | # diff: differences between models |
---|
824 | # direct: no statistics |
---|
825 | # last: last temporal value |
---|
826 | # Lmean: latitudinal mean values |
---|
827 | # Lsec: latitudinal section (latitudinal value must be given, [var]@[lat]) |
---|
828 | # lmean: longitudinal mean values |
---|
829 | # lsec: longitudinal section (longitudinal value must be given, [var]@[lat]) |
---|
830 | # pinterp: pressure interpolation (to the given $plevels) |
---|
831 | # tmean: temporal mean values |
---|
832 | # turb: Taylor's turbulence decomposition value |
---|
833 | # xmean: x-axis mean values |
---|
834 | # ymean: y-axis mean values |
---|
835 | # zsum: vertical aggregated values |
---|
836 | # [headerf]: header of the files to use |
---|
837 | # [modvar]: variable to use from the file |
---|
838 | # [diagvar]: variable computed from the diagnostics (diagnostic.py) |
---|
839 | # mdim: name of the dimensions in the model |
---|
840 | # mvdim: name of the vaariable-dimensions in the model |
---|
841 | # scratch: whether is has to be done from the scratch or not |
---|
842 | fname='compute_statistics' |
---|
843 | |
---|
844 | idir=$1 |
---|
845 | usefiles=$2 |
---|
846 | odir=$3 |
---|
847 | cvar=$4 |
---|
848 | mdim=$5 |
---|
849 | mvdim=$6 |
---|
850 | scratch=$7 |
---|
851 | |
---|
852 | # Getting a previous file name to continue with(for combinations) |
---|
853 | if test $# -eq 8; then |
---|
854 | echo ${warnmsg} |
---|
855 | echo " "${fname}": using a previous file '"$8"' to continue with!!" |
---|
856 | prevfile=$8 |
---|
857 | usefiles=$8 |
---|
858 | fi |
---|
859 | |
---|
860 | CFvarn=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'` |
---|
861 | vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'` |
---|
862 | headerf=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'` |
---|
863 | modvar=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'` |
---|
864 | diagvar=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'` |
---|
865 | |
---|
866 | cfiles=`echo ${usefiles} | tr ',' ' '` |
---|
867 | |
---|
868 | # dimensions |
---|
869 | dnx=`echo ${mdim} | tr ',' ' ' | awk '{print $1}'` |
---|
870 | dny=`echo ${mdim} | tr ',' ' ' | awk '{print $2}'` |
---|
871 | # var-dimensions |
---|
872 | vdnx=`echo ${mvdim} | tr ',' ' ' | awk '{print $1}'` |
---|
873 | vdny=`echo ${mvdim} | tr ',' ' ' | awk '{print $2}'` |
---|
874 | |
---|
875 | cd ${odir} |
---|
876 | |
---|
877 | if test $# -ne 8; then |
---|
878 | if test ${vark} == 'pinterp'; then |
---|
879 | fhead=${headerf}p |
---|
880 | else |
---|
881 | fhead=${headerf} |
---|
882 | fi |
---|
883 | filen=${CFvarn}_${fhead}_${vark}.nc |
---|
884 | else |
---|
885 | Lprevfile=`expr length ${prevfile}` |
---|
886 | Lprevfile3=`expr ${Lprevfile} - 3` |
---|
887 | filen=${prevfile:0:$Lprevfile3}_${vark}.nc |
---|
888 | fi |
---|
889 | if ${scratch}; then rm ${filen} >& /dev/null; fi |
---|
890 | |
---|
891 | if test ! -f ${filen}; then |
---|
892 | # Computing stats |
---|
893 | case ${vark} in |
---|
894 | # temporal accumulated values |
---|
895 | 'acc') |
---|
896 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
897 | exit |
---|
898 | ;; |
---|
899 | # differences between models |
---|
900 | 'diff') |
---|
901 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
902 | exit |
---|
903 | ;; |
---|
904 | # no statistics |
---|
905 | 'direct') |
---|
906 | cp ${cfiles} ${filen} |
---|
907 | ;; |
---|
908 | # last temporal value |
---|
909 | 'last') |
---|
910 | Lcfiles=`expr length ${cfiles}` |
---|
911 | Lcfiles3=`expr ${Lcfiles} - 3` |
---|
912 | vals='time,-9,0,0' |
---|
913 | pyout=`python ${pyHOME}/nc_var.py -o DataSetSection -S ${vals} -f ${cfiles} \ |
---|
914 | -v ${CFvarn}` |
---|
915 | pyn=$? |
---|
916 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
917 | ferrmsg ${pyn} ${fname} "python!'DataSetSection'!'last'!failed#"${Spyout} |
---|
918 | mv ${cfiles:0:${Lcfiles3}}_time_B-9-E0-I0.nc ${filen} |
---|
919 | |
---|
920 | # Keeping the operations |
---|
921 | pyins=${pyHOME}"/nc_var.py -o DataSetSection -S "${vals}" -f "${cfiles} |
---|
922 | pyins=${pyins}"-v "${CFvarn} |
---|
923 | echo " " >> ${odir}/all_statsvars.inf |
---|
924 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
925 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
926 | ;; |
---|
927 | # latitudinal mean values |
---|
928 | 'Lmean') |
---|
929 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
930 | exit |
---|
931 | ;; |
---|
932 | # latitudinal section (latitudinal value must be given, [var]@[lat]) |
---|
933 | 'Lsec') |
---|
934 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
935 | exit |
---|
936 | ;; |
---|
937 | # longitudinal section (longitudinal value must be given, [var]@[lat]) |
---|
938 | 'lsec') |
---|
939 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
940 | exit |
---|
941 | ;; |
---|
942 | # longitudinal mean values |
---|
943 | 'lmean') |
---|
944 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
945 | exit |
---|
946 | ;; |
---|
947 | # pinterp: pressure interpolation (to the given $plevels) |
---|
948 | 'pinterp') |
---|
949 | vals=${plevels}',1,1' |
---|
950 | pyout=`python $pyHOME/nc_var.py -o pinterp -f ${cfiles} -S ${vals} \ |
---|
951 | -v ${CFvarn}` |
---|
952 | pyn=$? |
---|
953 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
954 | ferrmsg ${pyn} ${fname} "python!'pinterp'!failed#"${Spyout} |
---|
955 | cp pinterp.nc ${filen} |
---|
956 | |
---|
957 | # Keeping the operations |
---|
958 | pyins=${pyHOME}"/nc_var.py -o pinterp -S "${vals}" -f "${cfiles} |
---|
959 | pyins=${pyins}"-v "${CFvarn} |
---|
960 | echo " " >> ${odir}/all_statsvars.inf |
---|
961 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
962 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
963 | |
---|
964 | # adding CF lon,lat,time in WRF files |
---|
965 | if test ${headerf:0:3} = 'wrf'; then |
---|
966 | WRF_toCF ${filen} ${vdnx} ${vdny} |
---|
967 | fi |
---|
968 | ;; |
---|
969 | # temporal mean values |
---|
970 | 'tmean') |
---|
971 | vals='time|-1,time,mean,lon:lat:'${vdnz}':time:pres' |
---|
972 | dims='time@time,'${dnz}'@'${vdnz}',lat@lat,lon@lon' |
---|
973 | |
---|
974 | pyout=`python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} \ |
---|
975 | -f ${cfiles} -v ${CFvarn}` |
---|
976 | pyn=$? |
---|
977 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
978 | ferrmsg ${pyn} ${fname} "python!'file_oper_alongdims'!'tmean'!failed#"${Spyout} |
---|
979 | mv file_oper_alongdims_mean.nc ${filen} |
---|
980 | |
---|
981 | # Keeping the operations |
---|
982 | pyins=${pyHOME}"/nc_var.py -o file_oper_alongdims -S '"${vals}"' -f "${cfiles} |
---|
983 | pyins=${pyins}" -v "${CFvarn} |
---|
984 | echo " " >> ${odir}/all_statsvars.inf |
---|
985 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
986 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
987 | |
---|
988 | varkeep=':'${CFvarn}'mean:timestats' |
---|
989 | ;; |
---|
990 | # turbulence values |
---|
991 | 'turb') |
---|
992 | vals='turbulence|'${CFvarn} |
---|
993 | dims='time@time,'${dnz}'@'${vdnz}',lat@lat,lon@lon,pres@pres' |
---|
994 | |
---|
995 | pyout=`python ${pyHOME}/diagnostics.py -d ${dims} -v ${vals} -f ${cfiles}` |
---|
996 | pyn=$? |
---|
997 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
998 | ferrmsg ${pyn} ${fname} "python!'diagnostics'!'turbulence'!failed#"${Spyout} |
---|
999 | mv diagnostics.nc ${filen} |
---|
1000 | |
---|
1001 | # Keeping the operations |
---|
1002 | pyins="python "${pyHOME}"/diagnostics.py -d "${dims}" -v '"${vals} |
---|
1003 | pyins=${pyins}"' -f ${cfiles}" |
---|
1004 | echo " " >> ${odir}/all_statsvars.inf |
---|
1005 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
1006 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
1007 | |
---|
1008 | varkeep=':'${CFvarn}'turb' |
---|
1009 | ;; |
---|
1010 | # x-axis mean values |
---|
1011 | 'xmean') |
---|
1012 | vals='lon|-1,lon,mean,lon:lat:'${vdnz}':time:pres' |
---|
1013 | dims='time@time,'${dnz}'@'${vdnz}',lat@lat,lon@lon' |
---|
1014 | |
---|
1015 | pyout=`python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} \ |
---|
1016 | -f ${cfiles} -v ${CFvarn}` |
---|
1017 | pyn=$? |
---|
1018 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
1019 | ferrmsg ${pyn} ${fname} "python!'file_oper_alongdims'!'tmean'!failed#"${Spyout} |
---|
1020 | mv file_oper_alongdims_mean.nc ${filen} |
---|
1021 | |
---|
1022 | # Keeping the operations |
---|
1023 | pyins=${pyHOME}"/nc_var.py -o file_oper_alongdims -S '"${vals}"' -f "${cfiles} |
---|
1024 | pyins=${pyins}" -v "${CFvarn} |
---|
1025 | echo " " >> ${odir}/all_statsvars.inf |
---|
1026 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
1027 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
1028 | |
---|
1029 | varkeep=':'${CFvarn}'mean:lonstats' |
---|
1030 | ;; |
---|
1031 | # y-axis mean values |
---|
1032 | 'ymean') |
---|
1033 | vals='lat|-1,lat,mean,lon:lat:'${vdnz}':time:pres' |
---|
1034 | dims='time@time,'${dnz}'@'${vdnz}',lat@lat,lon@lon' |
---|
1035 | |
---|
1036 | pyout=`python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} \ |
---|
1037 | -f ${cfiles} -v ${CFvarn}` |
---|
1038 | pyn=$? |
---|
1039 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
1040 | ferrmsg ${pyn} ${fname} "python!'file_oper_alongdims'!'tmean'!failed#"${Spyout} |
---|
1041 | mv file_oper_alongdims_mean.nc ${filen} |
---|
1042 | |
---|
1043 | # Keeping the operations |
---|
1044 | pyins=${pyHOME}"/nc_var.py -o file_oper_alongdims -S '"${vals}"' -f "${cfiles} |
---|
1045 | pyins=${pyins}" -v "${CFvarn} |
---|
1046 | echo " " >> ${odir}/all_statsvars.inf |
---|
1047 | echo "# ${CFvarn}" "${vark}" >> ${odir}/all_statsvars.inf |
---|
1048 | echo ${pyins} >> ${odir}/all_statsvars.inf |
---|
1049 | |
---|
1050 | varkeep=':'${CFvarn}'mean:latstats' |
---|
1051 | ;; |
---|
1052 | # vertical aggregated values |
---|
1053 | 'zsum') |
---|
1054 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
1055 | exit |
---|
1056 | ;; |
---|
1057 | *) |
---|
1058 | echo ${errmsg} |
---|
1059 | echo " "${fname}": kind '"${vark}"' not ready !!" |
---|
1060 | exit |
---|
1061 | ;; |
---|
1062 | esac |
---|
1063 | cleaning_varsfile ${filen} ${CFvarn}':lon:lat:pres:time'${varkeep} |
---|
1064 | fi |
---|
1065 | |
---|
1066 | } |
---|
1067 | |
---|
1068 | function compute_combos(){ |
---|
1069 | # Function to compute the given list of combos |
---|
1070 | # Iwdir= input folder |
---|
1071 | # Owdir= output folder |
---|
1072 | # Files= files to use |
---|
1073 | # Testfiles= files for testing the wat of compute a given variable |
---|
1074 | # Moddims= dimensions of the input files |
---|
1075 | # Modvdims= variable dimensions of the input files |
---|
1076 | # VarCombo= ':' separated list of combos to compute |
---|
1077 | # Filescratch= do we need to start files from the scratch? |
---|
1078 | fname='compute_combos' |
---|
1079 | |
---|
1080 | Iwdir=$1 |
---|
1081 | Owdir=$2 |
---|
1082 | Files=$3 |
---|
1083 | Testfiles=$4 |
---|
1084 | Moddims=$5 |
---|
1085 | Modvdims=$6 |
---|
1086 | VarCombo=$7 |
---|
1087 | Filescratch=$8 |
---|
1088 | |
---|
1089 | varcos=`echo ${VarCombo} | tr ':' ' '` |
---|
1090 | for vco in ${varcos}; do |
---|
1091 | echo " "${vco} |
---|
1092 | CFvarn=`echo ${vco} | tr ';' ' ' | awk '{print $1}'` |
---|
1093 | cvar=`variable_compute ${Iwdir} ${CFvarn} ${Testfiles} | grep varcomp | \ |
---|
1094 | awk '{print $2}'` |
---|
1095 | CFv=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'` |
---|
1096 | vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'` |
---|
1097 | fileh=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'` |
---|
1098 | modv=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'` |
---|
1099 | diagv=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'` |
---|
1100 | |
---|
1101 | # if $(index_string ${vark} 'pinterp') -ne -1; then |
---|
1102 | # fhead=${fileh}'p' |
---|
1103 | # else |
---|
1104 | # fhead=${fileh} |
---|
1105 | # fi |
---|
1106 | combs=`echo ${vco} | tr ';' ' ' | awk '{print $2}' | tr '@' ' '` |
---|
1107 | ifile=${CFv}_${fhead} |
---|
1108 | for comb in ${combs}; do |
---|
1109 | combcvar=${CFv}'|'${comb}'|'${fhead}'|'${modv}'|'${diagv} |
---|
1110 | compute_statistics ${Iwdir} ${ifile}.nc ${Owdir} ${combcvar} ${Moddims} \ |
---|
1111 | ${Modvdims} ${Filescratch} ${ifile}.nc |
---|
1112 | ifile=${ifile}_${comb} |
---|
1113 | |
---|
1114 | # Adding 'surnames' to the variable's name |
---|
1115 | if test ${comb} = 'turb'; then |
---|
1116 | CFv=${CFv}'turb' |
---|
1117 | fi |
---|
1118 | if $(isInlist ${varmeanname} ${comb}); then |
---|
1119 | CFv=${CFv}'mean' |
---|
1120 | fi |
---|
1121 | |
---|
1122 | isc=`expr ${isc} + 1` |
---|
1123 | # End of combo |
---|
1124 | done |
---|
1125 | # End of combo variables |
---|
1126 | done |
---|
1127 | |
---|
1128 | return |
---|
1129 | } |
---|
1130 | |
---|
1131 | function createlist_plots(){ |
---|
1132 | # Function to create the list of plots to draw |
---|
1133 | # Drawplots= ':' separated list of plots to draw |
---|
1134 | # KindPlots= ':' list of plots to draw this time |
---|
1135 | |
---|
1136 | fname='createlist_plots' |
---|
1137 | |
---|
1138 | Drawplots=$1 |
---|
1139 | KindPlots=$2 |
---|
1140 | |
---|
1141 | drwplts=`echo ${Drawplots} | tr ':' ' '` |
---|
1142 | ikp=1 |
---|
1143 | plots='' |
---|
1144 | for drw in ${drwplts}; do |
---|
1145 | if $(isInlist ${KindPlots} ${drw}); then |
---|
1146 | case ${drw} in |
---|
1147 | 'map2Dsfc') |
---|
1148 | plts=${pltmap2Dsfc} |
---|
1149 | ;; |
---|
1150 | 'map3D') |
---|
1151 | plts=${pltmap3D} |
---|
1152 | ;; |
---|
1153 | 'shadcont2Dsfc') |
---|
1154 | plts=${pltshadcont2Dsfc} |
---|
1155 | ;; |
---|
1156 | 'shadconthovmsfc') |
---|
1157 | plts=${pltshadconthovmsfc} |
---|
1158 | ;; |
---|
1159 | 'shadcont2Dzsec') |
---|
1160 | plts=${pltshadcont2Dzsec} |
---|
1161 | ;; |
---|
1162 | *) |
---|
1163 | echo ${errmsg} |
---|
1164 | echo " "${main}": plot kind '"${drw}"' not ready !!" |
---|
1165 | exit |
---|
1166 | esac |
---|
1167 | # Do we have plots for this kind? |
---|
1168 | Lkplots=`expr length ${plts}'0'` |
---|
1169 | if test ${Lkplots} -lt 2; then |
---|
1170 | ferrmsg 1 ${main} "plot!kind!"${drw}"!without!variables" |
---|
1171 | fi |
---|
1172 | kplots=`list_add_label ${plts} ${drw} + beg` |
---|
1173 | if test ${ikp} -eq 1; then |
---|
1174 | plots=${kplots} |
---|
1175 | else |
---|
1176 | plots=${plots}':'${kplots} |
---|
1177 | fi |
---|
1178 | ikp=`expr ${ikp} + 1` |
---|
1179 | fi |
---|
1180 | # End of coincident direct plots |
---|
1181 | done |
---|
1182 | |
---|
1183 | echo ${fname}" listplots= "${plots}_${ikp} |
---|
1184 | } |
---|
1185 | |
---|
1186 | function createlist_diffplots(){ |
---|
1187 | # Function to create the list of diff plots to draw |
---|
1188 | # Drawplots= ':' separated list of plots to draw |
---|
1189 | # KindPlots= ':' list of plots to draw this time |
---|
1190 | |
---|
1191 | fname='createlist_diffplots' |
---|
1192 | |
---|
1193 | Drawplots=$1 |
---|
1194 | KindPlots=$2 |
---|
1195 | |
---|
1196 | drwplts=`echo ${Drawplots} | tr ':' ' '` |
---|
1197 | ikp=1 |
---|
1198 | plots='' |
---|
1199 | for drw in ${drwplts}; do |
---|
1200 | if $(isInlist ${KindPlots} ${drw}); then |
---|
1201 | case ${drw} in |
---|
1202 | 'map2Dsfc') |
---|
1203 | plts=${pltdiffmap2Dsfc} |
---|
1204 | ;; |
---|
1205 | 'map3D') |
---|
1206 | plts=${pltdiffmap3D} |
---|
1207 | ;; |
---|
1208 | 'shadcont2Dsfc') |
---|
1209 | plts=${pltdiffshadcont2Dsfc} |
---|
1210 | ;; |
---|
1211 | 'shadconthovmsfc') |
---|
1212 | plts=${pltdiffshadconthovmsfc} |
---|
1213 | ;; |
---|
1214 | 'shadcont2Dzsec') |
---|
1215 | plts=${pltdiffshadcont2Dzsec} |
---|
1216 | ;; |
---|
1217 | *) |
---|
1218 | echo ${errmsg} |
---|
1219 | echo " "${main}": plot kind '"${drw}"' not ready !!" |
---|
1220 | exit |
---|
1221 | esac |
---|
1222 | # Do we have plots for this kind? |
---|
1223 | Lkplots=`expr length ${plts}'0'` |
---|
1224 | if test ${Lkplots} -lt 2; then |
---|
1225 | ferrmsg 1 ${main} "plot!kind!"${drw}"!without!variables" |
---|
1226 | fi |
---|
1227 | kplots=`list_add_label ${plts} ${drw} + beg` |
---|
1228 | if test ${ikp} -eq 1; then |
---|
1229 | plots=${kplots} |
---|
1230 | else |
---|
1231 | plots=${plots}':'${kplots} |
---|
1232 | fi |
---|
1233 | ikp=`expr ${ikp} + 1` |
---|
1234 | fi |
---|
1235 | # End of coincident direct plots |
---|
1236 | done |
---|
1237 | |
---|
1238 | echo ${fname}" listplots= "${plots}_${ikp} |
---|
1239 | } |
---|
1240 | |
---|
1241 | function draw_plot(){ |
---|
1242 | # Function to carry out the drawing of the plots |
---|
1243 | # plot= [kplot]+[varn1]|[kind1]#[varn2]|[kind2]#.... |
---|
1244 | # diffmap2Dsfc: 2D map of surface differences values of 1 variable |
---|
1245 | # diffmap2Dz: 2D map of 3D differences values of 1 variable |
---|
1246 | # map2Dsfc: 2D map of surface values of 1 variable |
---|
1247 | # map3D: 2D map of 3D values of 1 variable |
---|
1248 | # shadconthovmsfc: Hovmoeller diagrams of 2 variable at the surface in shadow and the other in contourn |
---|
1249 | # shadcont2Dsfc: 2D map of shadow (1st variable) and countour (2nd variable) [stvar1]#[stvar2] |
---|
1250 | # shadcont2Dzsec: 2D map of vertical section of 2 variables one in shadow and the other in contourn |
---|
1251 | # |
---|
1252 | # ':' separated list of statitsics variable values are given as: [var]|[kind(including combo values)] |
---|
1253 | # in figures with more than 1 variable, use '#' to separate them |
---|
1254 | # odir= working directory |
---|
1255 | # headf= head of the file |
---|
1256 | # additiona= additional value when necessary |
---|
1257 | # 'diff': diff plots (to use `diffspecificvarplot' instead) |
---|
1258 | fname='draw_plot' |
---|
1259 | |
---|
1260 | plot=$1 |
---|
1261 | odir=$2 |
---|
1262 | headf=$3 |
---|
1263 | scratch=$4 |
---|
1264 | additional=$5 |
---|
1265 | |
---|
1266 | if test $# -eq 5; then |
---|
1267 | if test ${additional} = 'diff'; then |
---|
1268 | specvarplot=${diffspecificvarplot} |
---|
1269 | else |
---|
1270 | specvarplot=${specificvarplot} |
---|
1271 | fi |
---|
1272 | fi |
---|
1273 | |
---|
1274 | cd ${odir} |
---|
1275 | |
---|
1276 | kplot=`echo ${plot} | tr '+' ' ' | awk '{print $1}'` |
---|
1277 | plotvals=`echo ${plot} | tr '+' ' ' | awk '{print $2}'` |
---|
1278 | |
---|
1279 | # Assuming that multiple variables will be separated by '#' |
---|
1280 | nvars=`echo ${plotvals} | tr '#' ' ' | wc -w | awk '{print $1}'` |
---|
1281 | |
---|
1282 | # Model and experiment |
---|
1283 | mod=`echo ${odir} | tr '/' '\n' | tail -n 2 | head -n 1` |
---|
1284 | exp=`echo ${odir} | tr '/' '\n' | tail -n 1` |
---|
1285 | |
---|
1286 | figfiles='' |
---|
1287 | varinfilen='' |
---|
1288 | CFvars='' |
---|
1289 | figvarparam='' |
---|
1290 | varkinds='' |
---|
1291 | vardims='' |
---|
1292 | if test ${nvars} -ge 1; then |
---|
1293 | figname=${kplot}_${headf} |
---|
1294 | iv=1 |
---|
1295 | while test $iv -le ${nvars}; do |
---|
1296 | varkind=`echo ${plotvals} | tr '#' '\n' | head -n ${iv} | tail -n 1` |
---|
1297 | varn=`echo ${varkind} | tr '|' ' ' | awk '{print $1}'` |
---|
1298 | kind=`echo ${varkind} | tr '|' ' ' | awk '{print $2}'` |
---|
1299 | |
---|
1300 | # Do we have processed the given variable? |
---|
1301 | nfiles=`ls -1 ${odir}/${varn}_${headf}*.nc | wc -l | awk '{print $1}'` |
---|
1302 | if test ${nfiles} -eq 0; then |
---|
1303 | echo " "${fname}": there are no files for variable '"${varn}"' skiping it !!" |
---|
1304 | return |
---|
1305 | fi |
---|
1306 | |
---|
1307 | Nopers=`echo ${kind} | tr '@' ' ' | wc -w | awk '{print $1}'` |
---|
1308 | if test ${Nopers} -eq 1; then |
---|
1309 | if $(isInlist ${varmeanname} ${kind}); then |
---|
1310 | vn=${varn}'mean' |
---|
1311 | else |
---|
1312 | vn=${varn} |
---|
1313 | fi |
---|
1314 | if test ${op} = 'turb'; then |
---|
1315 | vn=${vn}'turb' |
---|
1316 | fi |
---|
1317 | else |
---|
1318 | oprs=`echo ${kind} | tr '@' ' '` |
---|
1319 | vn=${varn} |
---|
1320 | for op in ${oprs}; do |
---|
1321 | if $(isInlist ${varmeanname} ${op}); then |
---|
1322 | vn=${vn}'mean' |
---|
1323 | fi |
---|
1324 | if test ${op} = 'turb'; then |
---|
1325 | vn=${vn}'turb' |
---|
1326 | fi |
---|
1327 | done |
---|
1328 | fi |
---|
1329 | filen=`stats_filename ${varn} ${kind} ${headf}` |
---|
1330 | dims=`python ${pyHOME}/nc_var.py -o idims -f ${filen} | grep alldims | \ |
---|
1331 | awk '{print $3}'` |
---|
1332 | |
---|
1333 | if test ${iv} -eq 1; then |
---|
1334 | if test ${Nopers} -gt 1; then |
---|
1335 | varkinds=${varn}'|('$(echo ${kind} | tr '@' '|')')' |
---|
1336 | else |
---|
1337 | varkinds=${varkind} |
---|
1338 | fi |
---|
1339 | CFvars=${varn} |
---|
1340 | varinfilen=${vn} |
---|
1341 | figfiles=${filen} |
---|
1342 | vardims=${dims} |
---|
1343 | if $(isInlist ${dims} 'time'); then |
---|
1344 | tunits=`python ${pyHOME}/nc_var.py -o ivattrs -f ${filen} -v time | \ |
---|
1345 | grep units | grep -v '#' | awk '{print $3}'` |
---|
1346 | fi |
---|
1347 | else |
---|
1348 | if test ${Nopers} -gt 1; then |
---|
1349 | varkinds=${varkinds}':'${varn}'|('$(echo ${kind} | tr '@' '|')')' |
---|
1350 | else |
---|
1351 | varkinds=${varkinds}':'${varkind} |
---|
1352 | fi |
---|
1353 | CFvars=${CFvars}':'${varn} |
---|
1354 | varinfilen=${varinfilen}':'${vn} |
---|
1355 | figfiles=${figfiles}':'${filen} |
---|
1356 | vardims=${vardims}':'${dims} |
---|
1357 | fi |
---|
1358 | |
---|
1359 | figname=${figname}'_'${vn}'-'$(echo ${kind} | tr '@' '-') |
---|
1360 | |
---|
1361 | # Getting plot variable configuration (using variable name inside the file?) |
---|
1362 | specific=false |
---|
1363 | # if $(isInlist ${specvarplot} ${varn}); then |
---|
1364 | if test $(index_string ${specvarplot} ${varn}) -ne -1; then |
---|
1365 | vals=`list_filter ${specvarplot} ${varn}` |
---|
1366 | kvals=`list_filter ${vals} ${kind}` |
---|
1367 | Lkvals=`expr length ${kvals}'0'` |
---|
1368 | if test ${Lkvals} -gt 1; then |
---|
1369 | fkvals=`list_filter ${kvals} ${kplot}` |
---|
1370 | Lfkvals=`expr length ${fkvals}'0'` |
---|
1371 | if test ${Lfkvals} -gt 1; then |
---|
1372 | specific=true |
---|
1373 | minval=`echo ${fkvals} | tr '|' ' ' | awk '{print $4}'` |
---|
1374 | maxval=`echo ${fkvals} | tr '|' ' ' | awk '{print $5}'` |
---|
1375 | colorbar=`echo ${fkvals} | tr '|' ' ' | awk '{print $6}'` |
---|
1376 | cntformat=`echo ${fkvals} | tr '|' ' ' | awk '{print $7}'` |
---|
1377 | colorcnt=`echo ${fkvals} | tr '|' ' ' | awk '{print $8}' | tr ':' ' ' | awk '{print $1}'` |
---|
1378 | fi |
---|
1379 | fi |
---|
1380 | fi |
---|
1381 | if ! ${specific}; then |
---|
1382 | allvals=`python ${pyHOME}/drawing.py -o variable_values -S ${varn} | \ |
---|
1383 | grep all_values | awk '{print $3}'` |
---|
1384 | pyn=$? |
---|
1385 | ferrmsg ${pyn} ${fname} "python!'variable_values'!'${varn}'!failed#" |
---|
1386 | minval=`echo ${allvals} | tr ',' ' ' | awk '{print $3}'` |
---|
1387 | maxval=`echo ${allvals} | tr ',' ' ' | awk '{print $4}'` |
---|
1388 | colorbar=`echo ${allvals} | tr ',' ' ' | awk '{print $7}'` |
---|
1389 | cntformat='%g' |
---|
1390 | colorcnt='black' |
---|
1391 | fi |
---|
1392 | |
---|
1393 | # Graphical parameters for each variable in the plot |
---|
1394 | if test ${iv} -eq 1; then |
---|
1395 | figvarparam=${minval}'|'${maxval}'|'${colorbar}'|'${cntformat}'|'${colorcnt} |
---|
1396 | else |
---|
1397 | figvarparam=${figvarparam}':'${minval}'|'${maxval}'|'${colorbar}'|' |
---|
1398 | figvarparam=${figvarparam}${cntformat}'|'${colorcnt} |
---|
1399 | fi |
---|
1400 | |
---|
1401 | iv=`expr ${iv} + 1` |
---|
1402 | # End of number of variables of the plot |
---|
1403 | done |
---|
1404 | fi |
---|
1405 | figname=${figname}.${kindfig} |
---|
1406 | |
---|
1407 | if ${scratch}; then rm ${figname} >& /dev/null; fi |
---|
1408 | if test ! -f ${figname}; then |
---|
1409 | case ${kplot} in |
---|
1410 | 'diffmap2Dsfc') |
---|
1411 | echo " "${fname}": kind of plot '"${kplot}"' not ready !!" |
---|
1412 | exit |
---|
1413 | ;; |
---|
1414 | 'diffmap2Dz') |
---|
1415 | echo " "${fname}": kind of plot '"${kplot}"' not ready !!" |
---|
1416 | exit |
---|
1417 | ;; |
---|
1418 | 'map2Dsfc') |
---|
1419 | echo " "${fname}": kind of plot '"${kplot}"' not ready !!" |
---|
1420 | exit |
---|
1421 | ;; |
---|
1422 | 'map3D') |
---|
1423 | echo " "${fname}": kind of plot '"${kplot}"' not ready !!" |
---|
1424 | exit |
---|
1425 | ;; |
---|
1426 | 'shadcont2Dsfc') |
---|
1427 | figtit=${mod}'|'${exp}'|'$(echo ${varkinds} | tr ':' '|') |
---|
1428 | shdstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $1}'` |
---|
1429 | cntstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $2}'` |
---|
1430 | figfs=`echo ${figfiles} | tr ':' ','` |
---|
1431 | srange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1432 | awk '{print $1","$2}'` |
---|
1433 | cbar=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1434 | awk '{print $3}'` |
---|
1435 | crange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1436 | awk '{print $1","$2}'` |
---|
1437 | cline=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1438 | awk '{print $5}'` |
---|
1439 | cfmt=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1440 | awk '{print $4}'` |
---|
1441 | |
---|
1442 | graphvals=$(echo ${CFvars} | tr ':' ',') |
---|
1443 | graphvals=${graphvals}':lon|-1,lat|-1:lon|-1,lat|-1:lon:lat:'${cbar}':fixc,' |
---|
1444 | graphvals=${graphvals}${cline}':'${cfmt}':'${srange}':'${crange}',9:' |
---|
1445 | graphvals=${graphvals}${figtit}':'${kindfig}':None:'${mapval} |
---|
1446 | |
---|
1447 | pyout=`python ${pyHOME}/drawing.py -f ${figfs} -o draw_2D_shad_cont \ |
---|
1448 | -S ${graphvals} -v $(echo ${varinfilen} | tr ':' ',')` |
---|
1449 | pyn=$? |
---|
1450 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
1451 | ferrmsg ${pyn} ${fname} "python!'draw_2D_shad_cont'!failed#"${Spyout} |
---|
1452 | mv 2Dfields_shadow-contour.${kindfig} ${figname} |
---|
1453 | |
---|
1454 | # keeping all figures |
---|
1455 | plotins="python "${pyHOME}"/drawing.py -f "${figfs}" -o draw_2D_shad_cont " |
---|
1456 | plotins=${plotins}"-S '"${graphvals}"' -v "$(echo ${varinfilen} | tr ':' ',') |
---|
1457 | echo " " >> ${odir}/all_figures.inf |
---|
1458 | echo "#"$(echo $f{igtit} | tr '|' ' ') >> ${odir}/all_figures.inf |
---|
1459 | echo ${plotins} >> ${odir}/all_figures.inf |
---|
1460 | ;; |
---|
1461 | 'shadconthovmsfc') |
---|
1462 | shdstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $1}'` |
---|
1463 | cntstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $2}'` |
---|
1464 | |
---|
1465 | # It is assumed that if the space variable is 'lon': is desired a (lon, time) plot |
---|
1466 | # it it is 'lat': then (time, lat) plot |
---|
1467 | dimspace='xxx' |
---|
1468 | if $( isInlist ${vardims} 'lon'); then |
---|
1469 | spacedim='lon' |
---|
1470 | figtit=${mod}'|'${exp}'|mean|longitudinal|evolution|of|'${shdstdn}'|&|' |
---|
1471 | figtit=${figtit}${cntstdn} |
---|
1472 | reverse='None' |
---|
1473 | dims=${spacedim}'|-1,time|-1;'${spacedim}'|-1,time|-1;'${spacedim}';time' |
---|
1474 | else |
---|
1475 | spacedim='lat' |
---|
1476 | figtit=${mod}'|'${exp}'|mean|meridional|evolution|of|'${shdstdn}'|&|' |
---|
1477 | figtit=${figtit}${cntstdn} |
---|
1478 | reverse='None' |
---|
1479 | dims=${spacedim}'|-1,time|-1;'${spacedim}'|-1,time|-1;time;'${spacedim} |
---|
1480 | fi |
---|
1481 | |
---|
1482 | figfs=`echo ${figfiles} | tr ':' ','` |
---|
1483 | srange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1484 | awk '{print $1","$2}'` |
---|
1485 | cbar=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1486 | awk '{print $3}'` |
---|
1487 | crange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1488 | awk '{print $1","$2}'` |
---|
1489 | cline=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1490 | awk '{print $5}'` |
---|
1491 | cfmt=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1492 | awk '{print $4}'` |
---|
1493 | |
---|
1494 | graphvals=$(echo ${CFvars} | tr ':' ',') |
---|
1495 | graphvals=${shdstdn}','${cntstdn}';'${dims}';' |
---|
1496 | graphvals=${graphvals}${cbar}';fixsigc,'${cline}';'${cfmt}';'${srange}';' |
---|
1497 | graphvals=${graphvals}${crange}',9;'${figtit}';'${kindfig}';'${reverse}';' |
---|
1498 | graphvals=${graphvals}'time|'${tunits}'|'${timekind}'|'${timefmt}'|' |
---|
1499 | graphvals=${graphvals}${timelabel} |
---|
1500 | |
---|
1501 | python ${pyHOME}/drawing.py -f ${figfs} -o draw_2D_shad_cont_time \ |
---|
1502 | -S ${graphvals} -v $(echo ${varinfilen} | tr ':' ',') |
---|
1503 | mv 2Dfields_shadow-contour.${kindfig} ${figname} |
---|
1504 | |
---|
1505 | # keeping all figures |
---|
1506 | plotins="python "${pyHOME}"/drawing.py -f "${figfs}" -o draw_2D_shad_cont_time" |
---|
1507 | plotins=${plotins}" -S ${graphvals} -v "$(echo ${varinfilen} | tr ':' ',') |
---|
1508 | echo " " >> ${odir}/all_figures.inf |
---|
1509 | echo "#"$(echo $f{igtit} | tr '|' ' ') >> ${odir}/all_figures.inf |
---|
1510 | echo ${plotins} >> ${odir}/all_figures.inf |
---|
1511 | ;; |
---|
1512 | 'shadcont2Dzsec') |
---|
1513 | shdstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $1}'` |
---|
1514 | cntstdn=`echo ${CFvars} | tr ':' ' ' | awk '{print $2}'` |
---|
1515 | # It is assumed that if the space variable is 'lon': is desired a (lon, pres) plot |
---|
1516 | # it it is 'lat': then (pres, lat) plot |
---|
1517 | dimspace='xxx' |
---|
1518 | if $( isInlist ${vardims} 'lon'); then |
---|
1519 | spacedim='lon' |
---|
1520 | figtit=${mod}'|'${exp}'|mean|longitudinal|vertical|cross|section|of|' |
---|
1521 | figtit=${figtit}${shdstdn}'|&|'${cntstdn} |
---|
1522 | else |
---|
1523 | spacedim='lat' |
---|
1524 | figtit=${mod}'|'${exp}'|mean|meridional|vertical|cross|section|of|' |
---|
1525 | figtit=${figtit}${shdstdn}'|&|'${cntstdn} |
---|
1526 | fi |
---|
1527 | reverse='flip@y' |
---|
1528 | dims=${spacedim}'|-1,pres|-1:'${spacedim}'|-1,pres|-1:'${spacedim}':pres' |
---|
1529 | |
---|
1530 | figtit=${mod}'|'${exp}'|'$(echo ${varkinds} | tr ':' '|') |
---|
1531 | figfs=`echo ${figfiles} | tr ':' ','` |
---|
1532 | srange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1533 | awk '{print $1","$2}'` |
---|
1534 | cbar=`echo ${figvarparam} | tr ':' ' ' | awk '{print $1}' | tr '|' ' ' | \ |
---|
1535 | awk '{print $3}'` |
---|
1536 | crange=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1537 | awk '{print $1","$2}'` |
---|
1538 | cline=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1539 | awk '{print $5}'` |
---|
1540 | cfmt=`echo ${figvarparam} | tr ':' ' ' | awk '{print $2}' | tr '|' ' ' | \ |
---|
1541 | awk '{print $4}'` |
---|
1542 | |
---|
1543 | graphvals=$(echo ${CFvars} | tr ':' ',') |
---|
1544 | graphvals=${graphvals}':'${dims}':'${cbar}':fixc,' |
---|
1545 | graphvals=${graphvals}${cline}':'${cfmt}':'${srange}':'${crange}',9:' |
---|
1546 | graphvals=${graphvals}${figtit}':'${kindfig}':'${reverse}':None' |
---|
1547 | |
---|
1548 | pyout=`python ${pyHOME}/drawing.py -f ${figfs} -o draw_2D_shad_cont \ |
---|
1549 | -S ${graphvals} -v $(echo ${varinfilen} | tr ':' ',')` |
---|
1550 | pyn=$? |
---|
1551 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
1552 | ferrmsg ${pyn} ${fname} "python!'draw_2D_shad_cont'!failed#"${Spyout} |
---|
1553 | mv 2Dfields_shadow-contour.${kindfig} ${figname} |
---|
1554 | |
---|
1555 | # keeping all figures |
---|
1556 | plotins="python "${pyHOME}"/drawing.py -f "${figfs}" -o draw_2D_shad_cont " |
---|
1557 | plotins=${plotins}"-S '"${graphvals}"' -v "$(echo ${varinfilen} | tr ':' ',') |
---|
1558 | echo " " >> ${odir}/all_figures.inf |
---|
1559 | echo "#"$(echo $f{igtit} | tr '|' ' ') >> ${odir}/all_figures.inf |
---|
1560 | echo ${plotins} >> ${odir}/all_figures.inf |
---|
1561 | ;; |
---|
1562 | *) |
---|
1563 | echo ${errormsg} |
---|
1564 | echo " "${fname}": plot kind '"${kplot}"' not ready !!" |
---|
1565 | exit |
---|
1566 | ;; |
---|
1567 | esac |
---|
1568 | fi |
---|
1569 | |
---|
1570 | #LLUIS |
---|
1571 | |
---|
1572 | } |
---|
1573 | |
---|
1574 | ####### ####### |
---|
1575 | ## MAIN |
---|
1576 | ####### |
---|
1577 | rootsh=`pwd` |
---|
1578 | |
---|
1579 | # Uploading environment |
---|
1580 | uploadvars model_graphics.dat |
---|
1581 | |
---|
1582 | if test ${scratch} = 'true'; then |
---|
1583 | scratch=true |
---|
1584 | echo ${warnmsg} |
---|
1585 | echo " "${main}": starting from the SCRATCH !!" |
---|
1586 | echo " 10 seconds left!!" |
---|
1587 | filescratch=true |
---|
1588 | figscratch=true |
---|
1589 | sleep 10 |
---|
1590 | else |
---|
1591 | scratch=false |
---|
1592 | if test ${filescratch} = 'true'; then |
---|
1593 | filescratch=true |
---|
1594 | echo ${warnmsg} |
---|
1595 | echo " "${main}": files starting from the SCRATCH !!" |
---|
1596 | echo " 5 seconds left!!" |
---|
1597 | sleep 5 |
---|
1598 | else |
---|
1599 | filescratch=false |
---|
1600 | fi |
---|
1601 | if test ${figscratch} = 'true'; then |
---|
1602 | figscratch=true |
---|
1603 | echo ${warnmsg} |
---|
1604 | echo " "${main}": figures starting from the SCRATCH !!" |
---|
1605 | echo " 5 seconds left!!" |
---|
1606 | sleep 5 |
---|
1607 | else |
---|
1608 | figscratch=false |
---|
1609 | fi |
---|
1610 | fi |
---|
1611 | |
---|
1612 | if test ${addfiles} = 'true'; then |
---|
1613 | addfiles=true |
---|
1614 | else |
---|
1615 | addfiles=false |
---|
1616 | fi |
---|
1617 | |
---|
1618 | if test ${addfigures} = 'true'; then |
---|
1619 | addfigures=true |
---|
1620 | else |
---|
1621 | addfigures=false |
---|
1622 | fi |
---|
1623 | |
---|
1624 | if test ${debug} = 'true'; then |
---|
1625 | dbg=true |
---|
1626 | else |
---|
1627 | dbg=false |
---|
1628 | fi |
---|
1629 | |
---|
1630 | timeval='tstep' |
---|
1631 | zval='null' |
---|
1632 | dimval='lon,lat,pressure,time' |
---|
1633 | |
---|
1634 | compute=0 |
---|
1635 | computetlon=false |
---|
1636 | plot=false |
---|
1637 | single2Dplot=false |
---|
1638 | lonZsec=false |
---|
1639 | differences=true |
---|
1640 | |
---|
1641 | combosfile=${pyHOME}/diagnostics.inf |
---|
1642 | |
---|
1643 | ####### ###### ##### #### ### ## # |
---|
1644 | |
---|
1645 | mods=`echo ${models} | tr ':' ' '` |
---|
1646 | varks=`echo ${varkinds} | tr ':' ' '` |
---|
1647 | |
---|
1648 | # Models loop |
---|
1649 | ## |
---|
1650 | for mod in ${mods}; do |
---|
1651 | case ${mod} in |
---|
1652 | 'WRF') |
---|
1653 | exps=`echo ${WRFexps} | tr ':' ' '` |
---|
1654 | fheaders=`echo ${WRFheaders} | tr ':' ' '` |
---|
1655 | ;; |
---|
1656 | 'LMDZ') |
---|
1657 | exps=`echo ${LMDZexps} | tr ':' ' '` |
---|
1658 | fheaders=`echo ${LMDZheaders} | tr ':' ' '` |
---|
1659 | ;; |
---|
1660 | 'WRF_LMDZ') |
---|
1661 | exps=`echo ${WRF_LMDZexps} | tr ':' ' '` |
---|
1662 | fheaders=`echo ${WRF_LMDZheaders} | tr ':' ' '` |
---|
1663 | ;; |
---|
1664 | '*') |
---|
1665 | echo ${errmsg} |
---|
1666 | echo " "${main}": model '"${mod}"' not ready!!" |
---|
1667 | exit |
---|
1668 | ;; |
---|
1669 | esac |
---|
1670 | |
---|
1671 | modinf=`${pyHOME}/nc_var.py -o model_characteristics -f None -S ${mod} | \ |
---|
1672 | grep singleline | awk '{print $2}'` |
---|
1673 | ferrmsg $? $main "python!'model_characteristics'!failed" |
---|
1674 | dnx=`echo ${modinf} | tr ';' '\n' | grep dimxn | tr '=' ' ' | awk '{print $2}'` |
---|
1675 | dny=`echo ${modinf} | tr ';' '\n' | grep dimyn | tr '=' ' ' | awk '{print $2}'` |
---|
1676 | dnz=`echo ${modinf} | tr ';' '\n' | grep dimzn | tr '=' ' ' | awk '{print $2}'` |
---|
1677 | dnt=`echo ${modinf} | tr ';' '\n' | grep dimtn | tr '=' ' ' | awk '{print $2}'` |
---|
1678 | vdnx=`echo ${modinf} | tr ';' '\n' | grep vardxn | tr '=' ' ' | awk '{print $2}'` |
---|
1679 | vdny=`echo ${modinf} | tr ';' '\n' | grep vardyn | tr '=' ' ' | awk '{print $2}'` |
---|
1680 | vdnz=`echo ${modinf} | tr ';' '\n' | grep vardzn | tr '=' ' ' | awk '{print $2}'` |
---|
1681 | vdnt=`echo ${modinf} | tr ';' '\n' | grep vardtn | tr '=' ' ' | awk '{print $2}'` |
---|
1682 | echo ${mod} |
---|
1683 | echo " dims: "${dnx}", "${dny}", "${dnz}", "${dnt} |
---|
1684 | echo " var dims: "${vdnx}", "${vdny}", "${vdnz}", "${vdnt} |
---|
1685 | moddims=${dnx}','${dny}','${dnz}','${dnt} |
---|
1686 | modvdims=${vdnx}','${vdny}','${vdnz}','${vdnt} |
---|
1687 | |
---|
1688 | # Experiments loop |
---|
1689 | ## |
---|
1690 | for exp in ${exps}; do |
---|
1691 | echo " "${exp}"..." |
---|
1692 | iwdir=${ifold}/${mod}/${exp} |
---|
1693 | |
---|
1694 | # Does input folder exist? |
---|
1695 | if test ! -d ${iwdir}; then |
---|
1696 | echo ${errmsg} |
---|
1697 | echo " "${main}": folder '"${iwdir}"' does not exist !!" |
---|
1698 | exit |
---|
1699 | fi |
---|
1700 | |
---|
1701 | owdir=${ofold}/${mod}/${exp} |
---|
1702 | mkdir -p ${owdir} |
---|
1703 | |
---|
1704 | # Need to pass to analyze all the data? |
---|
1705 | if ${filescratch}; then |
---|
1706 | rm ${owdir}/varcompute.inf >& /dev/null |
---|
1707 | rm ${owdir}/all_computevars.inf >& /dev/null |
---|
1708 | rm ${owdir}/all_statsvars.inf >& /dev/null |
---|
1709 | |
---|
1710 | echo "## Computation of variables " > ${owdir}/all_computevars.inf |
---|
1711 | echo "## Computation of statistics " > ${owdir}/all_statsvars.inf |
---|
1712 | fi |
---|
1713 | |
---|
1714 | if ${addfiles}; then |
---|
1715 | rm ${owdir}/varcompute.inf >& /dev/null |
---|
1716 | fi |
---|
1717 | |
---|
1718 | if test ! -f ${owdir}/varcompute.inf; then |
---|
1719 | |
---|
1720 | # Does input folder has header files? |
---|
1721 | cd ${iwdir} |
---|
1722 | files='' |
---|
1723 | testfiles='' |
---|
1724 | ih=1 |
---|
1725 | for fh in ${fheaders}; do |
---|
1726 | if ${filescratch}; then rm ${owdir}/*_${fh}*.nc >& /dev/null; fi |
---|
1727 | |
---|
1728 | files1h=`ls -1 ${fh}* | tr '\n' '@'` |
---|
1729 | Lfiles1h=`expr length ${files1h}'0'` |
---|
1730 | if test ${Lfiles1h} -lt 2; then |
---|
1731 | ferrmsg 1 $main "folder!:!"${iwdir}"!does!not!contain!files!"${fh}"*" |
---|
1732 | fi |
---|
1733 | testfiles1h=`ls -1 ${fh}* | head -n 1` |
---|
1734 | if test ${ih} -eq 1; then |
---|
1735 | files=${fh}'|'${files1h} |
---|
1736 | testfiles=${fh}'|'${testfiles1h} |
---|
1737 | else |
---|
1738 | files=${files}','${fh}'|'${files1h} |
---|
1739 | testfiles=${testfiles}'@'${fh}'|'${testfiles1h} |
---|
1740 | fi |
---|
1741 | ih=`expr ${ih} + 1` |
---|
1742 | done |
---|
1743 | testfs=`echo ${testfiles} | tr '@' ' '` |
---|
1744 | cd ${rootsh} |
---|
1745 | |
---|
1746 | varcompt=`compvars_listconstruct ${varkinds} $(echo ${testfiles} | tr '@' ':') \ |
---|
1747 | | grep varcompute | awk '{print $3}'` |
---|
1748 | |
---|
1749 | varcompute=`echo ${varcompt} | tr '_' ' ' | awk '{print $1}'` |
---|
1750 | itotv=`echo ${varcompt} | tr '_' ' ' | awk '{print $2}'` |
---|
1751 | combo=`echo ${varcompt} | tr '_' ' ' | awk '{print $3}'` |
---|
1752 | |
---|
1753 | # Outwritting the varcompute to avoid next time (if it is not filescratch!) |
---|
1754 | cat << EOF > ${owdir}/varcompute.inf |
---|
1755 | files: ${files} |
---|
1756 | varcompute: ${varcompute} |
---|
1757 | itotv: ${itotv} |
---|
1758 | testfs: ${testfiles} |
---|
1759 | combo: ${combo} |
---|
1760 | EOF |
---|
1761 | else |
---|
1762 | echo $warnmsg |
---|
1763 | echo " "${main}": getting already data information from the experiment!" |
---|
1764 | files=`cat ${owdir}/varcompute.inf | grep files | awk '{print $2}'` |
---|
1765 | varcompute=`cat ${owdir}/varcompute.inf | grep varcompute | awk '{print $2}'` |
---|
1766 | itotv=`cat ${owdir}/varcompute.inf | grep itotv | awk '{print $2}'` |
---|
1767 | testfiles=`cat ${owdir}/varcompute.inf | grep testfs | awk '{print $2}'` |
---|
1768 | combo=`cat ${owdir}/varcompute.inf | grep 'combo:' | awk '{print $2}'` |
---|
1769 | # End of avoiding to repeat all the experiment search |
---|
1770 | fi |
---|
1771 | |
---|
1772 | echo " For experiment '"${exp}"' is required to compute: "${itotv}" variables" |
---|
1773 | # Computing files for each variable |
---|
1774 | ## |
---|
1775 | echo " Computing all variables ..." |
---|
1776 | |
---|
1777 | compute_vars ${iwdir} ${owdir} ${files} ${moddims} ${modvdims} ${varcompute} \ |
---|
1778 | ${filescratch} |
---|
1779 | |
---|
1780 | # Computing combos |
---|
1781 | if test ${combo}; then |
---|
1782 | echo " Computing combos: "${varcombo} |
---|
1783 | compute_combos ${iwdir} ${owdir} ${files} ${testfiles} ${moddims} ${modvdims} \ |
---|
1784 | ${varcombo} ${filescratch} |
---|
1785 | fi |
---|
1786 | |
---|
1787 | echo " "${main}": "${ic}" variables has been computed" |
---|
1788 | echo " "${main}": "${isc}" statistics has been computed" |
---|
1789 | |
---|
1790 | # Direct plotting |
---|
1791 | ## |
---|
1792 | echo " "${main}": Plotting direct figures ..." |
---|
1793 | if ${figscratch}; then rm directplotsdraw.inf; fi |
---|
1794 | if ${addfigures}; then rm directplotsdraw.inf; fi |
---|
1795 | |
---|
1796 | if test ! -f directplotsdraw.inf; then |
---|
1797 | listplots=`createlist_plots ${drawplots} ${directplots} | grep listplots | awk '{print $3}'` |
---|
1798 | |
---|
1799 | plots=`echo ${listplots} | tr '_' ' ' | awk '{print $1}'` |
---|
1800 | ikp=`echo ${listplots} | tr '_' ' ' | awk '{print $2}'` |
---|
1801 | |
---|
1802 | cat << EOF > directplotsdraw.inf |
---|
1803 | Nkinds= ${ikp} |
---|
1804 | plots= ${plots} |
---|
1805 | EOF |
---|
1806 | else |
---|
1807 | echo ${warnmsg} |
---|
1808 | echo " "${main}": retrieving direct plots from existing file 'directplotsdraw.inf' !!" |
---|
1809 | Nkinds=`cat directplotsdraw.inf | grep Nkinds | awk '{print $2}'` |
---|
1810 | plots=`cat directplotsdraw.inf | grep plots | awk '{print $2}'` |
---|
1811 | fi |
---|
1812 | |
---|
1813 | if ${figscratch}; then rm ${owdir}/all_figures.inf; fi |
---|
1814 | if test ! -f ${owdir}/all_figures.inf; then |
---|
1815 | echo "###### List of all figures" > ${owdir}/all_figures.inf |
---|
1816 | fi |
---|
1817 | |
---|
1818 | pts=`echo ${plots} | tr ':' ' '` |
---|
1819 | idp=1 |
---|
1820 | for pt in ${pts}; do |
---|
1821 | echo " "${pt} |
---|
1822 | draw_plot ${pt} ${owdir} ${fileh} ${figscratch} |
---|
1823 | idp=`expr ${idp} + 1` |
---|
1824 | done |
---|
1825 | |
---|
1826 | echo " "${main}": "${idp}" direct plots have been computed" |
---|
1827 | cd ${rootsh} |
---|
1828 | |
---|
1829 | # end of experiments |
---|
1830 | done |
---|
1831 | |
---|
1832 | ### ## # |
---|
1833 | # Experiment differences |
---|
1834 | ## # ## # |
---|
1835 | |
---|
1836 | diffexperiments=`list_pairs $(echo ${exps} | tr ' ' ':') | grep -v newlists | awk '{print $3}'` |
---|
1837 | diffexps=`echo ${diffexperiments} | tr ':' ' '` |
---|
1838 | |
---|
1839 | for diffexp in ${diffexps}; do |
---|
1840 | echo " "${diffexp} |
---|
1841 | difexp1=`echo ${diffexp} | tr '|' ' ' | awk '{print $1}'` |
---|
1842 | difexp2=`echo ${diffexp} | tr '|' ' ' | awk '{print $2}'` |
---|
1843 | |
---|
1844 | vdiffs=`echo ${vardiff} | tr ':' ' '` |
---|
1845 | ivd=1 |
---|
1846 | echo " Computing diff statistics ..." |
---|
1847 | for vdiff in ${vdiffs}; do |
---|
1848 | echo ${vdiff}" ..." |
---|
1849 | if test $(expr index ${vdiff} '|') -ne -1; then |
---|
1850 | vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'` |
---|
1851 | ops=`echo ${vdiff} | tr '|' ' ' | awk '{print $2}'` |
---|
1852 | else |
---|
1853 | vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'` |
---|
1854 | ops='None' |
---|
1855 | fi |
---|
1856 | #Modify in case of combo |
---|
1857 | if test $(expr index ${ops} '@') -eq 0; then |
---|
1858 | fileh=`echo ${varcompute} | tr ';' '\n' | grep ${vdiff} | tr '|' ' ' | \ |
---|
1859 | awk '{print $3}'` |
---|
1860 | else |
---|
1861 | set -x |
---|
1862 | Lcombo=`expr length ${vn}';'${ops}'|combo|'` |
---|
1863 | Lvarcompute=`expr length ${varcompute}` |
---|
1864 | indcombo=`index_string ${varcompute} ${vn}';'${ops}'|combo|'` |
---|
1865 | Lindcombo=`expr ${Lvarcompute} - ${indcombo}` |
---|
1866 | |
---|
1867 | fileh=`echo ${varcompute:${indcombo}:${Lindcombo}} | tr ';' '\n' | \ |
---|
1868 | head -n 2 | tail -n 1 | tr '|' ' ' | awk '{print $3}'` |
---|
1869 | if test $(index_string ${ops} pinterp) -ne -1; then fileh=${fileh}'p_pinterp'; fi |
---|
1870 | fi |
---|
1871 | |
---|
1872 | owdir=${ofold}/${mod}/${difexp1}-${difexp2} |
---|
1873 | if test ${ivd} -eq 1; then |
---|
1874 | mkdir -p ${owdir} |
---|
1875 | fi |
---|
1876 | |
---|
1877 | filen=${vn}_${fileh}.nc |
---|
1878 | |
---|
1879 | if ${filescratch}; then rm ${owdir}/${filen} >& /dev/null; fi |
---|
1880 | if test ! -f ${owdir}/${filen}; then |
---|
1881 | set -x |
---|
1882 | dfile1=${ofold}/${mod}/${difexp1}/${filen} |
---|
1883 | dfile2=${ofold}/${mod}/${difexp2}/${filen} |
---|
1884 | |
---|
1885 | dfiles='add|'${dfile1}'|'${vn}',sub|'${dfile2}'|'${vn} |
---|
1886 | dims='time|pres|lat|lon@'${dfiles} |
---|
1887 | Lfileh=`expr length ${fileh}` |
---|
1888 | Lfileh1=`expr ${Lfileh} - 1` |
---|
1889 | echo "python ${pyHOME}/nc_var.py -S ${dims} -o compute_opersvarsfiles -v ${vn}" |
---|
1890 | pyout=`python ${pyHOME}/nc_var.py -S ${dims} -o compute_opersvarsfiles -v ${vn}` |
---|
1891 | pyn=$? |
---|
1892 | Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'` |
---|
1893 | ferrmsg ${pyn} ${fname} "python!'difference'!failed"${Spyout} |
---|
1894 | |
---|
1895 | mv opersvarsfiles_${vn}.nc ${owdir}/${filen} |
---|
1896 | fi |
---|
1897 | |
---|
1898 | cfdims='lon:lat:pres:time' |
---|
1899 | cfvdims='lon:lat:pres:time' |
---|
1900 | cdiffvn=`echo ${filen} | tr '_' ' ' | awk '{print $1}'` |
---|
1901 | cdiffh=`echo ${filen} | tr '_' ' ' | awk '{print $2}' | tr '.' ' ' | \ |
---|
1902 | awk '{print $1}'` |
---|
1903 | |
---|
1904 | cdiffvar=${cdiffvn}'|'${ops}'|'${cdiffh}'|None|None' |
---|
1905 | |
---|
1906 | if test $(expr index ${ops} '@') -eq 0; then |
---|
1907 | compute_statistics ${owdir} ${filen} ${owdir} ${cdiffvar} ${cfdims} \ |
---|
1908 | ${cfvdims} ${filescratch} |
---|
1909 | else |
---|
1910 | # Computing combos |
---|
1911 | echo " Computing combos: "${ops} |
---|
1912 | combs=`echo ${ops} | tr '@' ' '` |
---|
1913 | ifile=${cdiffvn}_${fileh} |
---|
1914 | for comb in ${combs}; do |
---|
1915 | combcvar=${cdiffvn}'|'${comb}'|'${cdiffh}'|None|None' |
---|
1916 | compute_statistics ${owdir} ${ifile}.nc ${owdir} ${combcvar} ${cfdims} \ |
---|
1917 | ${cfvdims} ${filescratch} ${ifile}.nc |
---|
1918 | ifile=${ifile}_${comb} |
---|
1919 | |
---|
1920 | # Adding 'surnames' to the variable's name |
---|
1921 | if test ${comb} = 'turb'; then |
---|
1922 | cdiffvn=${cdiffvn}'turb' |
---|
1923 | fi |
---|
1924 | if $(isInlist ${varmeanname} ${comb}); then |
---|
1925 | cdiffvn=${cdiffvn}'mean' |
---|
1926 | fi |
---|
1927 | |
---|
1928 | # End of combo |
---|
1929 | done |
---|
1930 | fi |
---|
1931 | ivd=`expr ${ivd} + 1` |
---|
1932 | # end of variable diff |
---|
1933 | done |
---|
1934 | |
---|
1935 | # Diff plotting |
---|
1936 | ## |
---|
1937 | echo " "${main}": Plotting diff figures ..." |
---|
1938 | if ${figscratch}; then rm diffplotsdraw.inf; fi |
---|
1939 | if ${addfigures}; then rm diffplotsdraw.inf; fi |
---|
1940 | |
---|
1941 | if test ! -f diffplotsdraw.inf; then |
---|
1942 | listplots=`createlist_diffplots ${drawdiffplots} ${directplots} | \ |
---|
1943 | grep listplots | awk '{print $3}'` |
---|
1944 | |
---|
1945 | plots=`echo ${listplots} | tr '_' ' ' | awk '{print $1}'` |
---|
1946 | ikp=`echo ${listplots} | tr '_' ' ' | awk '{print $2}'` |
---|
1947 | |
---|
1948 | cat << EOF > diffplotsdraw.inf |
---|
1949 | Nkinds= ${ikp} |
---|
1950 | plots= ${plots} |
---|
1951 | EOF |
---|
1952 | else |
---|
1953 | echo ${warnmsg} |
---|
1954 | echo " "${main}": retrieving direct plots from existing file 'diffplotsdraw.inf' !!" |
---|
1955 | Nkinds=`cat diffplotsdraw.inf | grep Nkinds | awk '{print $2}'` |
---|
1956 | plots=`cat diffplotsdraw.inf | grep plots | awk '{print $2}'` |
---|
1957 | fi |
---|
1958 | |
---|
1959 | pts=`echo ${plots} | tr ':' ' '` |
---|
1960 | idp=1 |
---|
1961 | for pt in ${pts}; do |
---|
1962 | echo " "${pt} |
---|
1963 | draw_plot ${pt} ${owdir} ${fileh} ${figscratch} 'diff' |
---|
1964 | idp=`expr ${idp} + 1` |
---|
1965 | done |
---|
1966 | |
---|
1967 | echo " "${main}": "${idp}" diff plots have been computed" |
---|
1968 | cd ${rootsh} |
---|
1969 | |
---|
1970 | # end experiment pairs |
---|
1971 | done |
---|
1972 | # LLUIS |
---|
1973 | |
---|
1974 | exit |
---|
1975 | |
---|
1976 | # end of models |
---|
1977 | done |
---|
1978 | |
---|
1979 | exit |
---|
1980 | |
---|
1981 | istep=0 |
---|
1982 | |
---|
1983 | if test ${compute} -eq 1; then |
---|
1984 | for exp in ${exps}; do |
---|
1985 | echo "exp: "${exp} |
---|
1986 | if test ${exp} == 'AR40'; then |
---|
1987 | var2Dtmeans=${var2Dtmeans_AR40} |
---|
1988 | else |
---|
1989 | var2Dtmeans=${var2Dtmeans_NPv31} |
---|
1990 | fi |
---|
1991 | for vark in ${varks}; do |
---|
1992 | echo " vark: "${vark} |
---|
1993 | |
---|
1994 | if test ${vark} = 'mean'; then |
---|
1995 | fileorig=${ifoldmean}/${exp}/${filenmean} |
---|
1996 | if test ! -f ${fileorig}; then |
---|
1997 | fileworig=${filensfc} |
---|
1998 | dvals='T:Time,Z:bottom_top,Y:south_north,X:west_east' |
---|
1999 | dimnames='T:Time,Z:bottom_top,Y:south_north,X:west_east' |
---|
2000 | python ${pyHOME}/vertical_interpolation.py \ |
---|
2001 | -f ${ofold}/${exp}/${filensfc} -o WRFp -i ${plevels} -k 'lin' \ |
---|
2002 | -v WRFt,U,V,WRFrh,WRFght -d ${dimnames} -D T:Times,Z:ZNU,Y:XLAT,X:XLONG |
---|
2003 | if test $? -ne 0; then |
---|
2004 | echo ${errormsg} |
---|
2005 | echo " python failed!" |
---|
2006 | echo " python ${pyHOME}/vertical_interpolation.py" \ |
---|
2007 | "-f ${ofold}/${exp}/${filensfc} -o WRFp -i ${plevels} -k 'lin'" \ |
---|
2008 | "-v WRFt,U,V,WRFrh,WRFght -d ${dimnames} -D T:Times,Z:ZNU,Y:XLAT,X:XLONG" |
---|
2009 | rm ${ofold}/${exp}/vertical_interpolation_WRFp.nc >& /dev/null |
---|
2010 | exit |
---|
2011 | fi |
---|
2012 | mv vertical_interpolation_WRFp.nc ${ofold}/${exp} |
---|
2013 | fi |
---|
2014 | vars=`echo ${mean_variables} | tr ':' ' '` |
---|
2015 | ofile='mean_variables' |
---|
2016 | elif test ${vark} = 'sfc'; then |
---|
2017 | fileorig=${ifoldsfc}/${exp}/${filensfc} |
---|
2018 | if test ! -f ${fileorig}; then |
---|
2019 | fileworig=${filensfc} |
---|
2020 | cp ${ifoldsfc}/${exp}/${fileworig} ${ifoldsfc}/${exp}/${filensfc} |
---|
2021 | python ${pyHOME}/nc_var.py -o WRF_CFxtime_creation -f ${ifoldsfc}/${exp}/${filensfc} \ |
---|
2022 | -S 19491201000000,hours -v time |
---|
2023 | python ${pyHOME}/nc_var.py -o WRF_CFlonlat_creation -f ${ifoldsfc}/${exp}/${filensfc}\ |
---|
2024 | -S longitude,latitude -v XLONG,XLAT |
---|
2025 | fi |
---|
2026 | if test ${exp} = 'AR40'; then |
---|
2027 | vars=`echo ${sfc_variables_AR40} | tr ':' ' '` |
---|
2028 | else |
---|
2029 | vars=`echo ${sfc_variables_NPv31} | tr ':' ' '` |
---|
2030 | fi |
---|
2031 | ofile='sfc_variables' |
---|
2032 | elif test ${vark} = 'diag'; then |
---|
2033 | fileorig=${ifolddiag}/${exp}/${filendiag} |
---|
2034 | vars=`echo ${diag_variables} | tr ':' ' '` |
---|
2035 | if test ! -f ${fileorig}; then |
---|
2036 | values='Time@XTIME,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2037 | ivar=0 |
---|
2038 | varcombos='' |
---|
2039 | for var in ${vars}; do |
---|
2040 | echo " var:"${var} |
---|
2041 | varn=`echo ${var} | tr '_' ' ' | awk '{print $2}'` |
---|
2042 | combo=`python ${pyHOME}/diagnostics.py -f ${combosfile} -d variable_combo -v ${varn}\ |
---|
2043 | | grep COMBO | awk '{print $2}'` |
---|
2044 | if test ${combo} = 'ERROR'; then |
---|
2045 | echo ${errormsg} |
---|
2046 | echo " No variable '"${varn}"' in '"${combosfile}"' !!" |
---|
2047 | exit |
---|
2048 | fi |
---|
2049 | if test ${ivar} -eq 0; then |
---|
2050 | varcombos=${varn}'|'${combo} |
---|
2051 | else |
---|
2052 | varcombos=${varcombos}','${varn}'|'${combo} |
---|
2053 | fi |
---|
2054 | ivar=`expr ${ivar} + 1` |
---|
2055 | done |
---|
2056 | python ${pyHOME}/diagnostics.py -d ${values} -f ${ifoldsfc}/${exp}/${filensfc} -v \ |
---|
2057 | ${varcombos} |
---|
2058 | if test $? -ne 0; then |
---|
2059 | echo ${errormsg} |
---|
2060 | echo " python failed!!" |
---|
2061 | echo python ${pyHOME}/diagnostics.py -d ${values} -f ${ifoldsfc}/${exp}/${filensfc}\ |
---|
2062 | -v ${varcombos} |
---|
2063 | exit |
---|
2064 | fi |
---|
2065 | python ${pyHOME}/nc_var.py -o WRF_CFxtime_creation -f diagnostics.nc \ |
---|
2066 | -S 19491201000000,hours -v time |
---|
2067 | python ${pyHOME}/nc_var.py -o WRF_CFlonlat_creation -f diagnostics.nc \ |
---|
2068 | -S longitude,latitude -v XLONG,XLAT |
---|
2069 | mv diagnostics.nc ${ifolddiag}/${exp} |
---|
2070 | fi |
---|
2071 | ofile='diag_variables' |
---|
2072 | elif test ${vark} = 'z'; then |
---|
2073 | fileorig=${ifoldmean}/${exp}/${filenmean} |
---|
2074 | vars=`echo ${z_variables} | tr ':' ' '` |
---|
2075 | ofile='z_variables' |
---|
2076 | fi |
---|
2077 | |
---|
2078 | # Averaging |
---|
2079 | ## |
---|
2080 | echo " averaging..." |
---|
2081 | ivar=0 |
---|
2082 | for varn in ${vars}; do |
---|
2083 | file=${fileorig} |
---|
2084 | echo " var: "${varn} |
---|
2085 | var=`echo ${varn} | tr '|' ' ' | awk '{print $2}'` |
---|
2086 | varval=`python ${pyHOME}/drawing.py -o variable_values -S ${var} | grep all_values | awk '{print $3}'` |
---|
2087 | varname=`echo ${varval} | tr ',' ' ' | awk '{print $1}'` |
---|
2088 | |
---|
2089 | echo " std name: "${varname} |
---|
2090 | varhead=`echo ${varname} | tr '_' ' ' | awk '{print $1}'` |
---|
2091 | vartail=`echo ${varname} | tr '_' ' ' | awk '{print $2}'` |
---|
2092 | |
---|
2093 | if test ${vark} = 'mean'; then |
---|
2094 | vals='time:-1|z:-1|y:-1|x:-1,time:x,mean,pressure:lat' |
---|
2095 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${var} |
---|
2096 | pyexec=$? |
---|
2097 | if test ${pyexec} -ne 0; then |
---|
2098 | echo ${errormsg} |
---|
2099 | echo " "${main}": python fai1ls!" |
---|
2100 | echo "python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${var}" |
---|
2101 | exit |
---|
2102 | else |
---|
2103 | oper=`echo ${vals} | tr ',' ' ' | awk '{print $3}'` |
---|
2104 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${varname}${oper}.nc |
---|
2105 | fi |
---|
2106 | elif test ${vark} = 'z'; then |
---|
2107 | vals='time:-1|z:-1|y:-1|x:-1,time:x,mean,pressure:lat' |
---|
2108 | echo "NOT FINISHED!!!!" |
---|
2109 | exit |
---|
2110 | else |
---|
2111 | vals='Time:-1|south_north:-1|west_east:-1,west_east,mean,time:XLAT' |
---|
2112 | if test ${var} = 'ACRAINTOT'; then |
---|
2113 | files='add|'${file}'|RAINC,add|'${file}'|RAINNC' |
---|
2114 | python ${pyHOME}/nc_var.py -S 'time|XLAT|XLONG@'${files} -o compute_opersvarsfiles \ |
---|
2115 | -v ${var} |
---|
2116 | mv opersvarsfiles_${var}.nc ${ofold}/${exp} |
---|
2117 | file=${ofold}/${exp}/opersvarsfiles_${var}.nc |
---|
2118 | elif test ${var} = 'RAINTOT'; then |
---|
2119 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2120 | python ${pyHOME}/diagnostics.py -d ${dims} -v 'RAINTOT|RAINC@RAINNC@time' -f ${file} |
---|
2121 | mv diagnostics.nc ${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2122 | file=${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2123 | var='pr' |
---|
2124 | elif test ${var} = 'cllmh'; then |
---|
2125 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2126 | clouds='cll:clm:clh' |
---|
2127 | cls=`echo ${clouds} | tr ':' ' '` |
---|
2128 | for cl in ${cls}; do |
---|
2129 | file=${ofold}/${exp}/diagnostics.nc |
---|
2130 | var=${cl} |
---|
2131 | echo " var: "${var} |
---|
2132 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${cl} |
---|
2133 | pyexec=$? |
---|
2134 | if test ${pyexec} -ne 0; then |
---|
2135 | echo ${errormsg} |
---|
2136 | echo " "${main}": python fails!" |
---|
2137 | echo python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${cl} |
---|
2138 | exit |
---|
2139 | fi |
---|
2140 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${cl}${oper}.nc |
---|
2141 | vals='Time:-1|south_north:-1|west_east:-1,Time,mean,XLONG:XLAT' |
---|
2142 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2143 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${cl} |
---|
2144 | pyexec=$? |
---|
2145 | if test ${pyexec} -ne 0; then |
---|
2146 | echo ${errormsg} |
---|
2147 | echo " "${main}": python fails!" |
---|
2148 | exit |
---|
2149 | else |
---|
2150 | oper=`echo ${vals} | tr ',' ' ' | awk '{print $3}'` |
---|
2151 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${cl}t${oper}.nc |
---|
2152 | fi |
---|
2153 | done |
---|
2154 | # break |
---|
2155 | elif test ${var} = 'WRFbils' && test ! -f ${ofold}/${exp}/diagnostics_${varname}.nc; then |
---|
2156 | dims='Time@time,south_north@XLAT,west_east@XLONG' |
---|
2157 | python ${pyHOME}/diagnostics.py -d ${dims} -v 'WRFbils|HFX@LH' -f ${file} |
---|
2158 | mv diagnostics.nc ${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2159 | file=${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2160 | var='bils' |
---|
2161 | elif test ${var} = 'WRFprw' && test ! -f ${ofold}/${exp}/diagnostics_${varname}.nc; then |
---|
2162 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2163 | python ${pyHOME}/diagnostics.py -d ${dims} -v 'WRFprw|WRFdens@QVAPOR' -f ${file} |
---|
2164 | mv diagnostics.nc ${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2165 | file=${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2166 | var='prw' |
---|
2167 | elif test ${var} = 'WRFrhs' && test ! -f ${ofold}/${exp}/diagnostics_${varname}.nc; then |
---|
2168 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2169 | python ${pyHOME}/diagnostics.py -d ${dims} -v 'WRFrhs|PSFC@T2@Q2' -f ${file} |
---|
2170 | mv diagnostics.nc ${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2171 | file=${ofold}/${exp}/diagnostics_${varname}.nc |
---|
2172 | var='huss' |
---|
2173 | elif test ${var} = 'WRFprc'; then |
---|
2174 | vals='Time:-1|south_north:-1|west_east:-1,west_east,mean,time:XLAT' |
---|
2175 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2176 | var='prc' |
---|
2177 | elif test ${var} = 'WRFprls'; then |
---|
2178 | vals='Time:-1|south_north:-1|west_east:-1,west_east,mean,time:XLAT' |
---|
2179 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2180 | var='prls' |
---|
2181 | fi |
---|
2182 | if test ! -f ${ofold}/${exp}/${varname}${oper}.nc; then |
---|
2183 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${var} |
---|
2184 | pyexec=$? |
---|
2185 | if test ${pyexec} -ne 0; then |
---|
2186 | echo ${errormsg} |
---|
2187 | echo " "${main}": python fails!" |
---|
2188 | exit |
---|
2189 | else |
---|
2190 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${varname}${oper}.nc |
---|
2191 | fi |
---|
2192 | fi |
---|
2193 | fi |
---|
2194 | |
---|
2195 | # Time means |
---|
2196 | if $(isin_list ${var2Dtmeans} ${var}); then |
---|
2197 | echo "Computing time means!!" |
---|
2198 | if test ${var} = 'cllmh'; then |
---|
2199 | clouds='cll:clm:clh' |
---|
2200 | clds=`echo ${clouds} | tr ':' ' '` |
---|
2201 | for cld in ${clds}; do |
---|
2202 | vals='Time:-1|south_north:-1|west_east:-1,Time,mean,XLONG:XLAT' |
---|
2203 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2204 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${cld} |
---|
2205 | pyexec=$? |
---|
2206 | if test ${pyexec} -ne 0; then |
---|
2207 | echo ${errormsg} |
---|
2208 | echo " "${main}": python fails!" |
---|
2209 | exit |
---|
2210 | else |
---|
2211 | oper=`echo ${vals} | tr ',' ' ' | awk '{print $3}'` |
---|
2212 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${cld}t${oper}.nc |
---|
2213 | fi |
---|
2214 | done |
---|
2215 | else |
---|
2216 | vals='Time:-1|south_north:-1|west_east:-1,Time,mean,XLONG:XLAT' |
---|
2217 | dims='Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' |
---|
2218 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${file} -v ${var} |
---|
2219 | pyexec=$? |
---|
2220 | if test ${pyexec} -ne 0; then |
---|
2221 | echo ${errormsg} |
---|
2222 | echo " "${main}": python fails!" |
---|
2223 | exit |
---|
2224 | else |
---|
2225 | oper=`echo ${vals} | tr ',' ' ' | awk '{print $3}'` |
---|
2226 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${varname}t${oper}.nc |
---|
2227 | fi |
---|
2228 | fi |
---|
2229 | fi |
---|
2230 | if test ${var} = 'cllmh'; then exit; fi |
---|
2231 | ivar=`expr ${ivar} + 1` |
---|
2232 | # exit |
---|
2233 | # end of vars |
---|
2234 | done |
---|
2235 | |
---|
2236 | # end of kind vars |
---|
2237 | done |
---|
2238 | |
---|
2239 | done |
---|
2240 | # end of compute |
---|
2241 | fi |
---|
2242 | # Longitudinal means of tmeans |
---|
2243 | ## |
---|
2244 | if ${computetlon}; then |
---|
2245 | echo "Computing Longitudinal means of temporal means..." |
---|
2246 | for exp in ${exps}; do |
---|
2247 | echo " exp:"${exp} |
---|
2248 | for tmean in ${ofold}/${exp}/*tmean.nc; do |
---|
2249 | fname=`basename ${tmean}` |
---|
2250 | var=`ncdump -h ${tmean} | grep float | grep mean | tr '(' ' ' | awk '{print $2}'` |
---|
2251 | vals='south_north:-1|west_east:-1,west_east,mean,XLAT' |
---|
2252 | dims='bottom_top@bottom_top,south_north@south_north,west_east@west_east' |
---|
2253 | if test ! -f ${ofold}/${exp}/${var}t-lonmean.nc; then |
---|
2254 | python ${pyHOME}/nc_var.py -o file_oper_alongdims -S ${vals} -f ${tmean} -v ${var} |
---|
2255 | pyexec=$? |
---|
2256 | if test ${pyexec} -ne 0; then |
---|
2257 | echo ${errormsg} |
---|
2258 | echo " "${main}": python fails!" |
---|
2259 | exit |
---|
2260 | else |
---|
2261 | mv file_oper_alongdims_mean.nc ${ofold}/${exp}/${var}t-lonmean.nc |
---|
2262 | fi |
---|
2263 | # exit |
---|
2264 | fi |
---|
2265 | done |
---|
2266 | |
---|
2267 | done |
---|
2268 | fi |
---|
2269 | |
---|
2270 | if ${plot}; then |
---|
2271 | # Plots |
---|
2272 | ## |
---|
2273 | |
---|
2274 | for exp in ${exps}; do |
---|
2275 | echo "exp: "${exp} |
---|
2276 | for vark in ${varks}; do |
---|
2277 | echo " vark: "${vark} |
---|
2278 | if test ${vark} = 'mean'; then |
---|
2279 | gcoups=`echo ${graph_couples_mean} | tr ':' ' '` |
---|
2280 | elif test ${vark} = 'sfc'; then |
---|
2281 | if test ${exp} = 'AR40'; then |
---|
2282 | gcoups=`echo ${graph_couples_sfc_AR40} | tr ':' ' '` |
---|
2283 | else |
---|
2284 | gcoups=`echo ${graph_couples_sfc_NPv31} | tr ':' ' '` |
---|
2285 | fi |
---|
2286 | elif test ${vark} = 'diag'; then |
---|
2287 | gcoups=`echo ${graph_couples_diag} | tr ':' ' '` |
---|
2288 | fi |
---|
2289 | |
---|
2290 | for gpair in ${gcoups}; do |
---|
2291 | shdvar=`echo ${gpair} | tr '@' ' ' | awk '{print $1}'` |
---|
2292 | cntvar=`echo ${gpair} | tr '@' ' ' | awk '{print $2}'` |
---|
2293 | echo " couple: "${shdvar}'-'${cntvar} |
---|
2294 | shdvals=`python ${pyHOME}/drawing.py -o variable_values -S ${shdvar} | grep all_values | awk '{print $3}'` |
---|
2295 | cntvals=`python ${pyHOME}/drawing.py -o variable_values -S ${cntvar} | grep all_values | awk '{print $3}'` |
---|
2296 | files=${ofold}'/'${exp}'/'${shdvar}'mean.nc,'${ofold}'/'${exp}'/'${cntvar}'mean.nc' |
---|
2297 | |
---|
2298 | Lshdvals=`expr length ${shdvals}0` |
---|
2299 | if test ${Lshdvals} -lt 2; then |
---|
2300 | echo ${errormsg} |
---|
2301 | echo " Error in drawing_tools.py 'variables_values'!!" |
---|
2302 | echo " variable '"${shdvar}"' NOT found!" |
---|
2303 | exit |
---|
2304 | fi |
---|
2305 | |
---|
2306 | Lcntvals=`expr length ${cntvals}0` |
---|
2307 | if test ${Lcntvals} -lt 2; then |
---|
2308 | echo ${errormsg} |
---|
2309 | echo " Error in drawing_tools.py 'variables_values'!!" |
---|
2310 | echo " variable '"${cntvar}"' NOT found!" |
---|
2311 | exit |
---|
2312 | fi |
---|
2313 | |
---|
2314 | shdstdn=`echo ${shdvals} | tr ',' ' ' | awk '{print $1}'` |
---|
2315 | shdcbar=`echo ${shdvals} | tr ',' ' ' | awk '{print $7}'` |
---|
2316 | shdmin=`echo ${shdvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2317 | shdmax=`echo ${shdvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2318 | |
---|
2319 | cntstdn=`echo ${cntvals} | tr ',' ' ' | awk '{print $1}'` |
---|
2320 | cntmin=`echo ${cntvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2321 | cntmax=`echo ${cntvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2322 | |
---|
2323 | if test ${shdstdn} = 'ERROR' || test ${cntstdn} = 'ERROR'; then |
---|
2324 | echo ${errmsg} |
---|
2325 | echo " "${main}": wrong variable names!!!" |
---|
2326 | echo " shdvals: "${shdvals} |
---|
2327 | echo " cntvals: "${cntvals} |
---|
2328 | echo " shdvar: "${shdvar}" cntvar: "${cntvar} |
---|
2329 | exit |
---|
2330 | fi |
---|
2331 | |
---|
2332 | cntcolor='black' |
---|
2333 | cntfmt='%g' |
---|
2334 | |
---|
2335 | if test ${gpair} = 'va@ua'; then |
---|
2336 | shdmin=`echo ${shdmin} | awk '{print $1/4.}'` |
---|
2337 | shdmax=`echo ${shdmax} | awk '{print $1/4.}'` |
---|
2338 | cntmin=`echo ${cntmin} | awk '{print $1/3.}'` |
---|
2339 | cntmax=`echo ${cntmax} | awk '{print $1 + 20.}'` |
---|
2340 | elif test ${gpair} = 'tas@ps'; then |
---|
2341 | shdmin=`echo ${shdmin} | awk '{print $1 + 50.}'` |
---|
2342 | shdmax=`echo ${shdmax} | awk '{print $1 - 15.}'` |
---|
2343 | cntmin=`echo ${cntmin} | awk '{print $1 + 15000.}'` |
---|
2344 | cntmax=`echo ${cntmax} | awk '{print $1 - 2000.}'` |
---|
2345 | elif test ${gpair} = 'uas@vas'; then |
---|
2346 | cntmin=`echo ${cntmin} | awk '{print $1 * 0.1}'` |
---|
2347 | cntmax=`echo ${cntmax} | awk '{print $1 * 0.1}'` |
---|
2348 | elif test ${gpair} = 'pr@rsds'; then |
---|
2349 | # shdmax=`echo ${shdmax} | awk '{print $1 / 20.}'` |
---|
2350 | cntmax=`echo ${cntmax} | awk '{print $1 / 3.}'` |
---|
2351 | elif test ${gpair} = 'clt@cll' || test ${gpair} = 'clh@clm'; then |
---|
2352 | cntcolor='red' |
---|
2353 | cntfmt='%.1g' |
---|
2354 | elif test ${gpair} = 'clh@clm'; then |
---|
2355 | cntmax=`echo ${cntmax} | awk '{print $1}'` |
---|
2356 | elif test ${gpair} = 'prw@huss'; then |
---|
2357 | shdmax=`echo ${shdmax} | awk '{print $1*4}'` |
---|
2358 | elif test ${gpair} = 'prls@prc'; then |
---|
2359 | shdmax=`echo ${shdmax} | awk '{print $1/1.}'` |
---|
2360 | cntmax=`echo ${cntmax} | awk '{print $1 * 0.5}'` |
---|
2361 | elif test ${gpair} = 'hfls@hfss'; then |
---|
2362 | cntmin='-50.' |
---|
2363 | cntmax='50.' |
---|
2364 | fi |
---|
2365 | |
---|
2366 | if test ${vark} = 'mean'; then |
---|
2367 | graphvals=${shdstdn}','${cntstdn}':z|-1,y|-1:z|-1,y|-1:lat:pressure:' |
---|
2368 | graphvals=${graphvals}${shdcbar}':fixsigc,'${cntcolor}':'${cntfmt}':'${shdmin}',' |
---|
2369 | graphvals=${graphvals}${shdmax}':'${cntmin}','${cntmax}',9:LMDZ+WRF|'${exp} |
---|
2370 | graphvals=${graphvals}'|meridional|monthly|average|of|'${shdstdn}'|&|' |
---|
2371 | graphvals=${graphvals}${cntstdn}':pdf:flip@y:None' |
---|
2372 | else |
---|
2373 | graphvals=${shdstdn}','${cntstdn}':y|-1,time|-1:y|-1,time|-1:time:XLAT:' |
---|
2374 | graphvals=${graphvals}${shdcbar}':fixsigc,'${cntcolor}':'${cntfmt}':'${shdmin}',' |
---|
2375 | graphvals=${graphvals}${shdmax}':'${cntmin}','${cntmax}',9:WRF+LMDZ|'${exp} |
---|
2376 | graphvals=${graphvals}'|mean|meridional|evolution|of|'${shdstdn}'|&|' |
---|
2377 | graphvals=${graphvals}${cntstdn}':pdf:None:time|hours!since!1949-12-01|' |
---|
2378 | graphvals=${graphvals}'exct,5,d|%d|date!([DD]):None' |
---|
2379 | fi |
---|
2380 | |
---|
2381 | echo ${files} |
---|
2382 | echo ${graphvals} |
---|
2383 | echo ${shdstdn}'mean,'${cntstdn}'mean' |
---|
2384 | |
---|
2385 | if test ${vark} = 'sfc' || test ${vark} = 'diag' && |
---|
2386 | ! $(isin_list ${coup2D} ${gpair}); then |
---|
2387 | python ${pyHOME}/drawing.py -f ${files} -o draw_2D_shad_cont_time -S ${graphvals} -v \ |
---|
2388 | ${shdstdn}'mean,'${cntstdn}'mean' |
---|
2389 | pyexc=$? |
---|
2390 | else |
---|
2391 | python ${pyHOME}/drawing.py -f ${files} -o draw_2D_shad_cont -S ${graphvals} -v \ |
---|
2392 | ${shdstdn}'mean,'${cntstdn}'mean' |
---|
2393 | pyexc=$? |
---|
2394 | fi |
---|
2395 | if test ${pyexc} -ne 0; then |
---|
2396 | echo ${errormsg} |
---|
2397 | echo " "${main}": drawing.py fails!" |
---|
2398 | exit |
---|
2399 | else |
---|
2400 | mv 2Dfields_shadow-contour.pdf ${ofold}/${exp}/${shdvar}mean_${cntvar}mean.pdf |
---|
2401 | evince ${ofold}/${exp}/${shdvar}mean_${cntvar}mean.pdf & |
---|
2402 | fi |
---|
2403 | |
---|
2404 | if $(isin_list ${coup2D} ${gpair}); then |
---|
2405 | graphvals=${shdstdn}','${cntstdn}':south_north|-1,west_east|-1:' |
---|
2406 | graphvals=${graphvals}'south_north|-1,west_east|-1:longitude:latitude:' |
---|
2407 | graphvals=${graphvals}${shdcbar}':fixsigc,'${cntcolor}':'${cntfmt}':'${shdmin}',' |
---|
2408 | graphvals=${graphvals}${shdmax}':'${cntmin}','${cntmax}',9:LMDZ+WRF|'${exp} |
---|
2409 | graphvals=${graphvals}'|monthly|average|of|'${shdstdn}'|&|' |
---|
2410 | graphvals=${graphvals}${cntstdn}':pdf:flip@y:None' |
---|
2411 | echo ' '${shdstdn}'mean,'${cntstdn}'mean' |
---|
2412 | |
---|
2413 | python ${pyHOME}/drawing.py -f ${files} -o draw_2D_shad_cont -S ${graphvals} -v \ |
---|
2414 | ${shdstdn}'mean,'${cntstdn}'mean' |
---|
2415 | pyexc=$? |
---|
2416 | if test ${pyexc} -ne 0; then |
---|
2417 | echo ${errormsg} |
---|
2418 | echo " "${main}": drawing.py fails!" |
---|
2419 | exit |
---|
2420 | else |
---|
2421 | mv 2Dfields_shadow-contour.pdf ${ofold}/${exp}/${shdvar}tmean_${cntvar}tmean.pdf |
---|
2422 | evince ${ofold}/${exp}/${shdvar}tmean_${cntvar}tmean.pdf & |
---|
2423 | fi |
---|
2424 | fi |
---|
2425 | # exit |
---|
2426 | |
---|
2427 | # end of couples |
---|
2428 | done |
---|
2429 | # end of kinds |
---|
2430 | done |
---|
2431 | |
---|
2432 | done |
---|
2433 | fi |
---|
2434 | |
---|
2435 | # 2D single plots |
---|
2436 | ## |
---|
2437 | if ${single2Dplot}; then |
---|
2438 | echo "2D single plots" |
---|
2439 | for exp in ${exps}; do |
---|
2440 | echo " exp:"${exp} |
---|
2441 | for tmean in ${ofold}/${exp}/*tmean.nc ;do |
---|
2442 | fname=`basename ${tmean}` |
---|
2443 | var=`ncdump -h ${tmean} | grep float | grep mean | tr '(' ' ' | awk '{print $2}'` |
---|
2444 | if test ! ${var} = 'cltmean'; then |
---|
2445 | shdvals=`python ${pyHOME}/drawing.py -o variable_values -S ${var} | \ |
---|
2446 | grep all_values | awk '{print $3}'` |
---|
2447 | cbar=`echo ${shdvals} | tr ',' ' ' | awk '{print $7}'` |
---|
2448 | min=`echo ${shdvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2449 | max=`echo ${shdvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2450 | |
---|
2451 | if test ${var} = 'prlsmean'; then xtrms='0,0.00015'; |
---|
2452 | elif test ${var} = 'prwmean'; then xtrms='0,40'; |
---|
2453 | elif test ${var} = 'psmean'; then xtrms='99000,102500'; |
---|
2454 | elif test ${var} = 'r2mean'; then xtrms='0,0.025'; |
---|
2455 | elif test ${var} = 'tasmean'; then xtrms='275,310'; |
---|
2456 | elif test ${var} = 'tmlamean'; then xtrms='260,310'; |
---|
2457 | elif test ${var} = 'uasmean'; then xtrms='-20,20'; |
---|
2458 | elif test ${var} = 'vasmean'; then xtrms='-20,20'; |
---|
2459 | else xtrms=${min}','${max}; fi |
---|
2460 | |
---|
2461 | # vals=${var}':XLONG|-1,XLAT|-1:XLONG:XLAT:'${cbar}':'${xtrms}':monthly|mean:pdf:' |
---|
2462 | # vals=${vals}'None:None:true' |
---|
2463 | # dims='south_north@XLAT,west_east@XLONG' |
---|
2464 | python ${pyHOME}/nc_var.py -o WRF_CFlonlat_creation -S longitude,latitude \ |
---|
2465 | -f ${tmean} -v XLONG,XLAT |
---|
2466 | vals=${var}':longitude|-1,latitude|-1:longitude:latitude:'${cbar}':'${xtrms}':monthly|mean:pdf:' |
---|
2467 | vals=${vals}'None:None:true' |
---|
2468 | dims='south_north@latitude,west_east@longitude' |
---|
2469 | python ${pyHOME}/drawing.py -o draw_2D_shad -S ${vals} -f ${tmean} -v ${var} |
---|
2470 | pyexec=$? |
---|
2471 | if test ${pyexec} -ne 0; then |
---|
2472 | echo ${errormsg} |
---|
2473 | echo " "${main}": python fails!" |
---|
2474 | exit |
---|
2475 | else |
---|
2476 | mv 2Dfields_shadow.pdf ${ofold}/${exp}/${var}tmean.pdf |
---|
2477 | # evince ${ofold}/${exp}/${var}tmean.pdf & |
---|
2478 | # exit |
---|
2479 | fi |
---|
2480 | fi |
---|
2481 | done |
---|
2482 | done |
---|
2483 | fi |
---|
2484 | |
---|
2485 | # lon 2 vertical section |
---|
2486 | ## |
---|
2487 | echo "lon 2 vertical section ..." |
---|
2488 | vars=`echo ${lon2DZsecvars} | tr ':' ' '` |
---|
2489 | pts=`echo ${lon2DZsecpts} | tr ':' ' '` |
---|
2490 | |
---|
2491 | if ${lonZsec}; then |
---|
2492 | for exp in ${exps}; do |
---|
2493 | file=${ofold}/${exp}/vertical_interpolation_WRFp.nc |
---|
2494 | # python ${pyHOME}/nc_var.py -o WRF_CFlonlat_creation -S longitude,latitude \ |
---|
2495 | # -f ${file} -v lon,lat |
---|
2496 | ## ALREADY done! |
---|
2497 | # python ${pyHOME}/nc_var.py -o valmod -S lowthres@oper,0.,sumc,360. -f ${file} \ |
---|
2498 | # -v lon |
---|
2499 | if test ${exp} = 'AR40'; then labexp='wlmdza' |
---|
2500 | else labexp='wlmdzb'; fi |
---|
2501 | |
---|
2502 | for pt in ${pts}; do |
---|
2503 | echo " pt: "${pt} |
---|
2504 | vals='x:15|y:'${pt}'|time:23' |
---|
2505 | lonval=`python ${pyHOME}/nc_var.py -o varout -f ${file} -S ${vals} -v lon | \ |
---|
2506 | awk '{print $2}'` |
---|
2507 | latval=`python ${pyHOME}/nc_var.py -o varout -f ${file} -S ${vals} -v lat | \ |
---|
2508 | awk '{print $2}'` |
---|
2509 | tval=`python ${pyHOME}/nc_var.py -o varout -f ${file} -S ${vals} -v time | \ |
---|
2510 | awk '{print $2}'` |
---|
2511 | for var in ${vars}; do |
---|
2512 | echo " var: "${var} |
---|
2513 | |
---|
2514 | shdvals=`python ${pyHOME}/drawing.py -o variable_values -S ${var} | \ |
---|
2515 | grep all_values | awk '{print $3}'` |
---|
2516 | cbar=`echo ${shdvals} | tr ',' ' ' | awk '{print $7}'` |
---|
2517 | min=`echo ${shdvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2518 | max=`echo ${shdvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2519 | |
---|
2520 | # WRFt,U,V,WRFrh,WRFght |
---|
2521 | if test ${var} = 'WRFght'; then xtrms='0,40000'; |
---|
2522 | elif test ${var} = 'WRFt'; then xtrms='200,300'; |
---|
2523 | elif test ${var} = 'U'; then xtrms='-40,40'; |
---|
2524 | elif test ${var} = 'V'; then xtrms='-20,20'; |
---|
2525 | else xtrms=${min}','${max}; fi |
---|
2526 | |
---|
2527 | # Plotting |
---|
2528 | vals=${var}':x|-1,y|'${pt}',z|-1,time|24:lon:pressure:'${cbar}':' |
---|
2529 | vals=${vals}${xtrms}':'${labexp}'|vertical|longitudinal|section|('${latval} |
---|
2530 | vals=${vals}'$^{\circ}$):pdf:flip@y:None:true' |
---|
2531 | python ${pyHOME}/drawing.py -o draw_2D_shad -S ${vals} -f ${file} -v ${var} |
---|
2532 | pyexec=$? |
---|
2533 | if test ${pyexec} -ne 0; then |
---|
2534 | echo ${errormsg} |
---|
2535 | echo " "${main}": python fails!" |
---|
2536 | exit |
---|
2537 | else |
---|
2538 | mv 2Dfields_shadow.pdf ${ofold}/${exp}/${var}_lonZsec_${pt}pt.pdf |
---|
2539 | evince ${ofold}/${exp}/${var}_lonZsec_${pt}pt.pdf & |
---|
2540 | fi |
---|
2541 | |
---|
2542 | cntcolor='black' |
---|
2543 | cntfmt='%g' |
---|
2544 | |
---|
2545 | if test ${var} = 'WRFght'; then cxtrms='0,40000'; |
---|
2546 | elif test ${var} = 'WRFt'; then cxtrms='200,300'; |
---|
2547 | elif test ${var} = 'U'; then cxtrms='-40,40'; |
---|
2548 | elif test ${var} = 'V'; then cxtrms='-20,20'; |
---|
2549 | else cxtrms=${min}','${max}; fi |
---|
2550 | |
---|
2551 | graphvals=${var}','${var}':x|-1,y|'${pt}',z|-1,time|24:' |
---|
2552 | graphvals=${graphvals}'x|-1,y|'${pt}',z|-1,time|24:lon:pressure:' |
---|
2553 | graphvals=${graphvals}${cbar}':fixsigc,'${cntcolor}':'${cntfmt}':'${xtrms}':' |
---|
2554 | graphvals=${graphvals}${cxtrms}',15:'${labexp} |
---|
2555 | graphvals=${graphvals}'|vertical|zonal|section|('${latval}'$^{\circ}$):pdf:' |
---|
2556 | graphvals=${graphvals}'flip@y:None' |
---|
2557 | |
---|
2558 | python ${pyHOME}/drawing.py -o draw_2D_shad_cont -S ${graphvals} \ |
---|
2559 | -f ${file},${file} -v ${var},${var} |
---|
2560 | pyexec=$? |
---|
2561 | if test ${pyexec} -ne 0; then |
---|
2562 | echo ${errormsg} |
---|
2563 | echo " "${main}": python fails!" |
---|
2564 | exit |
---|
2565 | else |
---|
2566 | mv 2Dfields_shadow-contour.pdf ${ofold}/${exp}/${var}_lonZsec-cnt_${pt}pt.pdf |
---|
2567 | evince ${ofold}/${exp}/${var}_lonZsec-cnt_${pt}pt.pdf & |
---|
2568 | fi |
---|
2569 | |
---|
2570 | # exit |
---|
2571 | done |
---|
2572 | done |
---|
2573 | done |
---|
2574 | fi |
---|
2575 | |
---|
2576 | echo "Computing differences" |
---|
2577 | exp1=`echo ${experiments} | tr ':' ' ' | awk '{print $1}'` |
---|
2578 | exp2=`echo ${experiments} | tr ':' ' ' | awk '{print $2}'` |
---|
2579 | |
---|
2580 | diffks=`echo ${diffkinds} | tr ':' ' '` |
---|
2581 | |
---|
2582 | if test ${differences}; then |
---|
2583 | for kind in ${diffks}; do |
---|
2584 | echo ${kind} |
---|
2585 | case ${kind} in |
---|
2586 | 'diffZ') |
---|
2587 | vars=`echo ${diffZvars} | tr ':' ' '` |
---|
2588 | fileorigd='mean.nc' |
---|
2589 | ;; |
---|
2590 | 'diffH') |
---|
2591 | vars=`echo ${diffHvars} | tr ':' ' '` |
---|
2592 | fileorigd='tmean.nc' |
---|
2593 | ;; |
---|
2594 | esac |
---|
2595 | |
---|
2596 | echo " "${var} |
---|
2597 | for var in ${vars}; do |
---|
2598 | if test ! -f ${ofold}/${var}_diff.nc; then |
---|
2599 | # cdo sub ${ofold}/${exp1}/${var}${fileorigd} ${ofold}/${exp2}/${var}${fileorigd} ${ofold}/${var}_diff.nc |
---|
2600 | if test ${kind} = 'diffZ'; then |
---|
2601 | values='pressure|lat@add|'${ofold}'/'${exp1}'/'${var}${fileorigd}'|'${var}'mean,' |
---|
2602 | values=${values}'sub|'${ofold}'/'${exp2}'/'${var}${fileorigd}'|'${var}'mean' |
---|
2603 | python ${pyHOME}/nc_var.py -o compute_opersvarsfiles -S ${values} -v ${var} |
---|
2604 | pyexec=$? |
---|
2605 | if test ${pyexec} -ne 0; then |
---|
2606 | echo ${errormsg} |
---|
2607 | echo " "${main}": python fails!" |
---|
2608 | exit |
---|
2609 | fi |
---|
2610 | mv opersvarsfiles_${var}.nc ${ofold}/${var}_diff.nc |
---|
2611 | else |
---|
2612 | values='longitude|latitude@add|'${ofold}'/'${exp1}'/'${var}${fileorigd}'|'${var}'mean,' |
---|
2613 | values=${values}'sub|'${ofold}'/'${exp2}'/'${var}${fileorigd}'|'${var}'mean' |
---|
2614 | python ${pyHOME}/nc_var.py -o compute_opersvarsfiles -S ${values} -v ${var} |
---|
2615 | pyexec=$? |
---|
2616 | if test ${pyexec} -ne 0; then |
---|
2617 | echo ${errormsg} |
---|
2618 | echo " "${main}": python fails!" |
---|
2619 | exit |
---|
2620 | fi |
---|
2621 | mv opersvarsfiles_${var}.nc ${ofold}/${var}_diff.nc |
---|
2622 | fi |
---|
2623 | fi |
---|
2624 | done |
---|
2625 | |
---|
2626 | if test ${kind} = 'diffZ'; then |
---|
2627 | coups=`echo ${graph_couples_mean} | tr ':' ' '` |
---|
2628 | for coup in ${coups}; do |
---|
2629 | shdvar=`echo ${coup} | tr '@' ' ' | awk '{print $1}'` |
---|
2630 | cntvar=`echo ${coup} | tr '@' ' ' | awk '{print $2}'` |
---|
2631 | |
---|
2632 | echo " couple: "${shdvar}'-'${cntvar} |
---|
2633 | |
---|
2634 | shdvals=`python ${pyHOME}/drawing.py -o variable_values -S ${shdvar} | grep all_values | awk '{print $3}'` |
---|
2635 | cntvals=`python ${pyHOME}/drawing.py -o variable_values -S ${cntvar} | grep all_values | awk '{print $3}'` |
---|
2636 | files=${ofold}'/'${shdvar}'_diff.nc,'${ofold}'/'${cntvar}'_diff.nc' |
---|
2637 | |
---|
2638 | shdstdn=`echo ${shdvals} | tr ',' ' ' | awk '{print $1}'` |
---|
2639 | shdcbar=`echo ${shdvals} | tr ',' ' ' | awk '{print $7}'` |
---|
2640 | shdmin=`echo ${shdvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2641 | shdmax=`echo ${shdvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2642 | |
---|
2643 | cntstdn=`echo ${cntvals} | tr ',' ' ' | awk '{print $1}'` |
---|
2644 | cntmin=`echo ${cntvals} | tr ',' ' ' | awk '{print $3}'` |
---|
2645 | cntmax=`echo ${cntvals} | tr ',' ' ' | awk '{print $4}'` |
---|
2646 | |
---|
2647 | shdcbar='seismic' |
---|
2648 | if test ${coup} = 'va@ua'; then |
---|
2649 | shdmin=-4. |
---|
2650 | shdmax=4. |
---|
2651 | cntmin=-10. |
---|
2652 | cntmax=10. |
---|
2653 | elif test ${coup} = 'hus@ta'; then |
---|
2654 | shdmin=-0.2 |
---|
2655 | shdmax=0.2 |
---|
2656 | cntmin=-2. |
---|
2657 | cntmax=2. |
---|
2658 | fi |
---|
2659 | |
---|
2660 | cntcolor='black' |
---|
2661 | cntfmt='%g' |
---|
2662 | |
---|
2663 | graphvals=${shdstdn}','${cntstdn}':x|-1,y|-1,x_2|-1:x|-1,y|-1,x_2|-1:lat:' |
---|
2664 | graphvals=${graphvals}'pressure:'${shdcbar}':fixsigc,'${cntcolor}':'${cntfmt}':' |
---|
2665 | graphvals=${graphvals}${shdmin}','${shdmax}':'${cntmin}','${cntmax}',9:' |
---|
2666 | graphvals=${graphvals}${exp1}'-'${exp2}'|meridional|monthly|average|differences|of|' |
---|
2667 | graphvals=${graphvals}${shdstdn}'|&|'${cntstdn}':pdf:flip@y:None' |
---|
2668 | |
---|
2669 | python ${pyHOME}/drawing.py -o draw_2D_shad_cont -S ${graphvals} \ |
---|
2670 | -f ${files} -v ${shdvar},${cntvar} |
---|
2671 | pyexec=$? |
---|
2672 | if test ${pyexec} -ne 0; then |
---|
2673 | echo ${errormsg} |
---|
2674 | echo " "${main}": python fails!" |
---|
2675 | exit |
---|
2676 | else |
---|
2677 | mv 2Dfields_shadow-contour.pdf ${ofold}/${shdvar}-${cntvar}_diff.pdf |
---|
2678 | evince ${ofold}/${shdvar}-${cntvar}_diff.pdf & |
---|
2679 | fi |
---|
2680 | done |
---|
2681 | # exit |
---|
2682 | else |
---|
2683 | for var in ${vars}; do |
---|
2684 | echo " "${var} |
---|
2685 | vals=`python ${pyHOME}/drawing.py -o variable_values -S ${var} | grep all_values | awk '{print $3}'` |
---|
2686 | file=${ofold}/${var}_diff.nc |
---|
2687 | |
---|
2688 | stdn=`echo ${vals} | tr ',' ' ' | awk '{print $1}'` |
---|
2689 | cbar='seismic' |
---|
2690 | |
---|
2691 | if test ${var} = 'uas'; then xtrms='-10.,10.'; |
---|
2692 | elif test ${var} = 'vas'; then xtrms='-5,5'; |
---|
2693 | elif test ${var} = 'ps'; then xtrms='-500,500'; |
---|
2694 | elif test ${var} = 'pr'; then xtrms='-0.001,0.001'; |
---|
2695 | else xtrms=${min}','${max}; fi |
---|
2696 | |
---|
2697 | vals=${var}':x|-1,y|-1:longitude:latitude:'${cbar}':' |
---|
2698 | vals=${vals}${xtrms}':'${exp1}'-'${exp2}'|meridional|monthly|average|differences:' |
---|
2699 | vals=${vals}'pdf:None:None:true' |
---|
2700 | python ${pyHOME}/drawing.py -o draw_2D_shad -S ${vals} -f ${file} -v ${var} |
---|
2701 | pyexec=$? |
---|
2702 | if test ${pyexec} -ne 0; then |
---|
2703 | echo ${errormsg} |
---|
2704 | echo " "${main}": python fails!" |
---|
2705 | exit |
---|
2706 | else |
---|
2707 | mv 2Dfields_shadow.pdf ${ofold}/${var}_diff.pdf |
---|
2708 | evince ${ofold}/${var}_diff.pdf & |
---|
2709 | fi |
---|
2710 | # exit |
---|
2711 | done |
---|
2712 | fi |
---|
2713 | done |
---|
2714 | fi |
---|