[3684] | 1 | #!/bin/bash |
---|
| 2 | |
---|
[4340] | 3 | source ~/env_Multi_atlas.sh |
---|
[3684] | 4 | |
---|
[4330] | 5 | #set -vx |
---|
[3684] | 6 | force_create=1 |
---|
| 7 | |
---|
| 8 | comp=$1 |
---|
[4330] | 9 | local=`pwd -P` |
---|
[3684] | 10 | |
---|
| 11 | for season in YEAR DJF JJA ; do |
---|
| 12 | |
---|
| 13 | cd $local |
---|
| 14 | |
---|
| 15 | if [ "$season" = "YEAR" ] ; then |
---|
| 16 | masks="ter oce NAtl Arct circA otrop glob eto weak conv subs NH SH PANET OCEMAR CONMAR" |
---|
| 17 | mask_figs="NAtl Arct circA glob ter oce otrop interH etoa etow etows circAa NAtla conv weak subs PANET OCEMAR CONMAR" |
---|
| 18 | else |
---|
| 19 | masks="NAtl Arct circA Sibe USA PANET OCEMAR CONMAR" |
---|
| 20 | mask_figs="NAtl Arct circA Sibe USA PANET OCEMAR CONMAR" |
---|
| 21 | fi |
---|
| 22 | |
---|
| 23 | WRK_D=$local/XMGR$$/$season |
---|
| 24 | if [ -d $WRK_D ] ; then WRK_D=$WRK_D$$ ; fi |
---|
| 25 | mkdir -p $WRK_D |
---|
| 26 | cd $WRK_D |
---|
| 27 | ln -s ../../mas*nc . |
---|
| 28 | |
---|
| 29 | comp=`basename $1` |
---|
| 30 | if [ -d $DODSDIR/$login/lmdz/MultiSimu ] ; then |
---|
| 31 | # Installation multi modele fabric |
---|
| 32 | COMP_D=$DODSDIR/$login/lmdz/MultiSimu/$comp |
---|
| 33 | CMOR_DIR=$DODSDIR/$login/lmdz/VLR/$season |
---|
[4330] | 34 | echo COMP_D $COMP_D CMOR_DIR $CMOR_DIR |
---|
[3684] | 35 | elif [ "$comp" = "$1" ] ; then |
---|
| 36 | # Installation locale |
---|
| 37 | COMP_D=. |
---|
| 38 | CMOR_DIR=. |
---|
| 39 | else |
---|
| 40 | # Path absolu |
---|
| 41 | COMP_D=$1 |
---|
| 42 | CMOR_DIR=. |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | ############################################### |
---|
| 46 | # Liste des simulations de la comparasion $comp |
---|
| 47 | listsims="" ; listsimsy="" |
---|
[4330] | 48 | |
---|
[3684] | 49 | DEF_FILE=$COMP_D/def.txt ; if [ ! -f "$DEF_FILE" ] ; then renseigner $DEF_FILE ; exit ; fi |
---|
| 50 | for s in `awk ' {print $1"_"$2 } ' $DEF_FILE` ; do listsimsy="$listsimsy $s" ; done |
---|
| 51 | for s in `awk ' {print $1 } ' $DEF_FILE` ; do listsims="$listsims $s" ; done |
---|
| 52 | ############################################### |
---|
| 53 | |
---|
| 54 | echo $listsimsy |
---|
| 55 | ici=`pwd` |
---|
| 56 | |
---|
| 57 | for simy in OBS $listsimsy ; do |
---|
| 58 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
| 59 | years=`echo $simy | sed -e s/${sim}//` |
---|
| 60 | echo SIM $sim |
---|
| 61 | echo years $years |
---|
| 62 | |
---|
| 63 | SIM_DIR=$CMOR_DIR/$GR/$sim$years |
---|
[4330] | 64 | ETOA_DIR=$SIM_DIR/METRICS |
---|
[3684] | 65 | |
---|
| 66 | for mask in $masks ; do |
---|
| 67 | xmgr=$ETOA_DIR/$mask |
---|
| 68 | mkdir -p $ETOA_DIR |
---|
| 69 | if [ ! -f "$xmgr" -o "$force_create" = "1" ] ; then |
---|
| 70 | \rm -f $xmgr ; touch $xmgr |
---|
| 71 | if [ ! -d $SIM_DIR ] ; then echo $SIM_DIR absent ; exit ; fi |
---|
| 72 | set +e ; \rm resu$sim ; set -e |
---|
[4330] | 73 | for var in rsut clhcalipso cllcalipso clmcalipso cltcalipso clt hfls hfss hurs huss pr ts tas sst psl rldscs rlds rlus rlutcs rlut rsdscs rsds rsdt rsuscs rsus rsutcs prw ; do |
---|
[3684] | 74 | if [ -f "$SIM_DIR/NC/$var.nc" ] ; then |
---|
| 75 | if [ "$mask" = "glob" ] ; then |
---|
| 76 | val=`cdo output -fldmean -selvar,$var $SIM_DIR/NC/$var.nc` |
---|
| 77 | elif [ ! -f "mask$mask.nc" ] ; then |
---|
| 78 | echo Le fichier mask$mask.nc n existe pas ; exit |
---|
| 79 | else |
---|
| 80 | if [ 1 = 1 ] ; then |
---|
| 81 | if [ 1 = 0 ] && [ $var = "hfls" ] && [ $simy == "OBS" ]; then |
---|
| 82 | cdo remapcon,mask$mask.nc $SIM_DIR/NC/$var.nc_ocean-only tmp.nc |
---|
| 83 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask$mask.nc` |
---|
| 84 | else |
---|
| 85 | cdo remapcon,mask$mask.nc $SIM_DIR/NC/$var.nc tmp.nc |
---|
| 86 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask$mask.nc` |
---|
| 87 | fi |
---|
| 88 | else |
---|
| 89 | cdo remapcon,maskotrop.nc $SIM_DIR/NC/$var.nc tmp.nc |
---|
| 90 | cdo remapcon,maskotrop.nc mask$mask.nc mask.nc |
---|
| 91 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask.nc` |
---|
| 92 | fi |
---|
| 93 | fi |
---|
| 94 | echo $mask $sim $var $val |
---|
| 95 | echo $var $val >> $xmgr |
---|
| 96 | else |
---|
| 97 | echo $var 999999 >> $xmgr |
---|
| 98 | fi |
---|
| 99 | done |
---|
| 100 | rsut=`grep '^rsut ' $xmgr | awk ' { print $2 } '` |
---|
| 101 | rsutcs=`grep '^rsutcs ' $xmgr | awk ' { print $2 } '` |
---|
| 102 | rlut=`grep '^rlut ' $xmgr | awk ' { print $2 } '` |
---|
| 103 | rlutcs=`grep '^rlutcs ' $xmgr | awk ' { print $2 } '` |
---|
| 104 | hfls=`grep '^hfls ' $xmgr | awk ' { print $2 } '` |
---|
| 105 | hfss=`grep '^hfss ' $xmgr | awk ' { print $2 } '` |
---|
| 106 | rlds=`grep '^rlds ' $xmgr | awk ' { print $2 } '` |
---|
| 107 | rldscs=`grep '^rldscs ' $xmgr | awk ' { print $2 } '` |
---|
| 108 | rsds=`grep '^rsds ' $xmgr | awk ' { print $2 } '` |
---|
| 109 | rsdscs=`grep '^rsdscs ' $xmgr | awk ' { print $2 } '` |
---|
| 110 | rlus=`grep '^rlus ' $xmgr | awk ' { print $2 } '` |
---|
| 111 | rsus=`grep '^rsus ' $xmgr | awk ' { print $2 } '` |
---|
| 112 | rsuscs=`grep '^rsuscs ' $xmgr | awk ' { print $2 } '` |
---|
| 113 | rsdt=`grep '^rsdt ' $xmgr | awk ' { print $2 } '` |
---|
[4330] | 114 | echo $hfls | awk ' { print "eva" , $1 * 0.03456 } ' >> $xmgr |
---|
[3684] | 115 | echo $rsut $rsutcs | awk ' { print "crest" , $2 - $1 } ' >> $xmgr |
---|
| 116 | echo $rlut $rlutcs | awk ' { print "crelt" , $2 - $1 } ' >> $xmgr |
---|
| 117 | echo $rsut $rsutcs $rlut $rlutcs | awk ' { print "cret" , $2 - $1 +$4 -$3 } ' >> $xmgr |
---|
| 118 | echo $rsdt $rsut | awk ' { print "rst" , $1 - $2 } ' >> $xmgr |
---|
| 119 | echo $rsdt $rsutcs | awk ' { print "rstcs" , $1 - $2 } ' >> $xmgr |
---|
| 120 | echo $rsdt $rsut $rlut | awk ' { print "rt" , $1 - $2 -$3 } ' >> $xmgr |
---|
| 121 | echo $hfls $hfss | awk ' { print "trbs" , $1 + $2 } ' >> $xmgr |
---|
| 122 | echo $rlds $rlus | awk ' { print "rls" , $1 - $2 } ' >> $xmgr |
---|
| 123 | echo $rsds $rsus | awk ' { print "rss" , $1 - $2 } ' >> $xmgr |
---|
| 124 | echo $rlds $rlus $rsds $rsus | awk ' { print "rs" , $1 - $2 +$3 - $4 } ' >> $xmgr |
---|
| 125 | echo $rlds $rldscs $rsds $rsdscs $rsus $rsuscs | awk ' { print "cres" , $1 - $2 + $3 - $4 - $5 + $6 } ' >> $xmgr |
---|
| 126 | echo $rlds $rldscs $rsds $rsdscs $rsus $rsuscs $hfls | awk ' { print "crehfls" , $1 - $2 + $3 - $4 - $5 + $6 - $7 } ' >> $xmgr |
---|
| 127 | echo $rlds $rlus $rsds $rsus $hfls $hfss | awk ' { print "bils" , $1 - $2 + $3 - $4 - $5 - $6 } ' >> $xmgr |
---|
| 128 | fi |
---|
| 129 | done |
---|
| 130 | |
---|
| 131 | # Masques combinés |
---|
| 132 | set +e |
---|
| 133 | paste $ETOA_DIR/otrop $ETOA_DIR/eto | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etoa |
---|
| 134 | paste $ETOA_DIR/weak $ETOA_DIR/subs | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etows |
---|
| 135 | paste $ETOA_DIR/weak $ETOA_DIR/eto | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etow |
---|
| 136 | paste $ETOA_DIR/otrop $ETOA_DIR/circA | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/circAa |
---|
| 137 | paste $ETOA_DIR/NAtl $ETOA_DIR/otrop | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/NAtla |
---|
| 138 | paste $ETOA_DIR/SH $ETOA_DIR/NH | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/interH |
---|
| 139 | set -e |
---|
| 140 | |
---|
| 141 | done |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | ######################################################################################### |
---|
| 145 | # Tracers |
---|
| 146 | ######################################################################################### |
---|
| 147 | |
---|
| 148 | cat <<eod>| descr |
---|
| 149 | clhcalipso 1 High Clouds |
---|
| 150 | cllcalipso 1 Low Clouds |
---|
| 151 | clmcalipso 1 Mid Clouds |
---|
| 152 | cltcalipso 1 Total Clouds |
---|
| 153 | clt 1 LMDZ Total Clouds |
---|
| 154 | hfls -1 -LE |
---|
[4306] | 155 | eva 1 Evaporation |
---|
[3684] | 156 | hfss -1 -H |
---|
| 157 | hurs 1 RHsrf |
---|
| 158 | huss 1 Surface specific humidity |
---|
| 159 | pr 10 PR*10 |
---|
| 160 | prw 1 PRW |
---|
| 161 | psl 1 SLP |
---|
| 162 | ts 10 Ts*10 |
---|
| 163 | sst 10 sst*10 |
---|
| 164 | tas 10 T2m*10 |
---|
| 165 | rlds 1 LWdn srf |
---|
| 166 | rldscs 1 LWdn srf Clr |
---|
| 167 | rlus -1 LWup Srf |
---|
| 168 | rlutcs -1 LW TOA Clr |
---|
| 169 | rlut -1 LW TOA |
---|
| 170 | rsdscs 1 SWdn srf Clr |
---|
| 171 | rsds 1 SWdn srf |
---|
| 172 | rsdt 1 SWdn TOA |
---|
| 173 | rsuscs -1 SWup srf Clr |
---|
| 174 | rsus -1 SWup srf |
---|
| 175 | rsutcs -1 SW TOA Clr |
---|
| 176 | rstcs -1 SW TOA Clr |
---|
| 177 | rsut -1 SW TOA |
---|
| 178 | crest 1 SW CRE TOA |
---|
| 179 | crelt 1 LW CRE TOA |
---|
| 180 | cres 1 CRE srf |
---|
| 181 | crehfls 1 CRE - LE |
---|
| 182 | cret 1 CRE TOA |
---|
| 183 | rst 1 SW TOA |
---|
| 184 | rt 1 SW+LW TOA |
---|
| 185 | trbs -1 -(LE+H) |
---|
| 186 | rls 1 LW srf |
---|
| 187 | rss 1 SW srf |
---|
| 188 | rs 1 SW+LW srf |
---|
| 189 | bils 1 Srf budget |
---|
| 190 | eod |
---|
| 191 | |
---|
| 192 | # ------------------- debut boucle sur les figures ---------------------------- |
---|
| 193 | for mask in $mask_figs ; do |
---|
| 194 | # ------------------- debut boucle sur les figures ---------------------------- |
---|
| 195 | |
---|
| 196 | case $mask in |
---|
| 197 | NAtla|circAa|etoa|etow|etows|oce|otrop) listevars="ts bils crehfls cres rs rss crest hfls tas cllcalipso clhcalipso " ;; |
---|
| 198 | interH|glob|ter|NAtl|circA|conv|weak|subs|PANET|CONMAR|OCEMAR) listevars="bils tas rt rlutcs crelt rsutcs crest cllcalipso clmcalipso clhcalipso pr" ;; |
---|
| 199 | Arct|Sibe|USA) listevars="tas rs rlds rsds crelt crest cllcalipso clmcalipso clhcalipso pr prw" ;; |
---|
| 200 | *) echo cas non prevu ; exit |
---|
| 201 | esac |
---|
| 202 | |
---|
| 203 | nvars=`echo $listevars | wc -w | awk ' { print $1 } '` |
---|
| 204 | case $mask in |
---|
| 205 | NAtl) yax="North Atlantic " ;; |
---|
| 206 | Arct) yax="Arctic ocean" ;; |
---|
| 207 | circA) yax="Circum Antartica " ;; |
---|
| 208 | Sibe) yax="Siberia " ;; |
---|
| 209 | USA) yax="US Gr. Plains " ;; |
---|
| 210 | glob) yax="Global " ;; |
---|
| 211 | ter) yax="Land " ;; |
---|
| 212 | oce) yax="Ocean " ;; |
---|
| 213 | otrop) yax="Tropical ocean " ;; |
---|
| 214 | interH) yax="Inter Hemispheric " ;; |
---|
| 215 | etoa) yax="ETOA " ;; |
---|
| 216 | etow) yax="ETO - Weak " ;; |
---|
| 217 | etows) yax="subs - Weak " ;; |
---|
| 218 | circAa) yax="Circum Antartic Anom. " ;; |
---|
| 219 | NAtla) yax="Nort Atlantic Anom. " ;; |
---|
| 220 | conv) yax="Convective regimes " ;; |
---|
| 221 | weak) yax="Weak convection " ;; |
---|
| 222 | subs) yax="Subsidences " ;; |
---|
| 223 | PANET) yax="Pacific Trop. NE" ;; |
---|
| 224 | CONMAR) yax="Terres Cont. Mar." ;; |
---|
| 225 | OCEMAR) yax="Ocean Cont. Mar." |
---|
| 226 | esac |
---|
| 227 | cat <<...eod>| tmp.param |
---|
| 228 | g0 type Chart |
---|
| 229 | world -0.5, -35, $nvars, 35 |
---|
| 230 | yaxis label "$yax Fluxes (W/m2) " |
---|
| 231 | xaxis ticklabel font 0 |
---|
| 232 | xaxis ticklabel color 1 |
---|
| 233 | xaxis tick place both |
---|
| 234 | xaxis tick spec type both |
---|
| 235 | xaxis tick spec 11 |
---|
| 236 | xaxis ticklabel char size 1.3 |
---|
| 237 | xaxis ticklabel angle 90 |
---|
| 238 | yaxis tick major 10 |
---|
| 239 | yaxis tick minor ticks 1 |
---|
| 240 | legend 1.20, 0.8 |
---|
| 241 | ...eod |
---|
| 242 | |
---|
| 243 | ii=0 |
---|
| 244 | for var in $listevars ; do |
---|
| 245 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
| 246 | titre=`grep "^$var " descr | sed -e 's/'$var'//' -e 's/'$fact'//'` |
---|
| 247 | cat <<......eod>> tmp.param |
---|
| 248 | xaxis tick major $ii, $ii |
---|
| 249 | xaxis ticklabel $ii, "$titre" |
---|
| 250 | ......eod |
---|
| 251 | (( ii = $ii + 1 )) |
---|
| 252 | done |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | prev="" |
---|
| 256 | ip=0 |
---|
| 257 | listex="" |
---|
| 258 | echo LISTESIMSY $listsimsy |
---|
| 259 | for simy in $listsimsy ; do |
---|
| 260 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
| 261 | years=`echo $simy | sed -e s/${sim}//` |
---|
| 262 | echo $sim |
---|
| 263 | SIM_DIR=$CMOR_DIR/$sim$years/METRICS |
---|
| 264 | ls $SIM_DIR |
---|
| 265 | OBS_DIR=$CMOR_DIR/OBS/METRICS |
---|
| 266 | mkdir -p $WRK_D/$mask |
---|
| 267 | if [ "$sim" = "$prev" ] ; then # Cas ou on a plusieurs decennies de la meme simu |
---|
| 268 | (( ip = $ip + 1 )) |
---|
| 269 | xmgr=$WRK_D/$mask/$sim.$ip |
---|
| 270 | listex="$listex $sim.$ip" |
---|
| 271 | else |
---|
| 272 | xmgr=$WRK_D/$mask/$sim |
---|
| 273 | ip=0 ; prev=$sim |
---|
| 274 | listex="$listex $sim" |
---|
| 275 | fi |
---|
| 276 | rm -f $xmgr ; touch $xmgr |
---|
| 277 | for var in $listevars ; do |
---|
| 278 | echo var $var |
---|
| 279 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
| 280 | paste $OBS_DIR/$mask $SIM_DIR/$mask | grep "^$var " | awk ' { if ( $4 == 999999 ) print 0 ; else print '$fact' * ( $4 - $2 ) } ' >> $xmgr |
---|
| 281 | done |
---|
| 282 | done |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | size=`echo $listsims | wc -w | awk ' { print 3. / $1 } '` |
---|
| 287 | for ii in 0 1 2 3 4 5 6 7 8 9 10 11 12 ; do |
---|
| 288 | echo "s$ii type bar" >> tmp.param |
---|
| 289 | echo "s$ii symbol fill pattern 1" >> tmp.param |
---|
| 290 | echo "s$ii symbol size $size" >> tmp.param |
---|
| 291 | echo "s$ii line linestyle 0" >> tmp.param |
---|
[4306] | 292 | echo "s$ii color $ii" >> tmp.param |
---|
[3684] | 293 | done |
---|
| 294 | |
---|
| 295 | cd $WRK_D/$mask |
---|
| 296 | pwd ; echo xmgrace $listex -param ../../../tmp.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
| 297 | xmgrace $listex -param ../../../tmp.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
[4306] | 298 | cp ../../../Colordef.txt . |
---|
| 299 | sed -i -e '32,47d' tmp.eps |
---|
| 300 | sed -i -e '31r Colordef.txt' tmp.eps |
---|
[3684] | 301 | epstopdf tmp.eps |
---|
| 302 | OUT_D=$COMP_D/METRICS/$season ; mkdir -p $OUT_D |
---|
| 303 | \mv -f tmp.pdf $OUT_D/$mask.pdf ; convert -density 144 $OUT_D/$mask.pdf $OUT_D/$mask.png |
---|
| 304 | cd ../../.. |
---|
| 305 | |
---|
| 306 | done |
---|
| 307 | |
---|
| 308 | cp mask*png $OUT_D |
---|
| 309 | done |
---|