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