Changeset 13723 for NEMO/branches/2020
- Timestamp:
- 2020-11-03T17:17:45+01:00 (4 years ago)
- Location:
- NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF
- Files:
-
- 2 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 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_OCE.py
r13719 r13723 3 3 # 4 4 ########################################################################################## 5 # Post-diagnostic of STATION_ASF for ocean only (no sea-ice support)5 # Post-diagnostic of STATION_ASF for air-sea fluxes (over open ocean) 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 = [ 'ANDREAS' , 'COARE3p6' , 'ECMWF' , 'NCAR' ]31 30 l_color = [ '0.85' , '#ffed00' , '#008ab8' , '0.4' ] ; # colors to differentiate algos on the plot 32 31 l_width = [ 4 , 3 , 2 , 1 ] ; # line-width to differentiate algos on the plot 33 32 l_style = [ '-' , '-' , '-' , '--' ] ; # line-style 34 33 35 nb_algos = len(L_ALGOS) ; print(nb_algos)36 34 37 35 # Variables to compare between algorithms 38 36 ############################################ 37 crealm = 'open-ocean' 39 38 L_VNEM = [ 'Cd_oce' , 'Ce_oce' , 'qla_oce' , 'qsb_oce' , 'qt_oce' , 'qlw_oce' , 'taum' , 'dt_skin' ] 40 39 L_VARO = [ 'Cd' , 'Ce' , 'Qlat' , 'Qsen' , 'Qnet' , 'Qlw' , 'Tau' , 'dT_skin' ] ; # name of variable on figure 41 40 L_VARL = [ r'$C_{D}$' , r'$C_{E}$' , r'$Q_{lat}$', r'$Q_{sens}$' , r'$Q_{net}$' , r'$Q_{lw}$' , r'$|\tau|$' , r'$\Delta T_{skin}$' ] ; # name of variable in latex mode 42 41 L_VUNT = [ '' , '' , r'$W/m^2$' , r'$W/m^2$' , r'$W/m^2$' , r'$W/m^2$' , r'$N/m^2$' , 'K' ] 43 L_BASE = [ 0.00 5 , 0.005, 5. , 5. , 5 , 5. , 0.05 , 0.05 ]42 L_BASE = [ 0.0005 , 0.0005 , 5. , 5. , 5 , 5. , 0.05 , 0.05 ] 44 43 L_PREC = [ 3 , 3 , 0 , 0 , 0 , 0 , 2 , 3 ] 45 44 L_ANOM = [ False , False , True , True , True , True , True , False ] 46 45 46 # About STATION_ASF output files to read: 47 cpref = 'STATION_ASF-' ; np = len(cpref) 48 csuff = '_gridT.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_gridT.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 … … 146 173 xxx = nmp.zeros((Nt,ntemp)) 147 174 148 for ja in range(nb_ algos):175 for ja in range(nb_exp): 149 176 # 150 177 # Temperatures... … … 170 197 ax1.grid(color='k', linestyle='-', linewidth=0.3) 171 198 plt.legend(loc='best', ncol=1, shadow=True, fancybox=True) 172 ax1.annotate('Algo: '+ L_ALGOS[ja]+', station: '+cforcing, xy=(0.5, 1.), xycoords='axes fraction', ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, zorder=50, **font_inf)173 plt.savefig('01_temperatures_'+ L_ALGOS[ja]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False)199 ax1.annotate('Algo: '+list_exp[ja]+', station: '+cforcing, xy=(0.5, 1.), xycoords='axes fraction', ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, zorder=50, **font_inf) 200 plt.savefig('01_temperatures_'+list_exp[ja]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False) 174 201 plt.close(1) 175 202 … … 183 210 nb_var = len(L_VNEM) 184 211 185 xF = nmp.zeros((Nt,nb_ algos))186 xFa = nmp.zeros((Nt,nb_ algos))212 xF = nmp.zeros((Nt,nb_exp)) 213 xFa = nmp.zeros((Nt,nb_exp)) 187 214 188 215 … … 190 217 print('\n *** Treating variable: '+L_VARO[jv]+' !') 191 218 192 for ja in range(nb_ algos):219 for ja in range(nb_exp): 193 220 # 194 221 id_in = Dataset(cf_in[ja]) … … 206 233 plt.xticks(rotation='60', **font_x) 207 234 208 for ja in range(nb_ algos):235 for ja in range(nb_exp): 209 236 fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] ) 210 237 plt.plot(vtime, fplot, '-', color=l_color[ja], \ 211 linestyle=l_style[ja], linewidth=l_width[ja], label= L_ALGOS[ja], zorder=10+ja)238 linestyle=l_style[ja], linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja) 212 239 213 240 fmin, fmax = round_bounds( nmp.min(xF[idx_okay]) , nmp.max(xF[idx_okay]), base=L_BASE[jv], prec=L_PREC[jv]) … … 220 247 ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \ 221 248 zorder=50, **font_inf) 222 plt.savefig(L_VARO[jv]+'_'+cforcing+' .'+fig_ext, dpi=int(rDPI), transparent=False)249 plt.savefig(L_VARO[jv]+'_'+cforcing+'_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False) 223 250 plt.close(jv) 224 251 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 239 266 if L_ANOM[jv]: 240 267 241 for ja in range(nb_ algos): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1)268 for ja in range(nb_exp): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1) 242 269 243 270 if nmp.sum(nmp.abs(xFa[:,:])) == 0.0: … … 251 278 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 252 279 fig = plt.figure(num = 10+jv, figsize=size_fig, facecolor='w', edgecolor='k') 253 ax1 = plt.axes([0.09, 0.2 5, 0.9, 0.7])280 ax1 = plt.axes([0.09, 0.23, 0.9, 0.7]) 254 281 ax1.set_xticks(vtime[::xticks_d]) 255 282 ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S')) 256 283 plt.xticks(rotation='60', **font_x) 257 284 258 for ja in range(nb_algos): 259 plt.plot(vtime, xFa[:,ja], '-', color=l_color[ja], linewidth=l_width[ja], label=L_ALGOS[ja], zorder=10+ja) 285 for ja in range(nb_exp): 286 fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] ) 287 plt.plot(vtime, fplot, '-', color=l_color[ja], \ 288 linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja) 260 289 261 290 ax1.set_ylim(-yrng,yrng) ; ax1.set_xlim(vtime[0],vtime[Nt-1]) … … 263 292 ax1.grid(color='k', linestyle='-', linewidth=0.3) 264 293 plt.legend(bbox_to_anchor=(0.45, 0.2), ncol=1, shadow=True, fancybox=True) 265 ax1.annotate('Anomaly of '+cvar_lnm, xy=(0.3, 0.97), xycoords='axes fraction', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, zorder=50, **font_inf) 266 plt.savefig(L_VARO[jv]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False) 294 ax1.annotate('Anomaly of '+cvar_lnm+', station: '+cforcing, xy=(0.5, 1.04), xycoords='axes fraction', \ 295 ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \ 296 zorder=50, **font_inf) 297 plt.savefig(L_VARO[jv]+'_'+cforcing+'_anomaly_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False) 267 298 plt.close(10+jv) 299 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: See TracChangeset
for help on using the changeset viewer.