source: BOL/Multi_atlas/make_axe2.sh @ 5224

Last change on this file since 5224 was 4697, checked in by musat, 14 months ago

Enlevement tests "Mise en attente" de scripts cmor et season
pour permettre de faire tourner plusieurs multi-atlas simultanément
Ajout variable rsdt dans les moyennes zonales
Nettoyage env_Multi_atlas
Adaptation a spirit des diagnostics de l'axe2 de MB
Correction html axe4
IonelaMusat?

  • Property svn:executable set to *
File size: 12.1 KB
Line 
1#!/bin/bash -vx
2# Par exemple:
3# ./make_axe2.sh V6.5AIS8
4# -----------------------------------------------------------------
5
6local=`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
17source ${local}/env_Multi_atlas_axe2.sh
18set -vx
19pr_yr=1
20pr_da=1
21
22# -----------------------------------------------------------------
23# Based on /home/fabric/LMDZ/UTILS/config.sh
24# -----------------------------------------------------------------
25
26runstxt=~/${local}/runs.txt
27
28while 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
35done
36
37
38WRK=$MULTIDIR/AXE2/WORK$$
39if [ -d $WRK ] ; then WRK=$WRK$$ ; fi
40mkdir -p $WRK ; cd $WRK
41
42COMP_D=$MULTIDIR/$comp
43if [ ! -d $COMP_D ] ; then echo "$COMP_D not found" && exit ; fi
44
45# -----------------------------------------------------------------
46# Liste des simulations de la comparasion $comp
47# -----------------------------------------------------------------
48liste_simy=""
49DEF_FILE=$COMP_D/def.txt
50for s in `awk ' {print $1} ' $DEF_FILE` ; do liste_sim="$liste_sim $s" ; done
51for s in `awk ' {print $1"_"$2} ' $DEF_FILE` ; do liste_simy="$liste_simy $s" ; done
52
53echo liste_sim: $liste_sim
54echo liste_simy: $liste_simy
55# -----------------------------------------------------------------
56# -----------------------------------------------------------------
57# Analyse de la distribution longitudinale des precipitation
58# sur ocean et continent
59# -----------------------------------------------------------------
60# -----------------------------------------------------------------
61
62echo OK0
63
64outputdir=$COMP_D/AXE2/PR_YR
65if [ -d $outputdir/PNG ] ; then pr_yr=0 ; fi
66if [ $pr_yr = 1 -o 0 = 0 ] ; then
67
68echo OK1
69
70outputdir=$COMP_D/AXE2/PR_YR
71for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done
72
73echo OK2 $liste_sim
74
75listey=""
76for 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
89cat <<eod>| tmpyr.jnl
90use "$simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc"
91use gpcp.nc
92use trmm.nc
93let con=pourc_ter[d=1,l=1:12@ave]+pourc_lic[d=1,l=1:12@ave]
94let oce=pourc_oce[d=1,l=1:12@ave]+pourc_sic[d=1,l=1:12@ave]
95let ocem=if ( oce[l=1] ge 99. ) then 1
96let conm=if ( con[l=1] ge 99. ) then 1
97let mixm=if ( oce[l=1] gt 1. AND con[l=1] gt 1. )  then 1
98let totm=tsol[d=1,l=1]*0.+1.
99
100let filtre=var
101go tmp0.jnl TOT,8,totm
102frame/file=tot.gif
103let filtre=if ( oce[l=1] ge 99.9 ) then var*oce/100.
104go tmp0.jnl OCE,9,ocem
105frame/file=oce.gif
106let filtre=if ( con[l=1] ge 99.9 ) then var*con/100.
107go tmp0.jnl CONT,10,conm
108frame/file=con.gif
109let filtre=if ( con[l=1] gt 0.1 AND oce[l=1] gt 0.1 ) then var
110go tmp0.jnl MIXT,11,mixm
111frame/file=mix.gif
112list/x=-10:10/y=12:18 "PRlmdzAMMA",86400*precip[d=1,i=@ave,j=@ave,l=1:12@ave]
113list/x=-10:10/y=12:18 "PRtrmmAMMA",r[d=3,i=@ave,j=@ave,l=1:12@ave]
114list/x=-10:10/y=12:18 "PRgpcpAMMA",86400*pr[d=2,i=@ave,j=@ave,l=1:12@ave]
115eod
116
117cat <<eod>| tmp0.jnl
118let mask=\$3
119let var=86400*precip[d=1]*mask[i=@ave,j=@ave]
120plot/line=\$2/vlim=0:10/title="$sim $years pr \$1 (mm/d)" filtre[i=@ave,l=1:12@ave]
121list/y=-50:50 "PRlmdz\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
122let var=r[d=3]*mask
123plot/line=1/o/title="TRMM" filtre[i=@ave,l=1]
124list/y=-50:50 "PRtrmm\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
125let var=86400*pr[d=2]*mask
126plot/line=7/o/title="GPCP" filtre[i=@ave,l=1:12@ave]
127list/y=-50:50 "PRgpcp\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
128quit
129eod
130
131\rm gotmpyr.jnl
132cat<<eof>gotmpyr.jnl
133go tmpyr.jnl
134quit
135eof
136echo ferret<gotmpyr.jnl   | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/${sim}_${years}
137ferret<gotmpyr.jnl | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/${sim}_${years}
138for type in con mix tot oce ; do
139convert -density 144 $type.gif $outputdir/PNG/${sim}_${years}_$type.png
140listey="$listey ${sim}_${years}_$type"
141done
142
143done
144
145if [ -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
149fi # pr_yr=1
150
151# -----------------------------------------------------------------
152# -----------------------------------------------------------------
153# Analyse de la variabilité jour à jour des pluies
154# -----------------------------------------------------------------
155# -----------------------------------------------------------------
156outputdir=$COMP_D/AXE2/PR_DAY
157# if [ -d $outputdir ] ; then pr_da = 0 ; fi
158
159if [ $pr_da = 1 ] ; then
160
161listey=""
162
163outputdir=$COMP_D/AXE2/PR_DAY
164for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done
165
166# PLOT SIMULATION RESULTS
167first=1
168for 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
197done
198
199
200
201for sim in $ts_da ; do
202echo Tracer de $sim
203if [ $sim = TRMM ] ; then
204    var=r
205else
206    var='86400*precip'
207fi
208
209nom=`echo $sim | sed -e 's/_/ /g'`
210cat <<eod>| tmp.jnl
211use "$WRK/pourc_oce.nc"
212use "$outputdir/NC/$sim.nc"
213DEFINE VIEWPORT/XLIM=0.,1./YLIM= .5,1. V1
214DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.2,0.7 V2
215DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.,0.35 V3
216set memory/size=1000
217let var=$var
218let dv=var-var[l=@sbx:30]
219let dv2=dv*dv
220let dv2oce=if ( pourc_oce[d=1,l=1] ge 99. ) then dv2
221reg/y=-50:50
222fill/pal=rain_cmyk/nolab/set/lev=(3,15,3)(Inf) (dv2[l=@ave])^0.5
223list "PRd1-30",(dv2[i=@ave,j=@ave,l=@ave])^0.5
224! ppl axlsze,0.14,0.14
225ppl fill
226label/nouser 3.,6.7,0,0,0.24 "$nom"
227label/nouser 3.,6.2,0,0,0.24 "Std deviation, pr(1d)-pr(30d)"
228go land
229frame/file=hf.gif
230let dv=var[l=@sbx:20]-var[l=@sbx:120]
231fill/pal=rain_cmyk/nolab/set/lev=(1,5,1)(Inf) (dv2[l=@ave])^0.5
232list "PRd20-120",(dv2[i=@ave,j=@ave,l=@ave])^0.5
233list/x=50:180/y=-20:20 "PRd20-120MJO",(dv2oce[i=@ave,j=@ave,l=@ave])^0.5
234ppl fill
235go land
236label/nouser 3.,6.7,0,0,0.24 "$nom"
237label/nouser 3,6.2,0,0,0.24 "Std deviation, pr(20d)-pr(120d)"
238frame/file=is.gif
239let pr1= if ( $var gt 1 ) then 1 else 0
240fill/pal=rain_cmyk/nolab/set/lev=(0.1,1,0.15) pr1[l=@ave]
241list "PRnd1",pr1[i=@ave,j=@ave,l=@ave]
242ppl fill
243label/nouser 3.,6.7,0,0,0.24 "$nom"
244label/nouser 3.,6.2,0,0,0.24 "time frac. wth daily pr. above 1mm/day"
245go land
246frame/file=nd.gif
247plot/line=7/vlim=0:9/title="$nom, PR (mm/day)" ${var}[i=@ave,l=@ave]
248let pr10= if ( $var gt 10 ) then $var else 0
249let pr20= if ( $var gt 20 ) then $var else 0
250let pr50= if ( $var gt 50 ) then $var else 0
251let pr100= if ( $var gt 100 ) then $var else 0
252let pr200= if ( $var gt 200 ) then $var else 0
253plot/o/line=8/title="PR>10mm/d" pr10[i=@ave,l=@ave]
254plot/o/line=9/title="PR>20mm/d" pr20[i=@ave,l=@ave]
255plot/o/line=10/title="PR>50mm/d" pr50[i=@ave,l=@ave]
256plot/o/line=11/title="PR>100mm/d" pr100[i=@ave,l=@ave]
257plot/o/line=12/title="PR>200mm/d" pr200[i=@ave,l=@ave]
258frame/file=zon.gif
259let dpr10=$var-pr10
260let dpr20=pr10-pr20
261let dpr50=pr20-pr50
262! list "PRTOT",${var}[i=@ave,j=@ave,l=@ave]
263list "PR0-10",dpr10[i=@ave,j=@ave,l=@ave]
264list "PR10-20",dpr20[i=@ave,j=@ave,l=@ave]
265list "PR20-50",dpr50[i=@ave,j=@ave,l=@ave]
266list "PR50",pr50[i=@ave,j=@ave,l=@ave]
267quit
268eod
269
270\rm gotmp.jnl
271cat<<eof>gotmp.jnl
272go tmp.jnl
273quit
274eof
275ferret<gotmp.jnl  | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/$sim
276
277for type in hf is nd zon ; do
278convert $type.gif $outputdir/PNG/${sim}_$type.png
279listey="$listey ${sim}_$type"
280done
281done
282
283echo $ts_da
284if [ -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
288fi # pr_da=1
289
290
291#######################################################################
292# Bar chart bilan
293#######################################################################
294
295cd $COMP_D/AXE2
296liste_simy=""
297DEF_FILE=$COMP_D/def.txt
298for s in `awk ' {print $1"_"$2 } ' $DEF_FILE` ; do liste_simy="$liste_simy $s" ; done
299echo $liste_simy
300
301
302ref=1
303mkdir -p XMGR
304for 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
315done
316
317mv trmm XMGR/TRMM
318mv gpcp XMGR/GPCP
319awk ' { print $2     } ' PR_DAY/TXT/TRMM >> XMGR/TRMM
320awk ' { print $2 * 0 } ' PR_DAY/TXT/TRMM >> XMGR/GPCP
321cd XMGR
322
323
324
325nsims=`echo $liste_simy | wc -w | awk ' { print  $1 + 2  } '`
326size=`echo $nsims | awk ' { print 3.5 / $1 } '`
327
328cat <<eod>| precip.param
329g0 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
373eod
374
375color=( 1 1 1 2 3 4 5 6 8 9 10 11 12 13 14 15 )
376pattern=( 10 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 )
377
378is=0
379while [ $is != $nsims ] ; do
380cat <<eod>> precip.param
381s$is type bar
382s$is symbol fill pattern ${pattern[$is]}
383s$is symbol color ${color[$is]}
384s$is symbol fill color ${color[$is]}
385s$is symbol size $size
386s$is line linestyle 0
387eod
388is=$(( $is + 1 ))
389done
390
391xmgrace TRMM GPCP $liste_simy -param precip.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps
392epstopdf tmp.eps
393convert -density 144 tmp.pdf tmp.png
Note: See TracBrowser for help on using the repository browser.