source: BOL/Multi_atlas/make_axe2.sh @ 4531

Last change on this file since 4531 was 4505, checked in by musat, 15 months ago

Mise a jour script axe2 sur spirit2
Ionela

  • Property svn:executable set to *
File size: 12.1 KB
Line 
1#!/bin/bash
2# Par exemple:
3# ./make_axe2.sh V6.5AIS8
4# -----------------------------------------------------------------
5
6set -vx
7pr_yr=1
8pr_da=1
9
10# -----------------------------------------------------------------
11# Based on /home/fabric/LMDZ/UTILS/config.sh
12# -----------------------------------------------------------------
13
14#runstxt=/home/fabric/LMDZ/MultiSimu/runs.txt
15runstxt=~/Multi_atlas/runs.txt
16
17while 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
24done
25
26
27season=YEAR
28GR=VLR
29MAIN_SE=/thredds/ipsl/fabric/lmdz/SE
30EXPNAME=NPV5LRL79
31STOREDIR=/thredds/ipsl/fabric/lmdz/STORE/$EXPNAME
32MULTIDIR=/thredds/ipsl/fabric/lmdz/MultiSimu
33
34WRK=$MULTIDIR/AXE2/WORK$$
35if [ -d $WRK ] ; then WRK=$WRK$$ ; fi
36mkdir -p $WRK ; cd $WRK
37
38COMP_D=$MULTIDIR/$comp
39if [ ! -d $COMP_D ] ; then echo "$COMP_D not found" && exit ; fi
40
41# -----------------------------------------------------------------
42# Liste des simulations de la comparasion $comp
43# -----------------------------------------------------------------
44liste_simy=""
45DEF_FILE=$COMP_D/def.txt
46for s in `awk ' {print $1} ' $DEF_FILE` ; do liste_sim="$liste_sim $s" ; done
47for 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
56echo OK0
57
58outputdir=$COMP_D/AXE2/PR_YR
59if [ -d $outputdir/PNG ] ; then pr_yr=0 ; fi
60if [ $pr_yr = 1 -o 0 = 0 ] ; then
61
62echo OK1
63
64outputdir=$COMP_D/AXE2/PR_YR
65for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done
66
67echo OK2 $liste_sim
68
69listey=""
70for 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
83cat <<eod>| tmpyr.jnl
84use "$simdir/ATM/Analyse/SE/${sim}_SE_${years}_1M_histmth.nc"
85use gpcp.nc
86use trmm.nc
87let con=pourc_ter[d=1,l=1:12@ave]+pourc_lic[d=1,l=1:12@ave]
88let oce=pourc_oce[d=1,l=1:12@ave]+pourc_sic[d=1,l=1:12@ave]
89let ocem=if ( oce[l=1] ge 99. ) then 1
90let conm=if ( con[l=1] ge 99. ) then 1
91let mixm=if ( oce[l=1] gt 1. AND con[l=1] gt 1. )  then 1
92let totm=tsol[d=1,l=1]*0.+1.
93
94let filtre=var
95go tmp0.jnl TOT,8,totm
96frame/file=tot.gif
97let filtre=if ( oce[l=1] ge 99.9 ) then var*oce/100.
98go tmp0.jnl OCE,9,ocem
99frame/file=oce.gif
100let filtre=if ( con[l=1] ge 99.9 ) then var*con/100.
101go tmp0.jnl CONT,10,conm
102frame/file=con.gif
103let filtre=if ( con[l=1] gt 0.1 AND oce[l=1] gt 0.1 ) then var
104go tmp0.jnl MIXT,11,mixm
105frame/file=mix.gif
106list/x=-10:10/y=12:18 "PRlmdzAMMA",86400*precip[d=1,i=@ave,j=@ave,l=1:12@ave]
107list/x=-10:10/y=12:18 "PRtrmmAMMA",r[d=3,i=@ave,j=@ave,l=1:12@ave]
108list/x=-10:10/y=12:18 "PRgpcpAMMA",86400*pr[d=2,i=@ave,j=@ave,l=1:12@ave]
109eod
110
111cat <<eod>| tmp0.jnl
112let mask=\$3
113let var=86400*precip[d=1]*mask[i=@ave,j=@ave]
114plot/line=\$2/vlim=0:10/title="$sim $years pr \$1 (mm/d)" filtre[i=@ave,l=1:12@ave]
115list/y=-50:50 "PRlmdz\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
116let var=r[d=3]*mask
117plot/line=1/o/title="TRMM" filtre[i=@ave,l=1]
118list/y=-50:50 "PRtrmm\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
119let var=86400*pr[d=2]*mask
120plot/line=7/o/title="GPCP" filtre[i=@ave,l=1:12@ave]
121list/y=-50:50 "PRgpcp\$1",filtre[i=@ave,j=@ave,l=1:12@ave]
122quit
123eod
124
125#pwd ; exit
126
127ferret -gif -nojnl -script tmpyr.jnl   | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/${sim}_${years}
128for type in con mix tot oce ; do
129convert -density 144 $type.gif $outputdir/PNG/${sim}_${years}_$type.png
130listey="$listey ${sim}_${years}_$type"
131done
132
133done
134
135if [ -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
140fi # pr_yr=1
141
142# -----------------------------------------------------------------
143# -----------------------------------------------------------------
144# Analyse de la variabilité jour à jour des pluies
145# -----------------------------------------------------------------
146# -----------------------------------------------------------------
147outputdir=$COMP_D/AXE2/PR_DAY
148# if [ -d $outputdir ] ; then pr_da = 0 ; fi
149
150if [ $pr_da = 1 ] ; then
151
152listey=""
153
154outputdir=$COMP_D/AXE2/PR_DAY
155for sub in [ PNG NC TXT ] ; do mkdir -p $outputdir/$sub ; done
156
157# PLOT SIMULATION RESULTS
158first=1
159for 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
185done
186
187
188
189for sim in $ts_da ; do
190echo Tracer de $sim
191if [ $sim = TRMM ] ; then
192    var=r
193else
194    var='86400*precip'
195fi
196
197nom=`echo $sim | sed -e 's/_/ /g'`
198cat <<eod>| tmp.jnl
199use "$WRK/pourc_oce.nc"
200use "$outputdir/NC/$sim.nc"
201DEFINE VIEWPORT/XLIM=0.,1./YLIM= .5,1. V1
202DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.2,0.7 V2
203DEFINE VIEWPORT/XLIM=0.,1./YLIM= 0.,0.35 V3
204set memory/size=1000
205let var=$var
206let dv=var-var[l=@sbx:30]
207let dv2=dv*dv
208let dv2oce=if ( pourc_oce[d=1,l=1] ge 99. ) then dv2
209reg/y=-50:50
210fill/pal=rain_cmyk/nolab/set/lev=(3,15,3)(Inf) (dv2[l=@ave])^0.5
211list "PRd1-30",(dv2[i=@ave,j=@ave,l=@ave])^0.5
212! ppl axlsze,0.14,0.14
213ppl fill
214label/nouser 3.,6.7,0,0,0.24 "$nom"
215label/nouser 3.,6.2,0,0,0.24 "Std deviation, pr(1d)-pr(30d)"
216go land
217frame/file=hf.gif
218let dv=var[l=@sbx:20]-var[l=@sbx:120]
219fill/pal=rain_cmyk/nolab/set/lev=(1,5,1)(Inf) (dv2[l=@ave])^0.5
220list "PRd20-120",(dv2[i=@ave,j=@ave,l=@ave])^0.5
221list/x=50:180/y=-20:20 "PRd20-120MJO",(dv2oce[i=@ave,j=@ave,l=@ave])^0.5
222ppl fill
223go land
224label/nouser 3.,6.7,0,0,0.24 "$nom"
225label/nouser 3,6.2,0,0,0.24 "Std deviation, pr(20d)-pr(120d)"
226frame/file=is.gif
227let pr1= if ( $var gt 1 ) then 1 else 0
228fill/pal=rain_cmyk/nolab/set/lev=(0.1,1,0.15) pr1[l=@ave]
229list "PRnd1",pr1[i=@ave,j=@ave,l=@ave]
230ppl fill
231label/nouser 3.,6.7,0,0,0.24 "$nom"
232label/nouser 3.,6.2,0,0,0.24 "time frac. wth daily pr. above 1mm/day"
233go land
234frame/file=nd.gif
235plot/line=7/vlim=0:9/title="$nom, PR (mm/day)" ${var}[i=@ave,l=@ave]
236let pr10= if ( $var gt 10 ) then $var else 0
237let pr20= if ( $var gt 20 ) then $var else 0
238let pr50= if ( $var gt 50 ) then $var else 0
239let pr100= if ( $var gt 100 ) then $var else 0
240let pr200= if ( $var gt 200 ) then $var else 0
241plot/o/line=8/title="PR>10mm/d" pr10[i=@ave,l=@ave]
242plot/o/line=9/title="PR>20mm/d" pr20[i=@ave,l=@ave]
243plot/o/line=10/title="PR>50mm/d" pr50[i=@ave,l=@ave]
244plot/o/line=11/title="PR>100mm/d" pr100[i=@ave,l=@ave]
245plot/o/line=12/title="PR>200mm/d" pr200[i=@ave,l=@ave]
246frame/file=zon.gif
247let dpr10=$var-pr10
248let dpr20=pr10-pr20
249let dpr50=pr20-pr50
250! list "PRTOT",${var}[i=@ave,j=@ave,l=@ave]
251list "PR0-10",dpr10[i=@ave,j=@ave,l=@ave]
252list "PR10-20",dpr20[i=@ave,j=@ave,l=@ave]
253list "PR20-50",dpr50[i=@ave,j=@ave,l=@ave]
254list "PR50",pr50[i=@ave,j=@ave,l=@ave]
255quit
256eod
257ferret -gif -nojnl -script tmp.jnl  | grep "^I.*.PR" | awk ' { print $4 , $5 } ' > $outputdir/TXT/$sim
258
259for type in hf is nd zon ; do
260convert $type.gif $outputdir/PNG/${sim}_$type.png
261listey="$listey ${sim}_$type"
262done
263done
264
265echo $ts_da
266if [ -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
271fi # pr_da=1
272
273
274#######################################################################
275# Bar chart bilan
276#######################################################################
277
278cd $COMP_D/AXE2
279liste_simy=""
280DEF_FILE=$COMP_D/def.txt
281for s in `awk ' {print $1"_"$2 } ' $DEF_FILE` ; do liste_simy="$liste_simy $s" ; done
282echo $liste_simy
283
284
285ref=1
286mkdir -p XMGR
287for 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
298done
299
300mv trmm XMGR/TRMM
301mv gpcp XMGR/GPCP
302awk ' { print $2     } ' PR_DAY/TXT/TRMM >> XMGR/TRMM
303awk ' { print $2 * 0 } ' PR_DAY/TXT/TRMM >> XMGR/GPCP
304cd XMGR
305
306
307
308nsims=`echo $liste_simy | wc -w | awk ' { print  $1 + 2  } '`
309size=`echo $nsims | awk ' { print 3.5 / $1 } '`
310
311cat <<eod>| precip.param
312g0 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
356eod
357
358color=( 1 1 1 2 3 4 5 6 8 9 10 11 12 13 14 15 )
359pattern=( 10 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 )
360
361is=0
362while [ $is != $nsims ] ; do
363cat <<eod>> precip.param
364s$is type bar
365s$is symbol fill pattern ${pattern[$is]}
366s$is symbol color ${color[$is]}
367s$is symbol fill color ${color[$is]}
368s$is symbol size $size
369s$is line linestyle 0
370eod
371is=$(( $is + 1 ))
372done
373
374# xmgrace TRMM GPCP $liste_simy TOTO -param precip.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps
375xmgrace TRMM GPCP $liste_simy -param precip.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps
376epstopdf tmp.eps
377convert -density 144 tmp.pdf tmp.png
Note: See TracBrowser for help on using the repository browser.