1 | #!/bin/bash |
---|
2 | # Par exemple: |
---|
3 | # ./make_axe2.sh V6.5AIS8 |
---|
4 | # ----------------------------------------------------------------- |
---|
5 | |
---|
6 | set -vx |
---|
7 | pr_yr=1 |
---|
8 | pr_da=1 |
---|
9 | |
---|
10 | # ----------------------------------------------------------------- |
---|
11 | # Based on /home/fabric/LMDZ/UTILS/config.sh |
---|
12 | # ----------------------------------------------------------------- |
---|
13 | |
---|
14 | #runstxt=/home/fabric/LMDZ/MultiSimu/runs.txt |
---|
15 | runstxt=~/Multi_atlas/runs.txt |
---|
16 | |
---|
17 | while test -n "${1}"; do |
---|
18 | case $1 in |
---|
19 | -runstxt) runstxt=$2 ; shift ;; |
---|
20 | -h) echo "Example: ./make_axe2.sh [-runstxt runs.description.file] V6.5AIS8" ;; |
---|
21 | *) comp=$1 ;; |
---|
22 | esac |
---|
23 | shift |
---|
24 | done |
---|
25 | |
---|
26 | |
---|
27 | season=YEAR |
---|
28 | GR=VLR |
---|
29 | MAIN_SE=/thredds/ipsl/fabric/lmdz/SE |
---|
30 | EXPNAME=NPV5LRL79 |
---|
31 | STOREDIR=/thredds/ipsl/fabric/lmdz/STORE/$EXPNAME |
---|
32 | MULTIDIR=/thredds/ipsl/fabric/lmdz/MultiSimu |
---|
33 | |
---|
34 | WRK=$MULTIDIR/AXE2/WORK$$ |
---|
35 | if [ -d $WRK ] ; then WRK=$WRK$$ ; fi |
---|
36 | mkdir -p $WRK ; cd $WRK |
---|
37 | |
---|
38 | COMP_D=$MULTIDIR/$comp |
---|
39 | if [ ! -d $COMP_D ] ; then echo "$COMP_D not found" && exit ; fi |
---|
40 | |
---|
41 | # ----------------------------------------------------------------- |
---|
42 | # Liste des simulations de la comparasion $comp |
---|
43 | # ----------------------------------------------------------------- |
---|
44 | liste_simy="" |
---|
45 | DEF_FILE=$COMP_D/def.txt |
---|
46 | for s in `awk ' {print $1} ' $DEF_FILE` ; do liste_sim="$liste_sim $s" ; done |
---|
47 | for s in `awk ' {print $1"_"$2} ' $DEF_FILE` ; do liste_simy="$liste_simy $s" ; done |
---|
48 | |
---|
49 | # ----------------------------------------------------------------- |
---|
50 | # ----------------------------------------------------------------- |
---|
51 | # Analyse de la distribution longitudinale des precipitation |
---|
52 | # sur ocean et continent |
---|
53 | # ----------------------------------------------------------------- |
---|
54 | # ----------------------------------------------------------------- |
---|
55 | |
---|
56 | echo OK0 |
---|
57 | |
---|
58 | outputdir=$COMP_D/AXE2/PR_YR |
---|
59 | if [ -d $outputdir/PNG ] ; then pr_yr=0 ; fi |
---|
60 | if [ $pr_yr = 1 -o 0 = 0 ] ; then |
---|
61 | |
---|
62 | echo OK1 |
---|
63 | |
---|
64 | outputdir=$COMP_D/AXE2/PR_YR |
---|
65 | for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done |
---|
66 | |
---|
67 | echo OK2 $liste_sim |
---|
68 | |
---|
69 | listey="" |
---|
70 | for simy in $liste_simy ; do |
---|
71 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
72 | years=`echo $simy | sed -e 's/'$sim'_//'` |
---|
73 | simdir=`grep -w "^$sim " $runstxt | awk ' { print $2 } '` |
---|
74 | ncks -v precip $simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc -O grid.nc |
---|
75 | cdo timavg -remapcon,grid.nc /thredds/ipsl/fabric/lmdz/SE/CMOR/OBS/pr.nc gpcp.nc |
---|
76 | cdo timavg -remapcon,grid.nc /thredds/ipsl/fabric/lmdz/TRMM/prm2000-2009.nc trmm.nc |
---|
77 | |
---|
78 | ###################################################### |
---|
79 | # Sauvegarde d'un masque oceanique pour le diag MJO |
---|
80 | ###################################################### |
---|
81 | if [ ! -f $WRK/pourc_oce.nc ] ; then ncks -d time_counter,1 -v pourc_oce "$simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc" $WRK/pourc_oce.nc ; fi |
---|
82 | echo ncks -d time_counter,1 -v pourc_oce "$simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc" $WRK/pourc_oce.nc |
---|
83 | cat <<eod>| tmpyr.jnl |
---|
84 | use "$simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc" |
---|
85 | use gpcp.nc |
---|
86 | use trmm.nc |
---|
87 | let con=pourc_ter[d=1,l=1:12@ave]+pourc_lic[d=1,l=1:12@ave] |
---|
88 | let oce=pourc_oce[d=1,l=1:12@ave]+pourc_sic[d=1,l=1:12@ave] |
---|
89 | let ocem=if ( oce[l=1] ge 99. ) then 1 |
---|
90 | let conm=if ( con[l=1] ge 99. ) then 1 |
---|
91 | let mixm=if ( oce[l=1] gt 1. AND con[l=1] gt 1. ) then 1 |
---|
92 | let totm=tsol[d=1,l=1]*0.+1. |
---|
93 | |
---|
94 | let filtre=var |
---|
95 | go tmp0.jnl TOT,8,totm |
---|
96 | frame/file=tot.gif |
---|
97 | let filtre=if ( oce[l=1] ge 99.9 ) then var*oce/100. |
---|
98 | go tmp0.jnl OCE,9,ocem |
---|
99 | frame/file=oce.gif |
---|
100 | let filtre=if ( con[l=1] ge 99.9 ) then var*con/100. |
---|
101 | go tmp0.jnl CONT,10,conm |
---|
102 | frame/file=con.gif |
---|
103 | let filtre=if ( con[l=1] gt 0.1 AND oce[l=1] gt 0.1 ) then var |
---|
104 | go tmp0.jnl MIXT,11,mixm |
---|
105 | frame/file=mix.gif |
---|
106 | list/x=-10:10/y=12:18 "PRlmdzAMMA",86400*precip[d=1,i=@ave,j=@ave,l=1:12@ave] |
---|
107 | list/x=-10:10/y=12:18 "PRtrmmAMMA",r[d=3,i=@ave,j=@ave,l=1:12@ave] |
---|
108 | list/x=-10:10/y=12:18 "PRgpcpAMMA",86400*pr[d=2,i=@ave,j=@ave,l=1:12@ave] |
---|
109 | eod |
---|
110 | |
---|
111 | cat <<eod>| tmp0.jnl |
---|
112 | let mask=\$3 |
---|
113 | let var=86400*precip[d=1]*mask[i=@ave,j=@ave] |
---|
114 | plot/line=\$2/vlim=0:10/title="$sim $years pr \$1 (mm/d)" filtre[i=@ave,l=1:12@ave] |
---|
115 | list/y=-50:50 "PRlmdz\$1",filtre[i=@ave,j=@ave,l=1:12@ave] |
---|
116 | let var=r[d=3]*mask |
---|
117 | plot/line=1/o/title="TRMM" filtre[i=@ave,l=1] |
---|
118 | list/y=-50:50 "PRtrmm\$1",filtre[i=@ave,j=@ave,l=1:12@ave] |
---|
119 | let var=86400*pr[d=2]*mask |
---|
120 | plot/line=7/o/title="GPCP" filtre[i=@ave,l=1:12@ave] |
---|
121 | list/y=-50:50 "PRgpcp\$1",filtre[i=@ave,j=@ave,l=1:12@ave] |
---|
122 | quit |
---|
123 | eod |
---|
124 | |
---|
125 | #pwd ; exit |
---|
126 | |
---|
127 | ferret -gif -nojnl -script tmpyr.jnl | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/${sim}_${years} |
---|
128 | for type in con mix tot oce ; do |
---|
129 | convert -density 144 $type.gif $outputdir/PNG/${sim}_${years}_$type.png |
---|
130 | listey="$listey ${sim}_${years}_$type" |
---|
131 | done |
---|
132 | |
---|
133 | done |
---|
134 | |
---|
135 | if [ -f $COMP_D/entete.html ] ; then cat $COMP_D/entete.html > $outputdir/index.html ; fi |
---|
136 | #~/LMDZ/MultiSimu/concat_html.sh $COMP_D/AXE2/PR_YR/PNG "OK" "$listey" 4 >> $outputdir/index.html |
---|
137 | ~/Multi_atlas/concat_html.sh $COMP_D/AXE2/PR_YR/PNG "OK" "$listey" 4 >> $outputdir/index.html |
---|
138 | |
---|
139 | |
---|
140 | fi # pr_yr=1 |
---|
141 | |
---|
142 | # ----------------------------------------------------------------- |
---|
143 | # ----------------------------------------------------------------- |
---|
144 | # Analyse de la variabilité jour à jour des pluies |
---|
145 | # ----------------------------------------------------------------- |
---|
146 | # ----------------------------------------------------------------- |
---|
147 | outputdir=$COMP_D/AXE2/PR_DAY |
---|
148 | # if [ -d $outputdir ] ; then pr_da = 0 ; fi |
---|
149 | |
---|
150 | if [ $pr_da = 1 ] ; then |
---|
151 | |
---|
152 | listey="" |
---|
153 | |
---|
154 | outputdir=$COMP_D/AXE2/PR_DAY |
---|
155 | for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done |
---|
156 | |
---|
157 | # PLOT SIMULATION RESULTS |
---|
158 | first=1 |
---|
159 | for simy in $liste_simy ; do |
---|
160 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
161 | years=`echo $simy | sed -e 's/'$sim'_//'` |
---|
162 | |
---|
163 | yi=`echo $years | cut -d_ -f1` |
---|
164 | yf=`echo $years | cut -d_ -f2` |
---|
165 | echo FICHIERS POUR LA SIMULATION $sim annees $years |
---|
166 | simdir=`grep -w "^$sim " $runstxt | awk ' { print $2 } '` |
---|
167 | run=`basename $simdir ` |
---|
168 | prd=`ls $simdir/ATM/Analyse/TS_DA/${run}_${yi}*_${yf}*_1D_precip.nc | tail -1` |
---|
169 | prc=`ls $simdir/ATM/Analyse/TS_DA/${run}_${yi}*_${yf}*_1D_pluc.nc | tail -1` |
---|
170 | prl=`ls $simdir/ATM/Analyse/TS_DA/${run}_${yi}*_${yf}*_1D_plul.nc | tail -1` |
---|
171 | ln -s $prd $outputdir/NC/${run}_${yi}_${yf}.nc |
---|
172 | prm=$simdir/ATM/Analyse/SE/${run}_SE_${years}_1M_histmth.nc |
---|
173 | if [ ! -f $prm ] ; then echo $prm not found ; exit ; fi |
---|
174 | if [ $first = 1 ] ; then |
---|
175 | remap=$prm ; first=0 |
---|
176 | trmm=$outputdir/NC/TRMM.nc |
---|
177 | if [ ! -f $trmm ] ; then |
---|
178 | ncks -v precip $prm -O $outputdir/NC/grid.nc |
---|
179 | cdo remapcon,$outputdir/NC/grid.nc /thredds/ipsl/fabric/lmdz/TRMM/pr2000-2009.nc $trmm |
---|
180 | fi |
---|
181 | ts_da="TRMM" |
---|
182 | fi |
---|
183 | echo PRD $prd |
---|
184 | if [ -f "$prd" ] ; then ts_da="$ts_da ${run}_${yi}_${yf}" ; fi |
---|
185 | done |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | for sim in $ts_da ; do |
---|
190 | echo Tracer de $sim |
---|
191 | if [ $sim = TRMM ] ; then |
---|
192 | var=r |
---|
193 | else |
---|
194 | var='86400*precip' |
---|
195 | fi |
---|
196 | |
---|
197 | nom=`echo $sim | sed -e 's/_/ /g'` |
---|
198 | cat <<eod>| tmp.jnl |
---|
199 | use "$WRK/pourc_oce.nc" |
---|
200 | use "$outputdir/NC/$sim.nc" |
---|
201 | DEFINE VIEWPORT/XLIM=0.,1./YLIM= .5,1. V1 |
---|
202 | DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.2,0.7 V2 |
---|
203 | DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.,0.35 V3 |
---|
204 | set memory/size=1000 |
---|
205 | let var=$var |
---|
206 | let dv=var-var[l=@sbx:30] |
---|
207 | let dv2=dv*dv |
---|
208 | let dv2oce=if ( pourc_oce[d=1,l=1] ge 99. ) then dv2 |
---|
209 | reg/y=-50:50 |
---|
210 | fill/pal=rain_cmyk/nolab/set/lev=(3,15,3)(Inf) (dv2[l=@ave])^0.5 |
---|
211 | list "PRd1-30",(dv2[i=@ave,j=@ave,l=@ave])^0.5 |
---|
212 | ! ppl axlsze,0.14,0.14 |
---|
213 | ppl fill |
---|
214 | label/nouser 3.,6.7,0,0,0.24 "$nom" |
---|
215 | label/nouser 3.,6.2,0,0,0.24 "Std deviation, pr(1d)-pr(30d)" |
---|
216 | go land |
---|
217 | frame/file=hf.gif |
---|
218 | let dv=var[l=@sbx:20]-var[l=@sbx:120] |
---|
219 | fill/pal=rain_cmyk/nolab/set/lev=(1,5,1)(Inf) (dv2[l=@ave])^0.5 |
---|
220 | list "PRd20-120",(dv2[i=@ave,j=@ave,l=@ave])^0.5 |
---|
221 | list/x=50:180/y=-20:20 "PRd20-120MJO",(dv2oce[i=@ave,j=@ave,l=@ave])^0.5 |
---|
222 | ppl fill |
---|
223 | go land |
---|
224 | label/nouser 3.,6.7,0,0,0.24 "$nom" |
---|
225 | label/nouser 3,6.2,0,0,0.24 "Std deviation, pr(20d)-pr(120d)" |
---|
226 | frame/file=is.gif |
---|
227 | let pr1= if ( $var gt 1 ) then 1 else 0 |
---|
228 | fill/pal=rain_cmyk/nolab/set/lev=(0.1,1,0.15) pr1[l=@ave] |
---|
229 | list "PRnd1",pr1[i=@ave,j=@ave,l=@ave] |
---|
230 | ppl fill |
---|
231 | label/nouser 3.,6.7,0,0,0.24 "$nom" |
---|
232 | label/nouser 3.,6.2,0,0,0.24 "time frac. wth daily pr. above 1mm/day" |
---|
233 | go land |
---|
234 | frame/file=nd.gif |
---|
235 | plot/line=7/vlim=0:9/title="$nom, PR (mm/day)" ${var}[i=@ave,l=@ave] |
---|
236 | let pr10= if ( $var gt 10 ) then $var else 0 |
---|
237 | let pr20= if ( $var gt 20 ) then $var else 0 |
---|
238 | let pr50= if ( $var gt 50 ) then $var else 0 |
---|
239 | let pr100= if ( $var gt 100 ) then $var else 0 |
---|
240 | let pr200= if ( $var gt 200 ) then $var else 0 |
---|
241 | plot/o/line=8/title="PR>10mm/d" pr10[i=@ave,l=@ave] |
---|
242 | plot/o/line=9/title="PR>20mm/d" pr20[i=@ave,l=@ave] |
---|
243 | plot/o/line=10/title="PR>50mm/d" pr50[i=@ave,l=@ave] |
---|
244 | plot/o/line=11/title="PR>100mm/d" pr100[i=@ave,l=@ave] |
---|
245 | plot/o/line=12/title="PR>200mm/d" pr200[i=@ave,l=@ave] |
---|
246 | frame/file=zon.gif |
---|
247 | let dpr10=$var-pr10 |
---|
248 | let dpr20=pr10-pr20 |
---|
249 | let dpr50=pr20-pr50 |
---|
250 | ! list "PRTOT",${var}[i=@ave,j=@ave,l=@ave] |
---|
251 | list "PR0-10",dpr10[i=@ave,j=@ave,l=@ave] |
---|
252 | list "PR10-20",dpr20[i=@ave,j=@ave,l=@ave] |
---|
253 | list "PR20-50",dpr50[i=@ave,j=@ave,l=@ave] |
---|
254 | list "PR50",pr50[i=@ave,j=@ave,l=@ave] |
---|
255 | quit |
---|
256 | eod |
---|
257 | ferret -gif -nojnl -script tmp.jnl | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/$sim |
---|
258 | |
---|
259 | for type in hf is nd zon ; do |
---|
260 | convert $type.gif $outputdir/PNG/${sim}_$type.png |
---|
261 | listey="$listey ${sim}_$type" |
---|
262 | done |
---|
263 | done |
---|
264 | |
---|
265 | echo $ts_da |
---|
266 | if [ -f $COMP_D/entete.html ] ; then cat $COMP_D/entete.html > $outputdir/index.html ; fi |
---|
267 | |
---|
268 | #~/LMDZ/MultiSimu/concat_html.sh $COMP_D/AXE2/PR_DAY/PNG "OK" "$listey" 4 >> $outputdir/index.html |
---|
269 | ~/Multi_atlas/concat_html.sh $COMP_D/AXE2/PR_DAY/PNG "OK" "$listey" 4 >> $outputdir/index.html |
---|
270 | |
---|
271 | fi # pr_da=1 |
---|
272 | |
---|
273 | |
---|
274 | ####################################################################### |
---|
275 | # Bar chart bilan |
---|
276 | ####################################################################### |
---|
277 | |
---|
278 | cd $COMP_D/AXE2 |
---|
279 | liste_simy="" |
---|
280 | DEF_FILE=$COMP_D/def.txt |
---|
281 | for s in `awk ' {print $1"_"$2 } ' $DEF_FILE` ; do liste_simy="$liste_simy $s" ; done |
---|
282 | echo $liste_simy |
---|
283 | |
---|
284 | |
---|
285 | ref=1 |
---|
286 | mkdir -p XMGR |
---|
287 | for sim in $liste_simy ; do |
---|
288 | if [ $ref = 1 ] ; then |
---|
289 | clims="lmdz gpcp trmm" |
---|
290 | else |
---|
291 | clims=lmdz |
---|
292 | fi |
---|
293 | ref=0 |
---|
294 | for clim in $clims ; do \rm -f $clim ; for type in TOT OCE CONT MIXT AMMA ; do grep $type PR_YR/TXT/$sim | grep $clim | awk ' { print $2 } ' >> $clim ; done ; done |
---|
295 | for clim in $clims ; do for type in TOT OCE CONT MIXT AMMA ; do grep $type PR_YR/TXT/$sim | grep $clim | awk ' { print $2 } ' ; done ; done |
---|
296 | \mv -f lmdz XMGR/$sim |
---|
297 | awk ' { print $2 } ' PR_DAY/TXT/$sim >> XMGR/$sim |
---|
298 | done |
---|
299 | |
---|
300 | mv trmm XMGR/TRMM |
---|
301 | mv gpcp XMGR/GPCP |
---|
302 | awk ' { print $2 } ' PR_DAY/TXT/TRMM >> XMGR/TRMM |
---|
303 | awk ' { print $2 * 0 } ' PR_DAY/TXT/TRMM >> XMGR/GPCP |
---|
304 | cd XMGR |
---|
305 | |
---|
306 | |
---|
307 | |
---|
308 | nsims=`echo $liste_simy | wc -w | awk ' { print $1 + 2 } '` |
---|
309 | size=`echo $nsims | awk ' { print 3.5 / $1 } '` |
---|
310 | |
---|
311 | cat <<eod>| precip.param |
---|
312 | g0 type Chart |
---|
313 | world -0.5, 0, 12.5, 8 |
---|
314 | |
---|
315 | |
---|
316 | yaxis label "PR (mm/day) " |
---|
317 | yaxis tick major 1 |
---|
318 | |
---|
319 | |
---|
320 | xaxis ticklabel font 0 |
---|
321 | xaxis ticklabel color 1 |
---|
322 | xaxis tick place both |
---|
323 | xaxis tick spec type both |
---|
324 | xaxis tick spec 13 |
---|
325 | xaxis tick major 0, 0 |
---|
326 | xaxis ticklabel 0, "TOT" |
---|
327 | xaxis tick major 1, 1 |
---|
328 | xaxis ticklabel 1, "OCE" |
---|
329 | xaxis tick major 2, 2 |
---|
330 | xaxis ticklabel 2, "CONT" |
---|
331 | xaxis tick major 3, 3 |
---|
332 | xaxis ticklabel 3, "MIXT" |
---|
333 | xaxis tick major 4, 4 |
---|
334 | xaxis ticklabel 4, "AMMA" |
---|
335 | xaxis tick major 5, 5 |
---|
336 | xaxis ticklabel 5, "SIG1-30" |
---|
337 | xaxis tick major 6, 6 |
---|
338 | xaxis ticklabel 6, "SIG20-120" |
---|
339 | xaxis tick major 7, 7 |
---|
340 | xaxis ticklabel 7, "MJO" |
---|
341 | xaxis tick major 8, 8 |
---|
342 | xaxis ticklabel 8, "FD(PR>1)" |
---|
343 | xaxis tick major 9, 9 |
---|
344 | xaxis ticklabel 9, "<10" |
---|
345 | xaxis tick major 10, 10 |
---|
346 | xaxis ticklabel 10, "10-20" |
---|
347 | xaxis tick major 11, 11 |
---|
348 | xaxis ticklabel 11, "20-50" |
---|
349 | xaxis tick major 12, 12 |
---|
350 | xaxis ticklabel 12, ">50" |
---|
351 | xaxis tick major 13, 13 |
---|
352 | xaxis ticklabel char size 1.3 |
---|
353 | xaxis ticklabel angle 90 |
---|
354 | |
---|
355 | legend 0.8, 0.85 |
---|
356 | eod |
---|
357 | |
---|
358 | color=( 1 1 1 2 3 4 5 6 8 9 10 11 12 13 14 15 ) |
---|
359 | pattern=( 10 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ) |
---|
360 | |
---|
361 | is=0 |
---|
362 | while [ $is != $nsims ] ; do |
---|
363 | cat <<eod>> precip.param |
---|
364 | s$is type bar |
---|
365 | s$is symbol fill pattern ${pattern[$is]} |
---|
366 | s$is symbol color ${color[$is]} |
---|
367 | s$is symbol fill color ${color[$is]} |
---|
368 | s$is symbol size $size |
---|
369 | s$is line linestyle 0 |
---|
370 | eod |
---|
371 | is=$(( $is + 1 )) |
---|
372 | done |
---|
373 | |
---|
374 | # xmgrace TRMM GPCP $liste_simy TOTO -param precip.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
375 | xmgrace TRMM GPCP $liste_simy -param precip.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
376 | epstopdf tmp.eps |
---|
377 | convert -density 144 tmp.pdf tmp.png |
---|