New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 13690 – NEMO

Changeset 13690


Ignore:
Timestamp:
2020-10-28T13:11:40+01:00 (3 years ago)
Author:
laurent
Message:

Improvements for "oce+ice capable" STATION_ASF!

Location:
NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/launch_sasf.sh

    r13682 r13690  
    1414CONFIG_BLD="STATION_ASF2" ; # name of config as build in NEMO... (directory inside "tests" actually contains the compiled test-case?) 
    1515 
     16# Atmo + SSX forcing to use and sea-ice support? 
     17#     => NFORC: name of forcing 
     18#     => i_sea_ice: whether to compute fluxes over sea-ice as well 
     19#     => SFORC: string sufficient to copy relevant files as in "*${SFORC}*.nc" 
     20#NFORC="PAPA"         ; i_sea_ice=0 ; SFORC="Station_PAPA_50N-145W" 
     21#NFORC="ERA5_arctic" ; i_sea_ice=1 ; SFORC="ERA5_arctic_surface_81N_36p75E_1h" ; # "ERA5_arctic" WITH ice/air flux computation 
     22NFORC="ERA5_arctic" ; i_sea_ice=0 ; SFORC="ERA5_arctic_surface_81N_36p75E_1h" ; # "ERA5_arctic" WITHOUT ice/air flux computation 
     23 
     24 
    1625# Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists: 
    1726NEMO_REF_DIR="`dirname ${PWD} | sed -e 's|/tests/STATION_ASF||g'`" ; # that should normally do the trick! 
     
    2837 
    2938 
    30 # Atmo + SSX forcing to use and wheter to compute fluxes over sea-ice as well (i_sea_ice=1) 
    31 ############################################################################################# 
    32 i_sea_ice=0 ; # default does not compute fluxes over sea-ice 
    33 # 
    34 NFORC="ERA5_arctic" ; i_sea_ice=1 ; FORC="ERA5_arctic_surface_81N_36p75E_1h" ; # string sufficient to copy relevant files as in "*${FORC}*.nc" 
    35 #NFORC="PAPA" ; FORC="Station_PAPA_50N-145W" ; # string sufficient to copy relevant files as in "*${FORC}*.nc" 
    3639 
    3740 
     
    154157# Copy forcing to work directory: 
    155158echo ; echo "Forcing files to use:" 
    156 \ls -l ${DATA_IN_DIR}/*${FORC}*.nc 
    157 echo 
    158 rsync -avP ${DATA_IN_DIR}/*${FORC}*.nc ${PROD_DIR}/ 
     159\ls -l ${DATA_IN_DIR}/*${SFORC}*.nc 
     160echo 
     161rsync -avP ${DATA_IN_DIR}/*${SFORC}*.nc ${PROD_DIR}/ 
    159162echo; echo 
    160163 
  • NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_OCE.py

    r13676 r13690  
    11#!/usr/bin/env python3 
    22# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- 
    3  
    4 # Post-diagnostic of STATION_ASF /  L. Brodeau, 2019 
     3# 
     4########################################################################################## 
     5# Post-diagnostic of STATION_ASF for ocean only  (no sea-ice support) 
     6# 
     7#  L. Brodeau, 2020 
     8########################################################################################## 
    59 
    610import sys 
    711from os import path as path 
    8 import math 
     12import argparse as ap 
     13from math import floor, ceil, copysign, log 
    914import numpy as nmp 
    1015from netCDF4 import Dataset,num2date 
     
    1419import matplotlib.dates as mdates 
    1520 
    16  
    17 cforcing = 'PAPA' ; # name of forcing ('PAPA', 'ERA5_arctic', etc...) 
    18  
    19 cy1     = '2018' ; # First year 
    20 cy2     = '2018' ; # Last year 
    21  
    22 jt0 = 0 
    23  
    2421dir_figs='.' 
    2522size_fig=(13,8) 
    2623size_fig0=(12,10) 
    27 fig_ext='svg' 
    2824 
    2925clr_red = '#AD0000' 
    30 clr_sat = '#ffed00' 
    3126clr_mod = '#008ab8' 
    3227 
    3328rDPI=100. 
    3429 
    35 L_ALGOS = [ 'COARE3p6' , 'ECMWF'   , 'NCAR' , 'ANDREAS' ] 
    36 l_color = [  '#ffed00' , '#008ab8' , '0.4'  , '0.8'     ] ; # colors to differentiate algos on the plot 
    37 l_width = [     3      ,    2      ,  1     ,  3        ] ; # line-width to differentiate algos on the plot 
    38 l_style = [    '-'     ,   '-'     , '--'   , '-'       ] ; # line-style 
    39  
    40  
    41 # Variables to compare for A GIVEN algorithm 
    42 ############################################### 
    43 #L_VNEM0 = [  
    44  
     30L_ALGOS = [ 'ANDREAS' , 'COARE3p6' , 'ECMWF'   , 'NCAR' ] 
     31l_color = [ '0.85'    ,  '#ffed00' , '#008ab8' , '0.4'  ] ; # colors to differentiate algos on the plot 
     32l_width = [  4        ,     3      ,    2      ,  1     ] ; # line-width to differentiate algos on the plot 
     33l_style = [ '-'       ,    '-'     ,   '-'     , '--'   ] ; # line-style 
    4534 
    4635 
     
    5140L_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 
    5241L_VUNT  = [     ''      ,     ''      , r'$W/m^2$'  , r'$W/m^2$'    , r'$W/m^2$'   , r'$W/m^2$'  , r'$N/m^2$'  ,      'K'             ] 
    53 L_VMAX  = [    0.0075   ,    0.005    ,     75.     ,     75.       ,    800.      ,     25.     ,    1.2      ,       0.7            ] 
    54 L_VMIN  = [    0.0005   ,    0.0005   ,   -250.     ,   -125.       ,   -400.      ,   -150.     ,    0.       ,      -0.7            ] 
     42L_BASE  = [    0.005    ,    0.005    ,      5.     ,      5.       ,       5      ,      5.     ,    0.05      ,       0.05           ] 
     43L_PREC  = [      3      ,      3      ,      0      ,      0        ,       0      ,      0      ,     2       ,        3             ] 
    5544L_ANOM  = [   False     ,   False     ,   True      ,    True       ,    True      ,    True     ,   True      ,      False           ] 
    5645 
     
    5847nb_algos = len(L_ALGOS) ; print(nb_algos) 
    5948 
    60 # Getting arguments: 
    61 narg = len(sys.argv) 
    62 if narg != 2: 
    63     print('Usage: '+sys.argv[0]+' <DIR_OUT_SASF>'); sys.exit(0) 
    64 cdir_data = sys.argv[1] 
     49 
     50 
     51 
     52################## ARGUMENT PARSING / USAGE ################################################################################################ 
     53parser = ap.ArgumentParser(description='Generate pixel maps of a given scalar.') 
     54# 
     55requiredNamed = parser.add_argument_group('required arguments') 
     56requiredNamed.add_argument('-d', '--dirout' , required=True,                 help='Path to (production) directory where STATION_ASF was run') 
     57requiredNamed.add_argument('-f', '--forcing', required=True, default="PAPA", help='Name of forcing (ex: PAPA, ERA5_arctic') 
     58# 
     59parser.add_argument('-C', '--conf',   default="STATION_ASF",  help='specify NEMO config (ex: STATION_ASF)') 
     60parser.add_argument('-s', '--ystart', default="2018",         help='specify first year of experiment (ex: 2018)') 
     61parser.add_argument('-e', '--yend',   default="2018",         help='specify last  year of experiment (ex: 2018)') 
     62# 
     63parser.add_argument('-t', '--itype',   default="png",         help='specify the type of image you want to create (ex: png, svg, etc.)') 
     64#parser.add_argument('-l', '--lev' , type=int, default=0,    help='specify the level to use if 3D field (default: 0 => 2D)') 
     65#parser.add_argument('-I', '--ice' , action='store_true',    help='draw sea-ice concentration layer onto the field') 
     66# 
     67args = parser.parse_args() 
     68# 
     69cdir_data = args.dirout 
     70cforcing  = args.forcing 
     71# 
     72CONF      = args.conf 
     73cy1       = args.ystart 
     74cy2       = args.yend 
     75# 
     76fig_ext   = args.itype 
     77#jk    = args.lev 
     78#lshow_ice = args.ice 
     79# 
     80#print(''); print(' *** cdir_data = ', cdir_data); print(' *** cforcing  = ', cforcing) 
     81#print(' *** CONF = ', CONF); print(' *** cy1 = ', cy1); print(' *** cy2 = ', cy2) 
     82############################################################################################################################################### 
    6583 
    6684 
     
    7694cf_in = [] 
    7795for ja in range(nb_algos): 
    78     cfi = cdir_data+'/output/'+'STATION_ASF-'+L_ALGOS[ja]+'_'+cforcing+'_1h_'+cy1+'0101_'+cy2+'1231_gridT.nc' 
     96    cfi = cdir_data+'/output/'+CONF+'-'+L_ALGOS[ja]+'_'+cforcing+'_1h_'+cy1+'0101_'+cy2+'1231_gridT.nc' 
    7997    chck4f(cfi) 
    8098    cf_in.append(cfi) 
     
    84102 
    85103 
     104def round_bounds( x1, x2,  base=5, prec=3 ): 
     105    rmin =  base * round( floor(float(x1)/base), prec ) 
     106    rmax =  base * round(  ceil(float(x2)/base), prec ) 
     107    return rmin, rmax 
     108 
     109 
     110 
    86111# Getting time array from the first file: 
    87112id_in = Dataset(cf_in[0]) 
    88 vt = id_in.variables['time_counter'][jt0:] 
     113vt = id_in.variables['time_counter'][:] 
    89114cunit_t = id_in.variables['time_counter'].units ; print(' "time_counter" is in "'+cunit_t+'"') 
    90115id_in.close() 
     
    133158    id_in = Dataset(cf_in[ja]) 
    134159    for jv in range(ntemp): 
    135         xxx[:,jv] = id_in.variables[vtemp_in[jv]][jt0:,1,1] # only the center point of the 3x3 spatial domain! 
     160        xxx[:,jv] = id_in.variables[vtemp_in[jv]][:,1,1] # only the center point of the 3x3 spatial domain! 
    136161    id_in.close() 
    137162 
     
    145170        plt.plot(vtime, xxx[:,jv], '-', color=vtemp_cl[jv], linestyle=vtemp_ls[jv], linewidth=vtemp_lw[jv], label=vtemp_lb[jv], zorder=10) 
    146171 
    147     ax1.set_ylim(0., 17.) ; ax1.set_xlim(vtime[0],vtime[nbr-1]) 
     172    idx_okay = nmp.where( nmp.abs(xxx) < 1.e+10 ) 
     173    fmin, fmax = round_bounds( nmp.min(xxx[idx_okay]) , nmp.max(xxx[idx_okay]), base=5, prec=0 ) 
     174    ax1.set_ylim(fmin, fmax) ; ax1.set_xlim(vtime[0],vtime[nbr-1]) 
    148175    plt.ylabel(r'Temperature [$^{\circ}$C]') 
    149176 
     
    151178    plt.legend(loc='best', ncol=1, shadow=True, fancybox=True) 
    152179    ax1.annotate('Algo: '+L_ALGOS[ja]+', station: '+cforcing, xy=(0.4, 1.), xycoords='axes fraction',  bbox={'facecolor':'w', 'alpha':1., 'pad':10}, zorder=50, **font_inf) 
    153     plt.savefig('01_temperatures_'+L_ALGOS[ja]+'.'+fig_ext, dpi=int(rDPI), transparent=False) 
     180    plt.savefig('01_temperatures_'+L_ALGOS[ja]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False) 
    154181    plt.close(1) 
    155182 
     
    173200        # 
    174201        id_in = Dataset(cf_in[ja]) 
    175         xF[:,ja] = id_in.variables[L_VNEM[jv]][jt0:,1,1] # only the center point of the 3x3 spatial domain! 
     202        xF[:,ja] = id_in.variables[L_VNEM[jv]][:,1,1] # only the center point of the 3x3 spatial domain! 
    176203        if ja == 0: cvar_lnm = id_in.variables[L_VNEM[jv]].long_name 
    177204        id_in.close() 
    178205 
     206    idx_okay = nmp.where( nmp.abs(xF) < 1.e+10 ) 
     207         
    179208    fig = plt.figure(num = jv, figsize=size_fig, facecolor='w', edgecolor='k') 
    180209    ax1 = plt.axes([0.08, 0.25, 0.9, 0.7]) 
     
    185214    for ja in range(nb_algos): 
    186215        plt.plot(vtime, xF[:,ja], '-', color=l_color[ja], linestyle=l_style[ja], linewidth=l_width[ja], label=L_ALGOS[ja], zorder=10+ja) 
    187  
    188     ax1.set_ylim(L_VMIN[jv], L_VMAX[jv]) ; ax1.set_xlim(vtime[0],vtime[nbr-1]) 
     216         
     217    fmin, fmax = round_bounds( nmp.min(xF[idx_okay]) , nmp.max(xF[idx_okay]), base=L_BASE[jv], prec=L_PREC[jv]) 
     218    #print("LOLO: fmin, fmax =",nmp.min(xF[idx_okay]), nmp.max(xF[idx_okay]) ); print("LOLO: fmin, fmax =",fmin, fmax) ; #sys.exit(0) 
     219     
     220    ax1.set_ylim(fmin, fmax) ; ax1.set_xlim(vtime[0],vtime[nbr-1]) 
    189221    plt.ylabel(L_VARL[jv]+' ['+L_VUNT[jv]+']') 
    190222 
    191223    ax1.grid(color='k', linestyle='-', linewidth=0.3) 
    192224    plt.legend(loc='best', ncol=1, shadow=True, fancybox=True) 
    193     ax1.annotate(cvar_lnm+', station: '+cforcing, xy=(0.3, 1.), xycoords='axes fraction',  bbox={'facecolor':'w', 'alpha':1., 'pad':10}, zorder=50, **font_inf) 
    194     plt.savefig(L_VARO[jv]+'.'+fig_ext, dpi=int(rDPI), transparent=False) 
     225    ax1.annotate(cvar_lnm+', station: '+cforcing, xy=(0.3, 1.), xycoords='axes fraction',  bbox={'facecolor':'w', 'alpha':1., 'pad':10}, \ 
     226                 zorder=50, **font_inf) 
     227    plt.savefig(L_VARO[jv]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False) 
    195228    plt.close(jv) 
    196229 
     
    208241            rmax = nmp.max(xFa) ; rmin = nmp.min(xFa) 
    209242            rmax = max( abs(rmax) , abs(rmin) ) 
    210             romagn = math.floor(math.log(rmax, 10)) ; # order of magnitude of the anomaly  we're dealing with 
     243            romagn = floor(log(rmax, 10)) ; # order of magnitude of the anomaly  we're dealing with 
    211244            rmlt = 10.**(int(romagn)) / 2. 
    212             yrng = math.copysign( math.ceil(abs(rmax)/rmlt)*rmlt , rmax) 
     245            yrng = copysign( ceil(abs(rmax)/rmlt)*rmlt , rmax) 
    213246 
    214247            fig = plt.figure(num = 10+jv, figsize=size_fig, facecolor='w', edgecolor='k') 
     
    226259            plt.legend(bbox_to_anchor=(0.45, 0.2), ncol=1, shadow=True, fancybox=True) 
    227260            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) 
    228             plt.savefig(L_VARO[jv]+'_anomaly.'+fig_ext, dpi=int(rDPI), transparent=False) 
     261            plt.savefig(L_VARO[jv]+'_'+cforcing+'.'+fig_ext, dpi=int(rDPI), transparent=False) 
    229262            plt.close(10+jv) 
    230263 
  • NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/plot_station_asf_OI.py

    r13675 r13690  
    11#!/usr/bin/env python3 
    22# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- 
    3  
    4 # Post-diagnostic of STATION_ASF /  L. Brodeau, 2019 
     3# 
     4########################################################################################## 
     5# Post-diagnostic of STATION_ASF with sea-ice support (ex: run with forcing "ERA5_arctic") 
     6# 
     7#  L. Brodeau, 2020 
     8########################################################################################## 
    59 
    610import sys 
     
    1519 
    1620CONFIG='STATION_ASF' 
    17 FORCING='ERA5_arctic' 
    18 # (files are: output/3x3/'+CONFIG+'-'+algo+'_1h_'+year+'0101_'+year+'1231_gridT_'+FORCING+'.nc' ) 
     21 
     22cforcing = 'PAPA' ; # name of forcing ('PAPA', 'ERA5_arctic', etc...) 
     23 
     24# (files are: output/3x3/'+CONFIG+'-'+algo+'_1h_'+year+'0101_'+year+'1231_gridT_'+cforcing+'.nc' ) 
    1925cstation = 'ERA5 81N, 36.75E' 
    2026 
     
    7783cf_in = [] 
    7884for ja in range(nb_algos): 
    79     cfi = cdir_data+'/output/3x3/'+CONFIG+'-'+L_ALGOS[ja]+'_1h_'+cy1+'0101_'+cy2+'1231_icemod_'+FORCING+'.nc' 
     85    cfi = cdir_data+'/output/3x3/'+CONFIG+'-'+L_ALGOS[ja]+'_1h_'+cy1+'0101_'+cy2+'1231_icemod_'+cforcing+'.nc' 
    8086    chck4f(cfi) 
    8187    cf_in.append(cfi) 
  • NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/sbcblk_sanity_check.sh

    r13686 r13690  
    2424CONFIG_BLD="STATION_ASF2" ; # name of config as build in NEMO... (directory inside "tests" actually contains the compiled test-case?) 
    2525 
     26# Atmo + SSX forcing to use and sea-ice support? 
     27NFORC="IDEALIZED" ; i_sea_ice=0 ; SFORC="input_output_VALIDATION_IDEALIZED.nc" 
     28 
     29 
    2630# Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists: 
    2731NEMO_REF_DIR="`dirname ${PWD} | sed -e 's|/tests/STATION_ASF||g'`" ; # that should normally do the trick! 
     
    3842 
    3943 
    40 # Atmo + SSX forcing to use and wheter to compute fluxes over sea-ice as well (i_sea_ice=1) 
    41 ############################################################################################# 
    42 i_sea_ice=0 ; # default does not compute fluxes over sea-ice 
    43 NFORC="IDEALIZED" ; i_sea_ice=0 ; FORC="input_output_VALIDATION_IDEALIZED.nc" ; # for now the sanity test does not test ice-atmo bulk parameterizations 
    4444 
    4545 
     
    153153# Copy forcing to work directory: 
    154154echo ; echo "Forcing files to use:" 
    155 \ls -l ${DATA_IN_DIR}/${FORC} 
    156 echo 
    157 rsync -avP ${DATA_IN_DIR}/${FORC} ${PROD_DIR}/ 
     155\ls -l ${DATA_IN_DIR}/${SFORC} 
     156echo 
     157rsync -avP ${DATA_IN_DIR}/${SFORC} ${PROD_DIR}/ 
    158158echo; echo 
    159159 
     
    205205 
    206206cd ${HERE} 
    207 python3 ./analyze_output.py ${DATA_IN_DIR}/${FORC} ${PROD_DIR}/output ${cmore} 
    208  
    209  
     207python3 ./analyze_output.py ${DATA_IN_DIR}/${SFORC} ${PROD_DIR}/output ${cmore} 
     208 
     209 
Note: See TracChangeset for help on using the changeset viewer.