| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | . env.sh |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | wavemin=1 |
|---|
| 7 | wavemax=`ls Remaining_space_after_wave_* | cut -d _ -f5 | cut -d. -f1 | sort -n | tail -1` |
|---|
| 8 | # wavemax can also be set manually |
|---|
| 9 | #wavemax=22 |
|---|
| 10 | nwave=$(( $wavemax - $wavemin + 1)) |
|---|
| 11 | |
|---|
| 12 | ################################################################## |
|---|
| 13 | # Controle of a sublist for the waves shading on profiles |
|---|
| 14 | if [ $wavemax -le 3 ] ; then |
|---|
| 15 | ListWaves=" `seq 1 $wavemax` " |
|---|
| 16 | else |
|---|
| 17 | ListWaves=" 1 3 $wavemax " |
|---|
| 18 | fi |
|---|
| 19 | # could be also set manually |
|---|
| 20 | # ListWaves=" 1 3 6 " |
|---|
| 21 | # wave_inc=1 |
|---|
| 22 | # ListWaves=$( seq $wavemin $wave_inc $wavemax ) |
|---|
| 23 | ################################################################## |
|---|
| 24 | |
|---|
| 25 | if [ `python -V 2>&1 | awk ' { print $2 } ' | cut -c1` != 2 ] ; then |
|---|
| 26 | echo You should use python 2 and not 3 ; exit ; fi |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | ############################################################################### |
|---|
| 30 | # Some preliminary computations |
|---|
| 31 | #------------------------------ |
|---|
| 32 | #echo $wavemin $wavemax $(seq $wavemin $wavemax) ; exit |
|---|
| 33 | for i in $(seq $wavemin $wavemax) ; do |
|---|
| 34 | echo $i |
|---|
| 35 | # Computing scores fore all the SCM simulations if not already done |
|---|
| 36 | if [ ! -f score$i.csv ] ; then echo Runing post_scores.sh first ; pause 10 ; ./post_scores.sh $wavemin $wavemax ; fi |
|---|
| 37 | # Compute the mean and max of the ensembles |
|---|
| 38 | for d in WAVE$i/*/* ; do |
|---|
| 39 | if [ -d $d ] ; then |
|---|
| 40 | cd $d |
|---|
| 41 | for stat in min max avg ; do if [ ! -f ens${stat}.nc ] ; then cdo ens${stat} SCM*nc ens${stat}.nc ; fi ; done |
|---|
| 42 | cd - |
|---|
| 43 | fi |
|---|
| 44 | done |
|---|
| 45 | done |
|---|
| 46 | |
|---|
| 47 | ############################################################################## |
|---|
| 48 | # Ranking the SCM simulations according to scores |
|---|
| 49 | #------------------------------------------------ |
|---|
| 50 | |
|---|
| 51 | scores="" |
|---|
| 52 | for i in $( seq $wavemin $wavemax ) ; do scores="$scores score$i.csv" ; done |
|---|
| 53 | cat $scores | awk -F, ' { print $(NF-1)","$0 } ' | sort >| opt_scores.csv |
|---|
| 54 | simss=`head -10 opt_scores.csv | awk -F, ' { print $2 } '` |
|---|
| 55 | echo $simss |
|---|
| 56 | head -1 WAVE$wavemax/Par*asc >| params_opt.csv |
|---|
| 57 | for sim in $simss ; do |
|---|
| 58 | grep $sim */Par*asc >> params_opt.csv |
|---|
| 59 | done |
|---|
| 60 | |
|---|
| 61 | iname=0 |
|---|
| 62 | |
|---|
| 63 | ############################################################################# |
|---|
| 64 | # Loop on the best 10 simulations according to the above ranking |
|---|
| 65 | #--------------------------------------------------------------- |
|---|
| 66 | |
|---|
| 67 | for sims in "$simss" $simss ; do |
|---|
| 68 | echo $sims |
|---|
| 69 | |
|---|
| 70 | set -vx |
|---|
| 71 | cat <<eod>| simus.py |
|---|
| 72 | #-*- coding:UTF-8 -*- |
|---|
| 73 | # files that define the lists of the simulations you want to draw and also define information of the profiles |
|---|
| 74 | # time of the profile, color/style of the lines, xmin/xmax, ymin/ymax ranges) |
|---|
| 75 | from datetime import datetime |
|---|
| 76 | |
|---|
| 77 | DIRDATA='./' |
|---|
| 78 | |
|---|
| 79 | nomvar='theta' |
|---|
| 80 | |
|---|
| 81 | # couleurs des courbes |
|---|
| 82 | #--------------------- |
|---|
| 83 | # cycle de couleurs |
|---|
| 84 | listcoul=['black','red','green','fuchsia','blue','lime','darkviolet','cyan','darkorange','slateblue','brown','gold'] |
|---|
| 85 | |
|---|
| 86 | # exemple dictionnaire de couleurs en fonction du nom de fichier (sans le prefixe time_ ou prof_) |
|---|
| 87 | #black=reference; blue=bb; violet=turb, orange=pas de temps, Diffusion=vert, resolution=grey, advection=red, resv=brown,domain= microphysique=turquoise |
|---|
| 88 | dicocoul={\\ |
|---|
| 89 | 'SCM.nc' : 'black',\\ |
|---|
| 90 | 'LES0.nc' : 'slateblue',\\ |
|---|
| 91 | 'LES1.nc' : 'blue',\\ |
|---|
| 92 | 'LES2.nc' : 'blue',\\ |
|---|
| 93 | 'LES3.nc' : 'blue',\\ |
|---|
| 94 | 'LES4.nc' : 'blue',\\ |
|---|
| 95 | 'LES5.nc' : 'blue',\\ |
|---|
| 96 | 'LES6.nc' : 'blue',\\ |
|---|
| 97 | 'LES7.nc' : 'blue',\\ |
|---|
| 98 | 'LES8.nc' : 'blue',\\ |
|---|
| 99 | eod |
|---|
| 100 | |
|---|
| 101 | cols=( red green fuchsia lime darkviolet cyan darkorange slateblue brown gold ) |
|---|
| 102 | ii=0 |
|---|
| 103 | for sim in $sims ; do |
|---|
| 104 | cat <<eod>> simus.py |
|---|
| 105 | '$sim.nc' : '${cols[$ii]}',\\ |
|---|
| 106 | eod |
|---|
| 107 | (( ii = $ii + 1 )) |
|---|
| 108 | done |
|---|
| 109 | |
|---|
| 110 | cat <<eod>> simus.py |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | dicostyl={\\ |
|---|
| 114 | 'SCM.nc' : '-',\\ |
|---|
| 115 | 'LES0.nc' : '-',\\ |
|---|
| 116 | 'LES1.nc' : '-.',\\ |
|---|
| 117 | 'LES2.nc' : '-.',\\ |
|---|
| 118 | 'LES3.nc' : '-.',\\ |
|---|
| 119 | 'LES4.nc' : '-.',\\ |
|---|
| 120 | 'LES5.nc' : '-.',\\ |
|---|
| 121 | 'LES6.nc' : '-.',\\ |
|---|
| 122 | 'LES7.nc' : '-.',\\ |
|---|
| 123 | 'LES8.nc' : '-.',\\ |
|---|
| 124 | eod |
|---|
| 125 | |
|---|
| 126 | for sim in $sims ; do |
|---|
| 127 | cat <<eod>> simus.py |
|---|
| 128 | '$sim.nc' : '-',\\ |
|---|
| 129 | eod |
|---|
| 130 | done |
|---|
| 131 | |
|---|
| 132 | wave_ens=1 |
|---|
| 133 | cat <<eod>> simus.py |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | # listcoul ou dicocoul ou dicohightune ou ... |
|---|
| 137 | #coul1d=listcoul |
|---|
| 138 | styl1d=dicostyl |
|---|
| 139 | coul1d=dicocoul |
|---|
| 140 | |
|---|
| 141 | # liste des fichiers sélectionnés |
|---|
| 142 | listfic=[\\ |
|---|
| 143 | 'LES/'+Case+'/'+SubCase+'/LES0.nc',\\ |
|---|
| 144 | 'LES/'+Case+'/'+SubCase+'/LES1.nc',\\ |
|---|
| 145 | 'LES/'+Case+'/'+SubCase+'/LES2.nc',\\ |
|---|
| 146 | 'LES/'+Case+'/'+SubCase+'/LES3.nc',\\ |
|---|
| 147 | 'LES/'+Case+'/'+SubCase+'/LES4.nc',\\ |
|---|
| 148 | 'LES/'+Case+'/'+SubCase+'/LES6.nc',\\ |
|---|
| 149 | 'LES/'+Case+'/'+SubCase+'/LES7.nc',\\ |
|---|
| 150 | 'LES/'+Case+'/'+SubCase+'/LES8.nc',\\ |
|---|
| 151 | eod |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | for sim in $sims ; do |
|---|
| 156 | w=`echo $sim | cut -d\- -f2` |
|---|
| 157 | echo $sim $w |
|---|
| 158 | cat <<eod>> simus.py |
|---|
| 159 | 'WAVE$w/'+Case+'/'+SubCase+'/$sim.nc',\\ |
|---|
| 160 | eod |
|---|
| 161 | done |
|---|
| 162 | |
|---|
| 163 | cat <<eod>> simus.py |
|---|
| 164 | 'CTRL/'+Case+'/'+SubCase+'/SCM.nc',\\ |
|---|
| 165 | ] |
|---|
| 166 | eod |
|---|
| 167 | |
|---|
| 168 | echo 'list_ens=[\' >> simus.py |
|---|
| 169 | for wave_ens in $ListWaves ; do |
|---|
| 170 | cat <<eod>> simus.py |
|---|
| 171 | 'WAVE$wave_ens/'+Case+'/'+SubCase,\\ |
|---|
| 172 | eod |
|---|
| 173 | done |
|---|
| 174 | echo ']' >> simus.py |
|---|
| 175 | |
|---|
| 176 | ./post.sh |
|---|
| 177 | mv t.pdf Prof$iname.pdf |
|---|
| 178 | |
|---|
| 179 | mkdir -p PROFILES/BEST$iname |
|---|
| 180 | mv profil* PROFILES/BEST$iname |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | (( iname = $iname + 1 )) |
|---|
| 184 | |
|---|
| 185 | done |
|---|