Changeset 13723 for NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_ICE.py
- Timestamp:
- 2020-11-03T17:17:45+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_ICE.py
r13719 r13723 3 3 # 4 4 ########################################################################################## 5 # Post-diagnostic of STATION_ASF with sea-ice support (ex: run with forcing "ERA5_arctic")5 # Post-diagnostic of STATION_ASF for air-ice fluxes (over sea-ice) 6 6 # 7 7 # L. Brodeau, 2020 … … 9 9 10 10 import sys 11 from os import path as path11 from os import path, listdir 12 12 import argparse as ap 13 13 from math import floor, ceil, copysign, log … … 28 28 rDPI=100. 29 29 30 L_ALGOS = [ 'ECMWF-CSTC', 'ECMWF-LG15', 'ECMWF-LU12' ] 31 l_color = [ '0.4' , '#ffed00' , '#008ab8' ] ; # colors to differentiate algos on the plot 32 l_width = [ 3 , 3 , 2 ] ; # line-width to differentiate algos on the plot 33 l_style = [ '--' , '-' , '-' ] ; # line-style 34 35 nb_algos = len(L_ALGOS) ; print(nb_algos) 30 l_color = [ '0.85' , '#ffed00' , '#008ab8' , '0.4' ] ; # colors to differentiate algos on the plot 31 l_width = [ 4 , 3 , 2 , 1 ] ; # line-width to differentiate algos on the plot 32 l_style = [ '-' , '-' , '-' , '--' ] ; # line-style 33 36 34 37 35 # Variables to compare between algorithms 38 36 ############################################ 37 crealm = 'sea-ice' 39 38 L_VNEM = [ 'Cd_ice', 'Ce_ice', 'qla_ice' , 'qsb_ice' , 'qt_ice' , 'qlw_ice' , 'qsr_ice' , 'taum_ai' ] 40 39 L_VARO = [ 'Cd' , 'Ce' , 'Qlat' , 'Qsen' , 'Qnet' , 'Qlw' , 'Qsw' , 'Tau' ] … … 45 44 L_ANOM = [ False , False , True , True , True , True , True , True ] 46 45 46 # About STATION_ASF output files to read: 47 cpref = 'STATION_ASF-' ; np = len(cpref) 48 csuff = '_icemod.nc' ; ns = len(csuff) 49 cclnd = '_1h_YYYY0101_YYYY1231' ; nc = len(cclnd) 47 50 48 51 … … 84 87 # Populating and checking existence of files to be read 85 88 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 86 def chck4f(cf): 87 cmesg = 'ERROR: File '+cf+' does not exist !!!' 88 if not path.exists(cf): print(cmesg) ; sys.exit(0) 89 90 cf_in = [] 91 for ja in range(nb_algos): 92 cfi = cdir_data+'/output/'+CONF+'-'+L_ALGOS[ja]+'_'+cforcing+'_1h_'+cy1+'0101_'+cy2+'1231_icemod.nc' 93 chck4f(cfi) 94 cf_in.append(cfi) 95 print('Files we are goin to use:') 96 for ja in range(nb_algos): print(cf_in[ja]) 89 90 dir_out = cdir_data+'/output' 91 ldir = listdir(dir_out) 92 93 cf_in = [] 94 list_exp = [] 95 list_frc = [] 96 for fn in ldir: 97 fpn = dir_out+'/'+fn 98 if path.isfile(dir_out+'/'+fn): 99 if fn[:np]==cpref and fn[-ns:]==csuff and cforcing in fn: 100 print('\n file: '+fn) 101 clab = fn[np:-nc-ns] 102 [ cexp, cfrc ] = str.split(clab, '_', 1) 103 print(' ===> Experiment = '+cexp+', Forcing = '+cfrc) 104 list_exp.append(cexp) 105 list_frc.append(cfrc) 106 cf_in.append(fpn) 107 nbf = len( set(list_frc) ) 108 if not nbf == 1: 109 print('PROBLEM: we found files for more that one forcing: ', set(list_frc)) 110 sys.exit(0) 111 112 nb_exp = len(list_exp) 113 114 115 print('\n\nThere are '+str(nb_exp)+' experiments to compare:') 116 for ja in range(nb_exp): print(' * '+list_exp[ja]+'\n'+' ==> '+cf_in[ja]+'\n') 117 118 if nb_exp > len(l_color): 119 print('PROBLEM: the max number of experiments for comparison is '+str(len(l_color))+' for now...') 120 sys.exit(0) 121 122 123 97 124 #----------------------------------------------------------------- 98 125 … … 135 162 nb_var = len(L_VNEM) 136 163 137 xF = nmp.zeros((Nt,nb_ algos))138 xFa = nmp.zeros((Nt,nb_ algos))164 xF = nmp.zeros((Nt,nb_exp)) 165 xFa = nmp.zeros((Nt,nb_exp)) 139 166 140 167 … … 142 169 print('\n *** Treating variable: '+L_VARO[jv]+' !') 143 170 144 for ja in range(nb_ algos):171 for ja in range(nb_exp): 145 172 # 146 173 id_in = Dataset(cf_in[ja]) … … 158 185 plt.xticks(rotation='60', **font_x) 159 186 160 for ja in range(nb_ algos):187 for ja in range(nb_exp): 161 188 fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] ) 162 189 plt.plot(vtime, fplot, '-', color=l_color[ja], \ 163 linestyle=l_style[ja], linewidth=l_width[ja], label= L_ALGOS[ja], zorder=10+ja)190 linestyle=l_style[ja], linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja) 164 191 165 192 fmin, fmax = round_bounds( nmp.min(xF[idx_okay]) , nmp.max(xF[idx_okay]), base=L_BASE[jv], prec=L_PREC[jv]) … … 172 199 ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \ 173 200 zorder=50, **font_inf) 174 plt.savefig(L_VARO[jv]+'_'+cforcing+' .'+fig_ext, dpi=int(rDPI), transparent=False)201 plt.savefig(L_VARO[jv]+'_'+cforcing+'_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False) 175 202 plt.close(jv) 176 203 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 191 218 if L_ANOM[jv]: 192 219 193 for ja in range(nb_ algos): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1)220 for ja in range(nb_exp): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1) 194 221 195 222 if nmp.sum(nmp.abs(xFa[:,:])) == 0.0: … … 208 235 plt.xticks(rotation='60', **font_x) 209 236 210 for ja in range(nb_ algos):237 for ja in range(nb_exp): 211 238 fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] ) 212 plt.plot(vtime, fplot, '-', color=l_color[ja], linewidth=l_width[ja],\213 l abel=L_ALGOS[ja], zorder=10+ja)239 plt.plot(vtime, fplot, '-', color=l_color[ja], \ 240 linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja) 214 241 215 242 ax1.set_ylim(-yrng,yrng) ; ax1.set_xlim(vtime[0],vtime[Nt-1]) … … 220 247 ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \ 221 248 zorder=50, **font_inf) 222 plt.savefig(L_VARO[jv]+'_ anomaly.'+fig_ext, dpi=int(rDPI), transparent=False)249 plt.savefig(L_VARO[jv]+'_'+cforcing+'_anomaly_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False) 223 250 plt.close(10+jv) 224 251 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: See TracChangeset
for help on using the changeset viewer.