1 | comp=$1 |
---|
2 | local=`pwd` |
---|
3 | season=YEAR |
---|
4 | force_create=0 |
---|
5 | |
---|
6 | MAIN_SE=/prodigfs/ipslfs/dods/fabric/lmdz/SE |
---|
7 | GR=VLR/YEAR |
---|
8 | MULTIDIR=/prodigfs/ipslfs/dods/fabric/lmdz/MultiSimu |
---|
9 | COMP_D=$MULTIDIR/$comp |
---|
10 | |
---|
11 | |
---|
12 | ############################################### |
---|
13 | # Liste des simulations de la comparasion $comp |
---|
14 | listsims="" |
---|
15 | DEF_FILE=$COMP_D/def.txt ; if [ ! -f $DEF_FILE ] ; then renseigner $DEF_FILE ; exit ; fi |
---|
16 | for s in `awk ' {print $1} ' $DEF_FILE` ; do listsims="$listsims $s" ; done |
---|
17 | ############################################### |
---|
18 | |
---|
19 | echo $listsims |
---|
20 | ici=`pwd` |
---|
21 | |
---|
22 | for sim in OBS $listsims ; do |
---|
23 | if [ "$sim" = "OBS" ] ; then |
---|
24 | years="" |
---|
25 | else |
---|
26 | years=_`grep '^'$sim' ' $DEF_FILE | awk ' { print $2 }'` |
---|
27 | fi |
---|
28 | SIM_DIR=/prodigfs/ipslfs/dods/fabric/lmdz/$GR/$sim$years |
---|
29 | ETOA_DIR=$SIM_DIR/METRICS |
---|
30 | |
---|
31 | for mask in otrop glob eto otrop weak conv subs ; do |
---|
32 | xmgr=$ETOA_DIR/$mask |
---|
33 | mkdir -p $ETOA_DIR |
---|
34 | if [ ! -f $xmgr -o "$force_create" = "1" ] ; then |
---|
35 | \rm -f $xmgr ; touch $xmgr |
---|
36 | if [ ! -d $SIM_DIR ] ; then echo $SIM_DIR absent ; exit ; fi |
---|
37 | \rm resu$sim |
---|
38 | for var in clhcalipso cllcalipso clmcalipso cltcalipso clt hfls hfss hurs huss pr psl rldscs rlds rlus rlutcs rlut rsdscs rsds rsdt rsuscs rsus rsutcs rsut ; do |
---|
39 | if [ "$mask" = "glob" ] ; then |
---|
40 | val=`cdo output -fldmean $SIM_DIR/NC/$var.nc` |
---|
41 | elif [ ! -f mask$mask.nc ] ; then |
---|
42 | echo Le fichier mask$mask.nc n existe pas ; exit |
---|
43 | else |
---|
44 | cdo remapcon,mask$mask.nc $SIM_DIR/NC/$var.nc tmp.nc |
---|
45 | val=`cdo output -fldmean -mul tmp.nc mask$mask.nc` |
---|
46 | echo cdo output -fldmean -mul $tmp.nc mask$mask.nc |
---|
47 | fi |
---|
48 | echo $mask $sim $var $val |
---|
49 | echo $var $val >> $xmgr |
---|
50 | done |
---|
51 | rsut=`grep '^rsut ' $xmgr | awk ' { print $2 } '` |
---|
52 | rsutcs=`grep '^rsutcs ' $xmgr | awk ' { print $2 } '` |
---|
53 | rlut=`grep '^rlut ' $xmgr | awk ' { print $2 } '` |
---|
54 | rlutcs=`grep '^rlutcs ' $xmgr | awk ' { print $2 } '` |
---|
55 | hfls=`grep '^hfls ' $xmgr | awk ' { print $2 } '` |
---|
56 | hfss=`grep '^hfss ' $xmgr | awk ' { print $2 } '` |
---|
57 | rlds=`grep '^rlds ' $xmgr | awk ' { print $2 } '` |
---|
58 | rsds=`grep '^rsds ' $xmgr | awk ' { print $2 } '` |
---|
59 | rlus=`grep '^rlus ' $xmgr | awk ' { print $2 } '` |
---|
60 | rsus=`grep '^rsus ' $xmgr | awk ' { print $2 } '` |
---|
61 | rsdt=`grep '^rsdt ' $xmgr | awk ' { print $2 } '` |
---|
62 | echo $rsut $rsutcs $xmgr | awk ' { print "crest" , $2 - $1 } ' >> $xmgr |
---|
63 | echo $rlut $rlutcs $xmgr | awk ' { print "crelt" , $2 - $1 } ' >> $xmgr |
---|
64 | echo $rsut $rsutcs $rlut $rlutcs $xmgr | awk ' { print "cret" , $2 - $1 +$4 -$3 } ' >> $xmgr |
---|
65 | echo $rsdt $rsut $xmgr | awk ' { print "rst" , $1 - $2 } ' >> $xmgr |
---|
66 | echo $rsdt $rsut $rlut $xmgr | awk ' { print "rt" , $1 - $2 -$3 } ' >> $xmgr |
---|
67 | echo $hfls $hfss $xmgr | awk ' { print "trbs" , $1 + $2 } ' >> $xmgr |
---|
68 | echo $rlds $rlus $xmgr | awk ' { print "rls" , $1 - $2 } ' >> $xmgr |
---|
69 | echo $rsds $rsus $xmgr | awk ' { print "rss" , $1 - $2 } ' >> $xmgr |
---|
70 | echo $rlds $rlus $rsds $rsus $xmgr | awk ' { print "rs" , $1 - $2 +$3 - $4 } ' >> $xmgr |
---|
71 | echo $rlds $rlus $rsds $rsus $hfls $hfss $xmgr | awk ' { print "bils" , $1 - $2 + $3 - $4 - $5 - $6 } ' >> $xmgr |
---|
72 | fi |
---|
73 | done |
---|
74 | |
---|
75 | # Masques combinés |
---|
76 | paste $ETOA_DIR/otrop $ETOA_DIR/eto | awk ' { print $1 , $4 - $2 } ' >| $ETOA_DIR/etoa |
---|
77 | |
---|
78 | done |
---|
79 | |
---|
80 | |
---|
81 | ######################################################################################### |
---|
82 | # Tracers |
---|
83 | ######################################################################################### |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | cat <<eod>| descr |
---|
88 | clhcalipso 1 High Clouds |
---|
89 | cllcalipso 1 Low Clouds |
---|
90 | clmcalipso 1 Mid Clouds |
---|
91 | cltcalipso 1 Total Clouds |
---|
92 | clt |
---|
93 | hfls -1 -LE |
---|
94 | hfss -1 -H |
---|
95 | hurs 1 RHsrf |
---|
96 | huss |
---|
97 | pr 10 PR*10 |
---|
98 | psl 1 SLP |
---|
99 | rlds 1 LWdn srf |
---|
100 | rldscs 1 LWdn srf Clr |
---|
101 | rlus -1 LWup Srf |
---|
102 | rlutcs -1 LW TOA Clr |
---|
103 | rlut -1 LW TOA |
---|
104 | rsdscs 1 SWdn srf Clr |
---|
105 | rsds 1 SWdn srf |
---|
106 | rsdt 1 SWdn TOA |
---|
107 | rsuscs -1 SWup srf Clr |
---|
108 | rsus -1 SWup srf |
---|
109 | rsutcs -1 SW TOA Clr |
---|
110 | rsut -1 SW TOA |
---|
111 | crest 1 SW CRE TOA |
---|
112 | crelt 1 LW CRE TOA |
---|
113 | cret 1 CRE TOA |
---|
114 | rst 1 SW TOA |
---|
115 | rt 1 SW+LW TOA |
---|
116 | trbs -1 -(LE+H) |
---|
117 | rls 1 LW srf |
---|
118 | rss 1 SW srf |
---|
119 | rs 1 SW+LW srf |
---|
120 | bils 1 Srf budget |
---|
121 | eod |
---|
122 | |
---|
123 | |
---|
124 | for mask in glob etoa conv weak subs ; do |
---|
125 | |
---|
126 | case $mask in |
---|
127 | etoa) listevars="bils rss crest rt hfls trbs cllcalipso clmcalipso clhcalipso pr" ;; |
---|
128 | glob|conv|weak|subs) listevars="bils rt rlutcs crelt rsutcs crest cllcalipso clmcalipso clhcalipso pr" ;; |
---|
129 | *) echo cas non prevu ; exit |
---|
130 | esac |
---|
131 | |
---|
132 | nvars=`echo $listevars | wc -w | awk ' { print $1 } '` |
---|
133 | case $mask in |
---|
134 | glob) yax="Global " ;; |
---|
135 | etoa) yax="ETOA " ;; |
---|
136 | conv) yax="Convective regimes " ;; |
---|
137 | weak) yax="Weak convection " ;; |
---|
138 | subs) yax="Subsidences " |
---|
139 | esac |
---|
140 | cat <<...eod>| tmp.param |
---|
141 | g0 type Chart |
---|
142 | world -0.5, -25, $nvars, 25 |
---|
143 | yaxis label "$yax, Fluxes (W/m2) " |
---|
144 | xaxis ticklabel font 0 |
---|
145 | xaxis ticklabel color 1 |
---|
146 | xaxis tick place both |
---|
147 | xaxis tick spec type both |
---|
148 | xaxis tick spec 11 |
---|
149 | legend 1.20, 0.8 |
---|
150 | xaxis ticklabel char size 1.3 |
---|
151 | xaxis ticklabel angle 90 |
---|
152 | ...eod |
---|
153 | |
---|
154 | ii=0 |
---|
155 | for var in $listevars ; do |
---|
156 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
157 | titre=`grep "^$var " descr | sed -e 's/'$var'//' -e 's/'$fact'//'` |
---|
158 | cat <<......eod>> tmp.param |
---|
159 | xaxis tick major $ii, $ii |
---|
160 | xaxis ticklabel $ii, "$titre" |
---|
161 | ......eod |
---|
162 | (( ii = $ii + 1 )) |
---|
163 | done |
---|
164 | |
---|
165 | |
---|
166 | for sim in $listsims ; do |
---|
167 | echo $sim |
---|
168 | years=_`grep '^'$sim' ' $DEF_FILE | awk ' { print $2 }'` |
---|
169 | SIM_DIR=/prodigfs/ipslfs/dods/fabric/lmdz/$GR/$sim$years/METRICS |
---|
170 | ls $SIM_DIR |
---|
171 | OBS_DIR=/prodigfs/ipslfs/dods/fabric/lmdz/$GR/OBS/METRICS |
---|
172 | mkdir -p XMGR$$/$mask |
---|
173 | xmgr=XMGR$$/$mask/$sim ; rm -f $xmgr ; touch $xmgr |
---|
174 | for var in $listevars ; do |
---|
175 | echo var $var |
---|
176 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
177 | paste $OBS_DIR/$mask $SIM_DIR/$mask | grep "^$var " | awk ' { print '$fact' * ( $4 -$2 ) } ' >> $xmgr |
---|
178 | done |
---|
179 | done |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | size=`echo $listsims | wc -w | awk ' { print 3. / $1 } '` |
---|
184 | for ii in 0 1 2 3 4 5 6 7 8 9 10 11 12 ; do |
---|
185 | echo "s$ii type bar" >> tmp.param |
---|
186 | echo "s$ii symbol fill pattern 1" >> tmp.param |
---|
187 | echo "s$ii symbol size $size" >> tmp.param |
---|
188 | echo "s$ii line linestyle 0" >> tmp.param |
---|
189 | done |
---|
190 | |
---|
191 | cd XMGR$$/$mask |
---|
192 | xmgrace * -param ../../tmp.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
193 | epstopdf tmp.eps |
---|
194 | OUT_D=$COMP_D/METRICS ; mkdir -p $OUT_D |
---|
195 | \mv -f tmp.pdf $OUT_D/$mask.pdf ; convert -density 144 $OUT_D/$mask.pdf $OUT_D/$mask.png |
---|
196 | cd ../.. |
---|
197 | |
---|
198 | done |
---|
199 | |
---|
200 | cp mask*png $OUT_D |
---|