Index: NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_ICE.py
===================================================================
--- NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_ICE.py	(revision 13719)
+++ NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_ICE.py	(revision 13723)
@@ -3,5 +3,5 @@
 #
 ##########################################################################################
-# Post-diagnostic of STATION_ASF with sea-ice support (ex: run with forcing "ERA5_arctic")
+# Post-diagnostic of STATION_ASF for air-ice fluxes (over sea-ice)
 #
 #  L. Brodeau, 2020
@@ -9,5 +9,5 @@
 
 import sys
-from os import path as path
+from os import path, listdir
 import argparse as ap
 from math import floor, ceil, copysign, log
@@ -28,13 +28,12 @@
 rDPI=100.
 
-L_ALGOS = [ 'ECMWF-CSTC', 'ECMWF-LG15', 'ECMWF-LU12' ]
-l_color = [     '0.4'   ,  '#ffed00'  , '#008ab8'    ] ; # colors to differentiate algos on the plot
-l_width = [       3     ,     3       ,      2       ] ; # line-width to differentiate algos on the plot
-l_style = [      '--'   ,    '-'      ,     '-'      ] ; # line-style
-
-nb_algos = len(L_ALGOS) ; print(nb_algos)
+l_color = [ '0.85'    ,  '#ffed00' , '#008ab8' , '0.4'  ] ; # colors to differentiate algos on the plot
+l_width = [  4        ,     3      ,    2      ,  1     ] ; # line-width to differentiate algos on the plot
+l_style = [ '-'       ,    '-'     ,   '-'     , '--'   ] ; # line-style
+
 
 # Variables to compare between algorithms
 ############################################
+crealm = 'sea-ice'
 L_VNEM = [   'Cd_ice',   'Ce_ice',   'qla_ice' ,   'qsb_ice'   ,  'qt_ice'    ,  'qlw_ice'  ,  'qsr_ice'  , 'taum_ai'   ]
 L_VARO = [     'Cd'  ,     'Ce'  ,   'Qlat'    ,    'Qsen'     ,   'Qnet'     ,   'Qlw'     ,    'Qsw'    ,  'Tau'      ]
@@ -45,4 +44,8 @@
 L_ANOM = [   False   ,   False   ,   True      ,    True       ,    True      ,    True     ,    True     ,   True      ]
 
+# About STATION_ASF output files to read:
+cpref = 'STATION_ASF-'          ; np = len(cpref)
+csuff = '_icemod.nc'            ; ns = len(csuff)
+cclnd = '_1h_YYYY0101_YYYY1231' ; nc = len(cclnd)
 
 
@@ -84,15 +87,39 @@
 # Populating and checking existence of files to be read
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-def chck4f(cf):
-    cmesg = 'ERROR: File '+cf+' does not exist !!!'
-    if not path.exists(cf): print(cmesg) ; sys.exit(0)
-
-cf_in = []
-for ja in range(nb_algos):
-    cfi = cdir_data+'/output/'+CONF+'-'+L_ALGOS[ja]+'_'+cforcing+'_1h_'+cy1+'0101_'+cy2+'1231_icemod.nc'
-    chck4f(cfi)
-    cf_in.append(cfi)
-print('Files we are goin to use:')
-for ja in range(nb_algos): print(cf_in[ja])
+
+dir_out = cdir_data+'/output'
+ldir = listdir(dir_out)
+
+cf_in    = []
+list_exp = []
+list_frc = []
+for fn in ldir:
+    fpn = dir_out+'/'+fn
+    if path.isfile(dir_out+'/'+fn):
+        if fn[:np]==cpref and fn[-ns:]==csuff and cforcing in fn:
+            print('\n file: '+fn)
+            clab = fn[np:-nc-ns]
+            [ cexp, cfrc ] = str.split(clab, '_', 1)
+            print('  ===> Experiment = '+cexp+', Forcing = '+cfrc)
+            list_exp.append(cexp)
+            list_frc.append(cfrc)
+            cf_in.append(fpn)
+nbf = len( set(list_frc) )
+if not nbf == 1:
+    print('PROBLEM: we found files for more that one forcing: ', set(list_frc))
+    sys.exit(0)
+
+nb_exp = len(list_exp)
+
+
+print('\n\nThere are '+str(nb_exp)+' experiments to compare:')
+for ja in range(nb_exp): print('  * '+list_exp[ja]+'\n'+'     ==> '+cf_in[ja]+'\n')
+
+if nb_exp > len(l_color):
+    print('PROBLEM: the max number of experiments for comparison is '+str(len(l_color))+' for now...')
+    sys.exit(0)
+
+
+
 #-----------------------------------------------------------------
 
@@ -135,6 +162,6 @@
 nb_var = len(L_VNEM)
 
-xF  = nmp.zeros((Nt,nb_algos))
-xFa = nmp.zeros((Nt,nb_algos))
+xF  = nmp.zeros((Nt,nb_exp))
+xFa = nmp.zeros((Nt,nb_exp))
 
 
@@ -142,5 +169,5 @@
     print('\n *** Treating variable: '+L_VARO[jv]+' !')
 
-    for ja in range(nb_algos):
+    for ja in range(nb_exp):
         #
         id_in = Dataset(cf_in[ja])
@@ -158,8 +185,8 @@
     plt.xticks(rotation='60', **font_x)
 
-    for ja in range(nb_algos):
+    for ja in range(nb_exp):
         fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] )
         plt.plot(vtime, fplot, '-', color=l_color[ja], \
-                 linestyle=l_style[ja], linewidth=l_width[ja], label=L_ALGOS[ja], zorder=10+ja)
+                 linestyle=l_style[ja], linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja)
 
     fmin, fmax = round_bounds( nmp.min(xF[idx_okay]) , nmp.max(xF[idx_okay]), base=L_BASE[jv], prec=L_PREC[jv])
@@ -172,5 +199,5 @@
                  ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \
                  zorder=50, **font_inf)
-    plt.savefig(L_VARO[jv]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False)
+    plt.savefig(L_VARO[jv]+'_'+cforcing+'_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False)
     plt.close(jv)
     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -191,5 +218,5 @@
     if L_ANOM[jv]:
 
-        for ja in range(nb_algos): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1)
+        for ja in range(nb_exp): xFa[:,ja] = xF[:,ja] - nmp.mean(xF,axis=1)
 
         if nmp.sum(nmp.abs(xFa[:,:])) == 0.0:
@@ -208,8 +235,8 @@
             plt.xticks(rotation='60', **font_x)
 
-            for ja in range(nb_algos):
+            for ja in range(nb_exp):
                 fplot = nmp.ma.masked_where( xF[:,ja]==0., xF[:,ja] )
-                plt.plot(vtime, fplot, '-', color=l_color[ja], linewidth=l_width[ja], \
-                         label=L_ALGOS[ja], zorder=10+ja)
+                plt.plot(vtime, fplot, '-', color=l_color[ja], \
+                         linewidth=l_width[ja], label=list_exp[ja], zorder=10+ja)
 
             ax1.set_ylim(-yrng,yrng) ; ax1.set_xlim(vtime[0],vtime[Nt-1])
@@ -220,5 +247,5 @@
                          ha='center', bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \
                          zorder=50, **font_inf)
-            plt.savefig(L_VARO[jv]+'_anomaly.'+fig_ext, dpi=int(rDPI), transparent=False)
+            plt.savefig(L_VARO[jv]+'_'+cforcing+'_anomaly_'+crealm+'.'+fig_ext, dpi=int(rDPI), transparent=False)
             plt.close(10+jv)
             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
