Example #1
0
    print '\n *** Treating box ' + cbox + ' => ', i1, j1, i2 - 1, j2 - 1

    # Filling Convection regions arrays:
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    xsurf = nmp.zeros(ny_b * nx_b)
    xsurf.shape = [ny_b, nx_b]
    xtmp0 = nmp.zeros(ny_b * nx_b)
    xtmp0.shape = [ny_b, nx_b]
    xtmp1 = nmp.zeros(ny_b * nx_b)
    xtmp1.shape = [ny_b, nx_b]
    xtmp2 = nmp.zeros(ny_b * nx_b)
    xtmp2.shape = [ny_b, nx_b]

    bt.chck4f(cf_in)
    print ' Reading SST, SSS and MLD in box ' + cbox + ' in file ' + cf_in
    id_in = Dataset(cf_in)
    if NN_SST == 'thetao':
        xsst = id_in.variables[NN_SST][:, 0, j1:j2, i1:i2]
    else:
        xsst = id_in.variables[NN_SST][:, j1:j2, i1:i2]
    if NN_SSS == 'so':
        xsss = id_in.variables[NN_SSS][:, 0, j1:j2, i1:i2]
    else:
        xsss = id_in.variables[NN_SSS][:, j1:j2, i1:i2]

    xmld = id_in.variables[NN_MLD][:, j1:j2, i1:i2]
    xtpot = id_in.variables[NN_T][:, :, j1:j2, i1:i2]
    xsali = id_in.variables[NN_S][:, :, j1:j2, i1:i2]
    id_in.close()
Example #2
0
CONFRUN = CONF + "-" + RUN
print " CONFRUN = " + CONFRUN
print " CPREF = " + CPREF


# First will read name and coordinates of rectangular boxes to treat into file FILE_DEF_BOXES
##############################################################################################
vboxes, vi1, vj1, vi2, vj2 = bt.read_box_coordinates_in_ascii(FILE_DEF_BOXES)
nbb = len(vboxes)
print ""


# Opening mesh-mask and T-grid file of NEMO:
############################################

bt.chck4f(MM_FILE)
id_mm = Dataset(MM_FILE)
Xmask = id_mm.variables["tmask"][0, :, :, :]
ze1t = id_mm.variables["e1t"][0, :, :]
ze2t = id_mm.variables["e2t"][0, :, :]
id_mm.close()


cf_in = CPREF + cy + "0101_" + cy + "1231_grid_T.nc"
bt.chck4f(cf_in)
id_in = Dataset(cf_in)
Vtime = id_in.variables["time_counter"][:]
Vdepth = id_in.variables["deptht"][:]
Xlon = id_in.variables["nav_lon"][:, :]
Xlat = id_in.variables["nav_lat"][:, :]
Xtheta = id_in.variables[NN_T][:, :, :, :]


# First will read name and coordinates of rectangular boxes to treat into file FILE_DEF_BOXES
##############################################################################################
vboxes, vi1, vj1, vi2, vj2 = bt.read_box_coordinates_in_ascii(FILE_DEF_BOXES)
nbb = len(vboxes)
print ''





# Checking presence of NEMO files:
cfroot = CPREF+cy+'0101_'+cy+'1231'
cf_in_T = cfroot+'_grid_T.nc'; bt.chck4f(cf_in_T, script_name=cname_script)
if luv:
    cf_in_U = cfroot+'_grid_U.nc'; bt.chck4f(cf_in_U, script_name=cname_script)
    cf_in_V = cfroot+'_grid_V.nc'; bt.chck4f(cf_in_V, script_name=cname_script)
    

# Coordinates, mask and metrics:
bt.chck4f(MM_FILE, script_name=cname_script)
id_mm = Dataset(MM_FILE)
Xmask = id_mm.variables['tmask']   [0,:,:,:]
ze1t  = id_mm.variables['e1t']     [0,:,:]
ze2t  = id_mm.variables['e2t']     [0,:,:]
ve3t  = id_mm.variables['e3t_1d']  [0,:]
zlon  = id_mm.variables['nav_lon'] [:,:]
zlat  = id_mm.variables['nav_lat'] [:,:]
vzt   = id_mm.variables['gdept_1d'][0,:]
Example #4
0
os.system("mkdir -p " + path_fig)

# 3D climatology :
# ------------

# Temperature
#    bt.chck4f(vdic['F_T_CLIM_3D_12'])
#    id_clim = Dataset(vdic['F_T_CLIM_3D_12'])
#    Tclim  = id_clim.variables[vdic['NN_T_CLIM']][:,0,:,:]; print '(has ',Tclim.shape[0],' time snapshots)\n'
#    id_clim.close()
#    [ nmn , nk0 , nj0 , ni0 ] = Tclim.shape

# Salinity
if cvar == 'sss':
    bt.chck4f(vdic['F_S_CLIM_3D_12'])
    id_clim = Dataset(vdic['F_S_CLIM_3D_12'])
    SSXclim = id_clim.variables[vdic['NN_S_CLIM']][:, 0, :, :]
    print '(has ', SSXclim.shape[0], ' time snapshots)\n'
    id_clim.close()

# 2D SST obs :
if cvar == 'sst':
    bt.chck4f(vdic['SST_CLIM_12'])
    id_clim_sst = Dataset(vdic['SST_CLIM_12'])
    SSXclim = id_clim_sst.variables[vdic['NN_SST_CLIM']][:, :, :]
    print '(has ', SSXclim.shape[0], ' time snapshots)\n'
    id_clim_sst.close()

[nmn, nj0, ni0] = SSXclim.shape
Example #5
0
if not ( jy1 >= 1984 and jy2 <= 2006 ):
    jy1_clim = 1984 ; jy2_clim = 2006
else:
    jy1_clim = jy1 ;  jy2_clim = jy2

print ' First and last year to treat:', jy1, jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'




# 3D climatology :
# ------------

# Temperature
bt.chck4f(vdic['F_T_OBS_3D_12'])
id_obs = Dataset(vdic['F_T_OBS_3D_12'])
Tobs  = id_obs.variables[vdic['NN_T_OBS']][:,:,:,:]; print '(has ',Tobs.shape[0],' time snapshots)\n'
id_obs.close()
[ nmn , nk0 , nj0 , ni0 ] = Tobs.shape

# Salinity
bt.chck4f(vdic['F_S_OBS_3D_12'])
id_obs = Dataset(vdic['F_S_OBS_3D_12'])
Sobs  = id_obs.variables[vdic['NN_S_OBS']][:,:,:,:]; print '(has ',Sobs.shape[0],' time snapshots)\n'
id_obs.close()


# 2D SST obs :
print 'We use the following SST climatology:'; print vdic['F_SST_OBS_12']
cv_sst_obs = vdic['NN_SST_OBS']
Example #6
0
print ' *** file to read ' + vdic['NN_ICEF'] + ' from: ' + cf_ice + '\n'

if not cvar in ['sst', 'sss', 'ice', 'mld']:
    print 'ERROR (prepare_movies.py): variable ' + cvar + ' not supported yet!'
    sys.exit(0)

path_fig = 'movies'

os.system("mkdir -p " + path_fig)

# 3D climatology :
# ------------

# Salinity
if cvar == 'sss':
    bt.chck4f(vdic['F_S_OBS_3D_12'])
    id_clim = Dataset(vdic['F_S_OBS_3D_12'])
    Vclim = id_clim.variables[vdic['NN_S_OBS']][:, 0, :, :]
    print '(has ', Vclim.shape[0], ' time snapshots)\n'
    id_clim.close()

# 2D SST obs :
if cvar == 'sst':
    cv_sst_obs = vdic['NN_SST_OBS']
    bt.chck4f(vdic['F_SST_OBS_12'])
    id_clim_sst = Dataset(vdic['F_SST_OBS_12'])
    nb_dim = len(id_clim_sst.variables[cv_sst_obs].dimensions)
    if nb_dim == 3:
        Vclim = id_clim_sst.variables[cv_sst_obs][:, :, :]
        print '(has ', Vclim.shape[0], ' time snapshots)\n'
    elif nb_dim == 4:
Example #7
0
path_fig='./'
fig_type='png'



narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'


# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon   = id_mm.variables['glamt'][0,:,:] ; xlat = id_mm.variables['gphit'][0,:,:]
Xmask = id_mm.variables['tmask'][0,0,:,:]
Xe1t = id_mm.variables['e1t'][0,:,:]
Xe2t = id_mm.variables['e2t'][0,:,:]
id_mm.close()


#  Getting NEMO mean monthly climatology of SSH coverage:
cf_nemo_mnmc = vdic['DIAG_D']+'/clim/mclim_'+CONFRUN+'_'+cy1+'-'+cy2+'_grid_T.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
ssh   = id_nemo.variables[vdic['NN_SSH']][:,:,:]
id_nemo.close()
Example #8
0
l_force_lim = True

cfig_type = "png"

path_fig = vdic["DIAG_D"] + "/"

cf_dens_sect = vdic["DENSITY_SECTION_FILE"]
print "  Using cf_dens_sect = " + cf_dens_sect
list_sections = bo.get_sections_names_from_file(cf_dens_sect)
print "List of sections to treat: ", list_sections
nbsec = len(list_sections)


cf_in = vdic["DIAG_D"] + "/transport_by_sigma_class.nc"
bt.chck4f(cf_in)


id_in = Dataset(cf_in)

vtime = id_in.variables["time"][:]
nbm = len(vtime)
vsigma = id_in.variables["sigma_bins"][:]
nbin = len(vsigma)

print "      => " + str(nbin) + " sigma-density bins and " + str(nbm) + " time snapshots..."

if nbm % 12 != 0:
    print "nbm is not a multiple of 12!"
    sys.exit(0)
Example #9
0
elif cdiag == 'seaice':
    idfig = 'ice'
    cyu = r'10$^6$km$^2$'

else:
    print 'ERROR: ' + csn + ' => diagnostic ' + cdiag + ' unknown!'
    sys.exit(0)

##########################################
# Basic temp., sali. and SSH time series #
##########################################

if idfig == 'simple':

    cf_in = 'mean_' + cvar + '_' + CONFRUN + '_global.nc'
    bt.chck4f(cf_in, script_name=csn)
    id_in = Dataset(cf_in)
    vtime = id_in.variables['time'][:]
    nbm = len(vtime)
    vvar = id_in.variables[cvar][:]
    id_in.close()
    nby = __test_nb_years__(nbm, cdiag)

    # Annual data
    VY, FY = bt.monthly_2_annual(vtime[:], vvar[:])

    ittic = bt.iaxe_tick(nbm / 12)

    # Time to plot
    bp.plot("1d_mon_ann")(vtime,
                          VY,
Example #10
0
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'



store_dir = os.getenv('DIAG_D')
if store_dir == '': print 'The DIAG_D environement variable is no set'; sys.exit(0)


# Getting coordinates:
bt.chck4f(cf_mesh_mask)
id_mm = Dataset(cf_mesh_mask)
xlat = id_mm.variables['gphit'][0,:,:]
xlon = id_mm.variables['glamt'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
#vlev  = id_mm.variables['gdept_1d'][0,:]
id_mm.close()


[ nk, nj, ni ] = nmp.shape(Xmask)


# Getting basin mask:
bt.chck4f(cf_basin_mask)
id_bm = Dataset(cf_basin_mask)
Xmask_atl = id_bm.variables['tmaskatl'][:,:]
Example #11
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <year1> <year2>'
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)

jy1_clim = jy1
jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

# Getting coordinates and mask :
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon = id_mm.variables['nav_lon'][:, :]
xlat = id_mm.variables['nav_lat'][:, :]
xmask = id_mm.variables['tmask'][0, 0, :, :]
id_mm.close()

# Getting obs:
bt.chck4f(vdic['ICE_CLIM_12'])
id_clim = Dataset(vdic['ICE_CLIM_12'])
xclim03 = id_clim.variables[vdic['NN_ICEF_CLIM']][2, :, :]
xclim09 = id_clim.variables[vdic['NN_ICEF_CLIM']][8, :, :]
id_clim.close()

#  Getting NEMO mean monthly climatology of sea-ice coverage:
cf_nemo_mnmc = vdic[
Example #12
0


narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'



# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon   = id_mm.variables['glamt'][0,:,:] ; xlat = id_mm.variables['gphit'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
vlev  = id_mm.variables['gdept_1d'][0,:]
id_mm.close()

nk = len(vlev)



#  Getting NEMO mean monthly climatology of MLD coverage:
cf_nemo_mnmc = vdic['DIAG_D']+'/clim/mclim_'+CONFRUN+'_'+cy1+'-'+cy2+'_grid_T.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
Example #13
0
cf_in  = sys.argv[1]
cv_in  = sys.argv[2]

cn_file, cn_ext = splitext(cf_in)

print cn_ext

cn_file = rplc(cn_file, cv_in+'_', '')
print cn_file

print "\n"



bt.chck4f(cf_in) ; f_in = Dataset(cf_in)

# Extracting the longitude and 1D array:
vlon     = f_in.variables['lon'][:]
cunt_lon = f_in.variables['lon'].units
print 'LONGITUDE: ', cunt_lon

# Extracting the longitude 1D array:
vlat     = f_in.variables['lat'][:]
cunt_lat = f_in.variables['lat'].units
print 'LATITUDE: ', cunt_lat

# Extracting time 1D array:
vtime     = f_in.variables['time'][:] ; cunt_time = f_in.variables['time'].units
print 'TIME: ', cunt_time, '\n'
Example #14
0
if not ( jy1 >= 1984 and jy2 <= 2006 ):
    jy1_clim = 1984 ; jy2_clim = 2006
else:
    jy1_clim = jy1 ;  jy2_clim = jy2

print ' First and last year to treat:', jy1, jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'




# 3D climatology :
# ------------

# Temperature
bt.chck4f(vdic['F_T_CLIM_3D_12'])
id_clim = Dataset(vdic['F_T_CLIM_3D_12'])
Tclim  = id_clim.variables[vdic['NN_T_CLIM']][:,:,:,:]; print '(has ',Tclim.shape[0],' time snapshots)\n'
id_clim.close()
[ nmn , nk0 , nj0 , ni0 ] = Tclim.shape

# Salinity
bt.chck4f(vdic['F_S_CLIM_3D_12'])
id_clim = Dataset(vdic['F_S_CLIM_3D_12'])
Sclim  = id_clim.variables[vdic['NN_S_CLIM']][:,:,:,:]; print '(has ',Sclim.shape[0],' time snapshots)\n'
id_clim.close()




# 2D SST obs :
Example #15
0
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'



store_dir = os.getenv('DIAG_D')
if store_dir == '': print 'The DIAG_D environement variable is no set'; sys.exit(0)


# Getting coordinates:
bt.chck4f(cf_mesh_mask)
id_mm = Dataset(cf_mesh_mask)
xlon   = id_mm.variables['glamt'][0,:,:] ; xlat = id_mm.variables['gphit'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
vlev  = id_mm.variables['gdept_1d'][0,:]
id_mm.close()

nk = len(vlev)



#  Getting NEMO mean monthly climatology of RNF coverage:
cf_nemo_mnmc = DIAG_D+'/clim/mclim_'+CONFRUN+'_'+cy1+'-'+cy2+'_SBC.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
Example #16
0
cn_file, cn_ext = splitext(cf_in)
#cn_file = replace(cn_file, cv_in+'_', '')
cpath = '.'
if dirname(cf_in) != '': cpath=dirname(cf_in)
cf_out = cpath+'/zonal_'+basename(cn_file)+'.nc'
#print ' *[mk_zonal_average.py]* file to write: ', cf_out ; sys.exit(0)

l_msk_from_val = False
if cf_msk in [ 'value', 'val', 'Value' ]:
    l_msk_from_val = True
    rmv = float(cv_msk)
    print ' *[mk_zonal_average.py]* mask is where '+cv_in+' == '+str(rmv)


else:
    bt.chck4f(cf_msk)
    f_msk = Dataset(cf_msk)
    Ndim = len(f_msk.variables[cv_msk].dimensions)
    if   Ndim == 4:
        xmsk = f_msk.variables[cv_msk][0,0,:,:]
    elif Ndim == 3:
        xmsk = f_msk.variables[cv_msk][0,:,:]
    elif Ndim == 2:
        xmsk = f_msk.variables[cv_msk][:,:]
    else:
        print ' ERROR (mk_zonal_average.py) => weird shape for your mask array!'
        sys.exit(0)    
    f_msk.close()


if cv_in == 'sosstsst':
    cfield = 'SST'
    tmin=-2. ;  tmax=32.   ;  dtemp = 1.
    cpal_fld = 'ncview_nrl'    
    cunit = r'$^{\circ}C$'
    cb_jump = 2
    
elif cv_in == 'somxl010':
    cfield == 'MLD'
    tmin=50. ;  tmax=1500. ;  dtemp = 50.
    cpal_fld = 'viridis_r'
    

#bt.chck4f(cf_ice)

bt.chck4f(cf_in)
id_fld = Dataset(cf_in)
vtime = id_fld.variables['time_counter'][:]
id_fld.close()
Nt = len(vtime)

if jtN > Nt: print 'ERROR: your jtN > Nt !!!'; sys.exit(0)
if jtN == 0: jtN = Nt


bt.chck4f(cf_lsm)
id_lsm = Dataset(cf_lsm)
#LOLO for curl => F !!!
if lforce_mask: XMSK  = id_lsm.variables['fmask'][0,0,:,:]
XLON  =  id_lsm.variables['glamf'][0,:,:]
XLAT  =  id_lsm.variables['gphif'][0,:,:]
Example #18
0
path_fig = vdic['DIAG_D'] + '/'

# Image type? eps, png, jpg...
#FIG_FORM = 'pdf'
FIG_FORM = 'png'

# First will read name and coordinates of rectangular boxes to treat into file FILE_DEF_BOXES
##############################################################################################
vboxes, vi1, vj1, vi2, vj2 = bt.read_coor(vdic['FILE_DEF_BOXES'])
nbb = len(vboxes)
print ''

# Checking presence of NEMO files:
cfroot = vdic['CPREF'] + cy + '0101_' + cy + '1231'
cf_in_T = cfroot + '_grid_T.nc'
bt.chck4f(cf_in_T, script_name=cname_script)
if luv:
    cf_in_U = cfroot + '_grid_U.nc'
    bt.chck4f(cf_in_U, script_name=cname_script)
    cf_in_V = cfroot + '_grid_V.nc'
    bt.chck4f(cf_in_V, script_name=cname_script)

# Coordinates, mask and metrics:
bt.chck4f(vdic['MM_FILE'], script_name=cname_script)
id_mm = Dataset(vdic['MM_FILE'])
Xmask = id_mm.variables['tmask'][0, :, :, :]
ze1t = id_mm.variables['e1t'][0, :, :]
ze2t = id_mm.variables['e2t'][0, :, :]
ve3t = id_mm.variables['e3t_1d'][0, :]
zlon = id_mm.variables['nav_lon'][:, :]
zlat = id_mm.variables['nav_lat'][:, :]
Example #19
0
    list_sections = bo.get_sections_names_from_file(vdic['TRANSPORT_SECTION_FILE'])
    print 'List of sections to treat: ', list_sections
    nbsect = len(list_sections)

    vstuff = [ 'volume', 'heat' , 'salt' ]
    vunit  = [ 'Sv'    , 'PW'   , 'kt/s' ]


    jrun = 0
    for confrun in clist_confruns:

        jsect=0
        for csect in list_sections:
            print '\n Treating transports through '+csect

            cf_in = cd_diag+'/'+confrun+'/transport_sect_'+csect+'.nc' ; bt.chck4f(cf_in, script_name='compare_time_series.py')
            id_in = Dataset(cf_in)
            if jsect == 0:
                if jrun == 0:
                    vtime = nmp.zeros(nb_years*12)
                    vyear = nmp.zeros(nb_years)
                    Xtrsp = nmp.zeros((nbrun,nbsect,3,nb_years))

                vtime_t = id_in.variables['time'][:] ; nbm = len(vtime_t) ; nby = nbm/12
                test_nb_mnth_rec(nbm, nb_years, cdiag)

                if nby == nb_years: vtime[:] = vtime_t[:]

            Xtrsp[jrun,jsect,:,:] = -999.
            vyear[:nby], Xtrsp[jrun,jsect,0,:nby] = bt.monthly_2_annual(vtime_t, id_in.variables['trsp_volu'][:nbm])
            vyear[:nby], Xtrsp[jrun,jsect,1,:nby] = bt.monthly_2_annual(vtime_t, id_in.variables['trsp_heat'][:nbm])
    sys.exit(0)
cf_u  = sys.argv[1]
cf_v  = string.replace(cf_u, cv_u, cv_v)
cf_wm = basename(string.replace(cf_u, cv_u, cv_wm))


if len(sys.argv) == 3:
    cvy = sys.argv[2]
    iyear = int(cvy)

#print iyear ; sys.exit(0)


# First need time length:

bt.chck4f(cf_u) ; f_u_in = Dataset(cf_u)
vlon     = f_u_in.variables['lon'][:]
cunt_lon = f_u_in.variables['lon'].units
print 'LONGITUDE: ', cunt_lon
# Extracting the longitude 1D array:
vlat     = f_u_in.variables['lat'][:]
cunt_lat = f_u_in.variables['lat'].units
print 'LATITUDE: ', cunt_lat

# Extracting time 1D array:
vtime     = f_u_in.variables['time'][:] ; cunt_time = f_u_in.variables['time'].units
print 'TIME: ', cunt_time, '\n'
f_u_in.close()


Example #21
0
    idfig = 'ice'
    cyu  = r'10$^6$km$^2$'

else:
    print 'ERROR: '+csn+' => diagnostic '+cdiag+' unknown!'; sys.exit(0)




############################################################# 
# Time series of 2D-averaged  2D fields such as SST, SSS, SSH
#############################################################

if idfig == 'simple':

    cf_in = 'mean_'+cvar+'_'+CONFEXP+'_GLO.nc' ;  bt.chck4f(cf_in, script_name=csn)
    id_in = Dataset(cf_in)
    vtime = id_in.variables['time'][:]
    vvar  = id_in.variables[cvar][:]
    id_in.close()
    (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)

    # Annual data
    VY, FY = bt.monthly_2_annual(vtime[:], vvar[:])

    # Time to plot
    bp.plot("1d_mon_ann")(vtime, VY, vvar, FY, cfignm=cdiag+'_'+CONFEXP, dt=ittic,
                          cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)

    if cvar == vdic['NN_SSH']:
        clnm = 'Global freshwater imbalance based on annual SSH drift'
if len(sys.argv) < 2 and len(sys.argv) > 3:
    print 'Usage: ' + sys.argv[0] + ' <IN_FILE_U.nc> (Year)'
    sys.exit(0)
cf_u = sys.argv[1]
cf_v = string.replace(cf_u, cv_u, cv_v)
cf_wm = basename(string.replace(cf_u, cv_u, cv_wm))

if len(sys.argv) == 3:
    cvy = sys.argv[2]
    iyear = int(cvy)

#print iyear ; sys.exit(0)

# First need time length:

bt.chck4f(cf_u)
f_u_in = Dataset(cf_u)
vlon = f_u_in.variables['lon'][:]
cunt_lon = f_u_in.variables['lon'].units
print 'LONGITUDE: ', cunt_lon
# Extracting the longitude 1D array:
vlat = f_u_in.variables['lat'][:]
cunt_lat = f_u_in.variables['lat'].units
print 'LATITUDE: ', cunt_lat

# Extracting time 1D array:
vtime = f_u_in.variables['time'][:]
cunt_time = f_u_in.variables['time'].units
print 'TIME: ', cunt_time, '\n'
f_u_in.close()
Example #23
0
elif cdiag == 'seaice':
    idfig = 'ice'
    cyu = r'10$^6$km$^2$'

else:
    print 'ERROR: plot_time_series.py => diagnostic ' + cdiag + ' unknown!'
    sys.exit(0)

##########################################
# Basic temp., sali. and SSH time series #
##########################################

if idfig == 'simple':

    cf_in = 'mean_' + cvar + '_' + CONFRUN + '_global.nc'
    bt.chck4f(cf_in, script_name='plot_time_series.py')
    id_in = Dataset(cf_in)
    vtime = id_in.variables['time'][:]
    nbm = len(vtime)
    vvar = id_in.variables[cvar][:]
    id_in.close()

    if nbm % 12 != 0:
        print 'ERROR: plot_time_series.py => ' + cvar + ', number of records not a multiple of 12!'
        sys.exit(0)

    # Annual data
    VY, FY = bt.monthly_2_annual(vtime[:], vvar[:])

    ittic = bt.iaxe_tick(nbm / 12)
Example #24
0

cn_obs = vdic['NM_IC_OBS']

narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'


# Getting coordinates and mask :
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon    = id_mm.variables['nav_lon'][:,:]
xlat    = id_mm.variables['nav_lat'][:,:]
xmask   = id_mm.variables['tmask'][0,0,:,:]
id_mm.close()


# Getting obs:
bt.chck4f(vdic['F_ICE_OBS_12'])
id_clim = Dataset(vdic['F_ICE_OBS_12'])
xclim03 = id_clim.variables[vdic['NN_ICEF_OBS']][2,:,:]
xclim09 = id_clim.variables[vdic['NN_ICEF_OBS']][8,:,:]
id_clim.close()

Example #25
0
    nx_b = i2 - i1
    ny_b = j2 - j1
    
    print '\n *** Treating box '+cbox+' => ', i1, j1, i2-1, j2-1
    

    # Filling Convection regions arrays:
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    xsurf    = nmp.zeros(ny_b*nx_b) ;     xsurf.shape = [ ny_b, nx_b ]
    xtmp0    = nmp.zeros(ny_b*nx_b) ;    xtmp0.shape = [ ny_b, nx_b ]    
    xtmp1    = nmp.zeros(ny_b*nx_b) ;    xtmp1.shape = [ ny_b, nx_b ]
    xtmp2    = nmp.zeros(ny_b*nx_b) ;    xtmp2.shape = [ ny_b, nx_b ]


    bt.chck4f(cf_in)
    print ' Reading SST, SSS and MLD in box '+cbox+' in file '+cf_in
    id_in = Dataset(cf_in)
    if NN_SST == 'thetao':
        xsst  = id_in.variables[NN_SST][:,0,j1:j2,i1:i2]
    else:
        xsst  = id_in.variables[NN_SST][:,j1:j2,i1:i2]
    if NN_SSS == 'so':
        xsss  = id_in.variables[NN_SSS][:,0,j1:j2,i1:i2]
    else:
        xsss  = id_in.variables[NN_SSS][:,j1:j2,i1:i2]
        
    xmld  = id_in.variables[NN_MLD][:,j1:j2,i1:i2]
    xtpot = id_in.variables[NN_T][:,:,j1:j2,i1:i2]
    xsali = id_in.variables[NN_S][:,:,j1:j2,i1:i2]
    id_in.close()
Example #26
0

# 3D climatology :
# ------------

# Temperature
#    bt.chck4f(vdic['F_T_CLIM_3D_12'])
#    id_clim = Dataset(vdic['F_T_CLIM_3D_12'])
#    Tclim  = id_clim.variables[vdic['NN_T_CLIM']][:,0,:,:]; print '(has ',Tclim.shape[0],' time snapshots)\n'
#    id_clim.close()
#    [ nmn , nk0 , nj0 , ni0 ] = Tclim.shape


# Salinity
if cvar == 'sss':
    bt.chck4f(vdic['F_S_CLIM_3D_12'])
    id_clim = Dataset(vdic['F_S_CLIM_3D_12'])
    Vclim  = id_clim.variables[vdic['NN_S_CLIM']][:,0,:,:]; print '(has ',Vclim.shape[0],' time snapshots)\n'
    id_clim.close()

# 2D SST obs :
if cvar == 'sst':
    bt.chck4f(vdic['SST_CLIM_12'])
    id_clim_sst = Dataset(vdic['SST_CLIM_12'])
    Vclim  = id_clim_sst.variables[vdic['NN_SST_CLIM']][:,:,:]; print '(has ',Vclim.shape[0],' time snapshots)\n'
    id_clim_sst.close()

# Sea-ice concentration :
# => no clim used!
if cvar == 'sss' or cvar == 'sst': [ nmn , nj0 , ni0 ] = Vclim.shape
Example #27
0
if DIAG_DIR == None: print 'The DIAG_DIR environement variable is no set'; sys.exit(0)

print '\n '+sys.argv[0]+':'


narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <RUN1> <RUN2>'; sys.exit(0)
crun1 = sys.argv[1] ; crun2=sys.argv[2]

CONFRUN1 = ORCA+'-'+crun1 ; print CONFRUN1
CONFRUN2 = ORCA+'-'+crun2 ; print CONFRUN2


# Getting coordinates and mask
cf_mask = MM_FILE ; print 'Reading coordinates into '+cf_mask
bt.chck4f(cf_mask)
id_mask = Dataset(cf_mask)
mask  = id_mask.variables['tmask'][0,:,:,:]
xlon   = id_mask.variables['nav_lon'][:,:] ; xlat   = id_mask.variables['nav_lat'][:,:]
id_mask.close()


[ nk, nj, ni ] = nmp.shape(mask)


# Getting basin mask:
cf_basin_mask = BM_FILE
bt.chck4f(cf_basin_mask)
id_bm = Dataset(cf_basin_mask)
Xmask_atl = id_bm.variables['tmaskatl'][:,:,:]
id_bm.close()
Example #28
0
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'



store_dir = os.getenv('DIAG_D')
if store_dir == '': print 'The DIAG_D environement variable is no set'; sys.exit(0)


# Getting coordinates:
bt.chck4f(cf_mesh_mask)
id_mm = Dataset(cf_mesh_mask)
xlon   = id_mm.variables['glamt'][0,:,:] ; xlat = id_mm.variables['gphit'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
vlev  = id_mm.variables['gdept_1d'][0,:]
id_mm.close()

nk = len(vlev)



#  Getting NEMO mean monthly climatology of MLD coverage:
cf_nemo_mnmc = DIAG_D+'/clim/mclim_'+CONFRUN+'_'+cy1+'-'+cy2+'_grid_T.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
Example #29
0
    cpal_fld = 'on2'
    tmin = -1.2
    tmax = 1.2
    df = 0.05
    l_apply_lap = True
    cunit = r'SSH (m)'
    cb_jump = 1

elif cv_in == 'somxl010':
    cfield == 'MLD'
    tmin = 50.
    tmax = 1500.
    df = 50.
    cpal_fld = 'viridis_r'

if l_do_ice: bt.chck4f(cf_ice)

bt.chck4f(cf_in)
id_fld = Dataset(cf_in)
vtime = id_fld.variables['time_counter'][:]
id_fld.close()
Nt = len(vtime)

if l_show_lsm or l_apply_lap:
    bt.chck4f(cf_lsm)
    id_lsm = Dataset(cf_lsm)
    nb_dim = len(id_lsm.variables['tmask'].dimensions)
    if l_show_lsm:
        if nb_dim == 4: XMSK = id_lsm.variables['tmask'][0, 0, j1:j2, i1:i2]
        if nb_dim == 3: XMSK = id_lsm.variables['tmask'][0, j1:j2, i1:i2]
        if nb_dim == 2: XMSK = id_lsm.variables['tmask'][j1:j2, i1:i2]
Example #30
0
if not ( jy1 >= 1984 and jy2 <= 2006 ):
    jy1_clim = 1984 ; jy2_clim = 2006
else:
    jy1_clim = jy1 ;  jy2_clim = jy2

print ' First and last year to treat:', jy1, jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'




# 3D climatology :
# ------------

# Temperature
bt.chck4f(F_T_CLIM_3D_12) ; id_clim = Dataset(F_T_CLIM_3D_12)
Tclim  = id_clim.variables[NN_T_CLIM][:,:,:,:]; print '(has ',Tclim.shape[0],' time snapshots)\n'
id_clim.close()
[ nmn , nk0 , nj0 , ni0 ] = Tclim.shape

# Salinity
bt.chck4f(F_S_CLIM_3D_12) ; id_clim = Dataset(F_S_CLIM_3D_12)
Sclim  = id_clim.variables[NN_S_CLIM][:,:,:,:]; print '(has ',Sclim.shape[0],' time snapshots)\n'
id_clim.close()




# 2D SST obs :
# ------------
print 'We use the following SST climatology:'; print SST_CLIM_12
Example #31
0
path_fig='./'
fig_type='png'


narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'


# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlat = id_mm.variables['gphit'][0,:,:]
xlon = id_mm.variables['glamt'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
id_mm.close()


[ nk, nj, ni ] = nmp.shape(Xmask)


# Getting basin mask:
bt.chck4f(vdic['BM_FILE'])
id_bm = Dataset(vdic['BM_FILE'])
Xmask_atl = id_bm.variables['tmaskatl'][:,:]
id_bm.close()
Example #32
0
fig_type='png'



narg = len(sys.argv)
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'


# Getting coordinates and mask :
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon    = id_mm.variables['nav_lon'][:,:]
xlat    = id_mm.variables['nav_lat'][:,:]
xmask   = id_mm.variables['tmask'][0,0,:,:]
id_mm.close()


# Getting obs:
bt.chck4f(vdic['ICE_CLIM_12'])
id_clim = Dataset(vdic['ICE_CLIM_12'])
xclim03 = id_clim.variables[vdic['NN_ICEF_CLIM']][2,:,:]
xclim09 = id_clim.variables[vdic['NN_ICEF_CLIM']][8,:,:]
id_clim.close()

Example #33
0
vMLD_crit = []
vv = vdic['MLD_CRIT'].split(',')
for cv in vv: vMLD_crit.append(float(cv))
print "\n All the z_crit to use:", vMLD_crit[:]




# First will read name and coordinates of rectangular boxes to treat into file FILE_DMV_BOXES
##############################################################################################
vboxes, vi1, vj1, vi2, vj2 = bt.read_coor(vdic['FILE_DMV_BOXES'])
nbb = len(vboxes)
print ''


bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
zmask_orca = id_mm.variables['tmask'][0,0,:,:]
ze1t_orca  = id_mm.variables['e1t']    [0,:,:]
ze2t_orca  = id_mm.variables['e2t']    [0,:,:]
id_mm.close()


bt.chck4f(cf_in)
id_in = Dataset(cf_in)
Xmld_orca  = id_in.variables[vdic['NN_MLD']][:,:,:]
print '(has ',Xmld_orca.shape[0],' time snapshots)\n'
xlat   = id_in.variables['nav_lat'][:,:]
id_in.close()

Example #34
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <year1> <year2>'
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)

jy1_clim = jy1
jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlat = id_mm.variables['gphit'][0, :, :]
xlon = id_mm.variables['glamt'][0, :, :]
Xmask = id_mm.variables['tmask'][0, :, :, :]
id_mm.close()

[nk, nj, ni] = nmp.shape(Xmask)

# Getting basin mask:
bt.chck4f(vdic['BM_FILE'])
id_bm = Dataset(vdic['BM_FILE'])
Xmask_atl = id_bm.variables['tmaskatl'][:, :]
id_bm.close()

for jk in range(nk):
Example #35
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <year1> <year2>'
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)

jy1_clim = jy1
jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon = id_mm.variables['glamt'][0, :, :]
xlat = id_mm.variables['gphit'][0, :, :]
Xmask = id_mm.variables['tmask'][0, :, :, :]
vlev = id_mm.variables['gdept_1d'][0, :]
id_mm.close()

nk = len(vlev)

#  Getting NEMO mean monthly climatology of MLD coverage:
cf_nemo_mnmc = vdic[
    'DIAG_D'] + '/clim/mclim_' + CONFRUN + '_' + cy1 + '-' + cy2 + '_grid_T.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
Example #36
0
print " cf_crl = ", cf_crl
print "\n"

rmult = 1.

if cv_Vx == 'EWSS':
    rmult = 1000.
    CUNIT_CRL = '???'

if cv_Vx == 'U10M':
    rmult = 1.
    CUNIT_CRL = 's^-1'

#  TAUY
#  ~~~~
bt.chck4f(cf_Vy)

f_Vy_in = Dataset(cf_Vy)

# Extracting the longitude and 1D array:
vlon = f_Vy_in.variables['lon'][:]
clnm_lon = f_Vy_in.variables['lon'].long_name
cunt_lon = f_Vy_in.variables['lon'].units
csnm_lon = f_Vy_in.variables['lon'].standard_name
print 'LONGITUDE: ', clnm_lon, cunt_lon, csnm_lon

# Extracting the longitude 1D array:
vlat = f_Vy_in.variables['lat'][:]
clnm_lat = f_Vy_in.variables['lat'].long_name
cunt_lat = f_Vy_in.variables['lat'].units
csnm_lat = f_Vy_in.variables['lat'].standard_name
Example #37
0
print ' CONF = ' + CONF
print ' RUN = ' + RUN
CONFRUN = CONF + '-' + RUN
print ' CONFRUN = ' + CONFRUN
print ' CPREF = ' + CPREF

# First will read name and coordinates of rectangular boxes to treat into file FILE_DEF_BOXES
##############################################################################################
vboxes, vi1, vj1, vi2, vj2 = bt.read_box_coordinates_in_ascii(FILE_DEF_BOXES)
nbb = len(vboxes)
print ''

# Opening mesh-mask and T-grid file of NEMO:
############################################

bt.chck4f(MM_FILE)
id_mm = Dataset(MM_FILE)
Xmask = id_mm.variables['tmask'][0, :, :, :]
ze1t = id_mm.variables['e1t'][0, :, :]
ze2t = id_mm.variables['e2t'][0, :, :]
id_mm.close()

cf_in = CPREF + cy + '0101_' + cy + '1231_grid_T.nc'
bt.chck4f(cf_in)
id_in = Dataset(cf_in)
Vtime = id_in.variables['time_counter'][:]
Vdepth = id_in.variables['deptht'][:]
Xlon = id_in.variables['nav_lon'][:, :]
Xlat = id_in.variables['nav_lat'][:, :]
Xtheta = id_in.variables[NN_T][:, :, :, :]
Xsali = id_in.variables[NN_S][:, :, :, :]
Example #38
0








##########################################
# Basic temp., sali. and SSH time series #
##########################################

if idfig == 'simple':

    cf_in = 'mean_'+cvar+'_'+CONFRUN+'_global.nc' ;  bt.chck4f(cf_in, script_name='plot_time_series.py')
    id_in = Dataset(cf_in)
    vtime = id_in.variables['time'][:] ; nbm = len(vtime)
    vvar  = id_in.variables[cvar][:]
    id_in.close()

    if nbm%12 != 0: print 'ERROR: plot_time_series.py => '+cvar+', numberof records not a multiple of 12!', sys.exit(0)

    # Annual data
    VY, FY = bt.monthly_2_annual(vtime[:], vvar[:])

    ittic = bt.iaxe_tick(nbm/12)

    # Time to plot
    bp.plot("1d_mon_ann")(vtime, VY, vvar, FY, cfignm=cdiag+'_'+CONFRUN, dt_year=ittic,
                          cyunit=cyu, ctitle = CONFRUN+': '+clnm, ymin=ym, ymax=yp)
Example #39
0
#if narg != 2: print 'Usage: '+sys.argv[0]+' <diag>'; sys.exit(0)
#cdiag = sys.argv[1]
#print '\n plot_time_series.py: diag => "'+cdiag+'"'

v_var_names = [
    'msl', 'tas', 'totp', 'NetTOA', 'NetSFC', 'PminE', 'e', 'tcc', 'PminE',
    'tsr', 'ssr'
]
nbvar = len(v_var_names)

v_var_units = nmp.zeros(nbvar, dtype=nmp.dtype('a8'))
v_var_lngnm = nmp.zeros(nbvar, dtype=nmp.dtype('a64'))

print '\n *** plot_atmo_time_series.py => USING time series in ' + SUPA_FILE

bt.chck4f(SUPA_FILE)

# Reading all var in netcdf file:

id_clim = Dataset(SUPA_FILE)

vtime = id_clim.variables['time'][:]

nbr = len(vtime)

XX = nmp.zeros(nbvar * nbr)
XX.shape = [nbvar, nbr]

for jv in range(nbvar):
    print ' **** reading ' + v_var_names[jv]
    XX[jv, :] = id_clim.variables[v_var_names[jv]][:]
Example #40
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <year1> <year2>'
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)
jy1_clim = jy1
jy2_clim = jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

ctag = CONFEXP + '_' + cy1 + '-' + cy2

# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon = id_mm.variables['glamt'][0, :, :]
xlat = id_mm.variables['gphit'][0, :, :]
Xmask = id_mm.variables['tmask'][0, 0, :, :]
id_mm.close()

l_tau_is_annual = False
cf_nemo_curl = cd_clim + '/mclim_' + ctag + '_TCURL.nc4'

if not path.exists(cf_nemo_curl):
    cf_nemo_curl = cd_clim + '/aclim_' + ctag + '_TCURL.nc4'
    if path.exists(cf_nemo_curl):
        l_tau_is_annual = True
        print '\n *** wind.py : wind stress is annual...'
    else:
Example #41
0
        vdic['TRANSPORT_SECTION_FILE'])
    print 'List of sections to treat: ', list_sections
    nbsect = len(list_sections)

    vstuff = ['volume', 'heat', 'salt']
    vunit = ['Sv', 'PW', 'kt/s']

    jrun = 0
    for confrun in clist_confruns:

        jsect = 0
        for csect in list_sections:
            print '\n Treating transports through ' + csect

            cf_in = cd_diag + '/' + confrun + '/transport_sect_' + csect + '.nc'
            bt.chck4f(cf_in, script_name='compare_time_series.py')
            id_in = Dataset(cf_in)
            if jsect == 0:
                if jrun == 0:
                    vtime = nmp.zeros(nb_years * 12)
                    vyear = nmp.zeros(nb_years)
                    Xtrsp = nmp.zeros((nbrun, nbsect, 3, nb_years))

                vtime_t = id_in.variables['time'][:]
                nbm = len(vtime_t)
                nby = nbm / 12
                test_nb_mnth_rec(nbm, nb_years, cdiag)

                if nby == nb_years: vtime[:] = vtime_t[:]

            Xtrsp[jrun, jsect, :, :] = -999.
Example #42
0
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)
jy1_clim = jy1
jy2_clim = jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

ctag = CONFEXP + '_' + cy1 + '-' + cy2

ct_nemo = vdic['FILE_FLX_SUFFIX']
# (SBC or grid_T, ect.)

# Getting coordinates and mask:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon = id_mm.variables['glamt'][0, :, :]
xlat = id_mm.variables['gphit'][0, :, :]
Xmask = id_mm.variables['tmask'][0, 0, :, :]
id_mm.close()

#  Getting NEMO mean monthly climatology surface flux:
cextra_qsol = ''
cv_qsol = vdic['NN_QSOL']
if cv_qsol != 'X':
    cf_nemo_qsol = cd_clim + '/mclim_' + ctag + '_' + ct_nemo + '.nc4'
else:
    print '\n *** WARNING: sfluxes.py : if no "NN_QSOL" ! No sfluxes.py! Aborting !!!\n'
    sys.exit(0)
Example #43
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <year1> <year2>'
    sys.exit(0)
cy1 = sys.argv[1]
cy2 = sys.argv[2]
jy1 = int(cy1)
jy2 = int(cy2)

jy1_clim = jy1
jy2_clim = jy2
print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'

# Getting coordinates:
bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
xlon = id_mm.variables['glamt'][0, :, :]
xlat = id_mm.variables['gphit'][0, :, :]
Xmask = id_mm.variables['tmask'][0, 0, :, :]
Xe1t = id_mm.variables['e1t'][0, :, :]
Xe2t = id_mm.variables['e2t'][0, :, :]
id_mm.close()

#  Getting NEMO mean monthly climatology of SSH coverage:
cf_nemo_mnmc = vdic[
    'DIAG_D'] + '/clim/mclim_' + CONFEXP + '_' + cy1 + '-' + cy2 + '_grid_T.nc4'

bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
ssh = id_nemo.variables[vdic['NN_SSH']][:, :, :]
Example #44
0
narg = len(sys.argv)
if narg < 3:
    print 'Usage: ' + sys.argv[0] + ' <RUN1> <RUN2>'
    sys.exit(0)
crun1 = sys.argv[1]
crun2 = sys.argv[2]

CONFRUN1 = ORCA + '-' + crun1
print CONFRUN1
CONFRUN2 = ORCA + '-' + crun2
print CONFRUN2

# Getting coordinates and mask
cf_mask = MM_FILE
print 'Reading coordinates into ' + cf_mask
bt.chck4f(cf_mask)
id_mask = Dataset(cf_mask)
mask = id_mask.variables['tmask'][0, :, :, :]
xlon = id_mask.variables['nav_lon'][:, :]
xlat = id_mask.variables['nav_lat'][:, :]
id_mask.close()

[nk, nj, ni] = nmp.shape(mask)

# Getting basin mask:
cf_basin_mask = BM_FILE
bt.chck4f(cf_basin_mask)
id_bm = Dataset(cf_basin_mask)
Xmask_atl = id_bm.variables['tmaskatl'][:, :, :]
id_bm.close()
Example #45
0
cf_in  = sys.argv[1]
cyear  = sys.argv[2] ; jyear = int(cyear); cyear = '%4.4i'%jyear


cv_sst = vdic['NN_SST']
cv_sss = vdic['NN_SSS']

if na == 5:
    cv_sst = sys.argv[3]
    cv_sss = sys.argv[4]


print 'Current year is '+cyear+' !\n'


bt.chck4f(vdic['MM_FILE'])
id_mm = Dataset(vdic['MM_FILE'])
rmsk = id_mm.variables['tmask'][0,0,:,:]
rlon = id_mm.variables['glamt'][0,:,:]
rlat = id_mm.variables['gphit'][0,:,:]
Xe1t = id_mm.variables['e1t'][0,:,:]
Xe2t = id_mm.variables['e2t'][0,:,:]
id_mm.close()



[ nj, ni ] = rmsk.shape



bt.chck4f(cf_in)
Example #46
0
cv_d2 = 'D2M'
cv_p0 = 'MSL'
cv_q2 = 'Q2M'
# OUTPUT !

if len(sys.argv) != 2:
    print 'Usage: ' + sys.argv[0] + ' <IN_FILE_D2.nc>'
    sys.exit(0)

cf_d2 = sys.argv[1]
cf_p0 = string.replace(cf_d2, cv_d2, cv_p0)
cf_q2 = basename(string.replace(cf_d2, cv_d2, cv_q2))

# First need time length:

bt.chck4f(cf_d2)
f_d2_in = Dataset(cf_d2)
vlon = f_d2_in.variables['lon'][:]
cunt_lon = f_d2_in.variables['lon'].units
print 'LONGITUDE: ', cunt_lon
# Extracting the longitude 1D array:
vlat = f_d2_in.variables['lat'][:]
cunt_lat = f_d2_in.variables['lat'].units
print 'LATITUDE: ', cunt_lat

# Extracting time 1D array:
vtime = f_d2_in.variables['time'][:]
cunt_time = f_d2_in.variables['time'].units
print 'TIME: ', cunt_time, '\n'
f_d2_in.close()
cv_q2='Q2M' ; # OUTPUT !


if len(sys.argv) != 2:
    print 'Usage: '+sys.argv[0]+' <IN_FILE_D2.nc>'
    sys.exit(0)

cf_d2   = sys.argv[1]
cf_p0 = string.replace(cf_d2, cv_d2, cv_p0)
cf_q2 = basename(string.replace(cf_d2, cv_d2, cv_q2))



# First need time length:

bt.chck4f(cf_d2) ; f_d2_in = Dataset(cf_d2)
vlon     = f_d2_in.variables['lon'][:]
cunt_lon = f_d2_in.variables['lon'].units
print 'LONGITUDE: ', cunt_lon
# Extracting the longitude 1D array:
vlat     = f_d2_in.variables['lat'][:]
cunt_lat = f_d2_in.variables['lat'].units
print 'LATITUDE: ', cunt_lat

# Extracting time 1D array:
vtime     = f_d2_in.variables['time'][:] ; cunt_time = f_d2_in.variables['time'].units
print 'TIME: ', cunt_time, '\n'
f_d2_in.close()


Example #48
0
    tmin = -0.3
    tmax = 0.3
    df = 0.1
    cpal_fld = 'ncview_jaisnc'
    cunit = r'SSH (m)'
    cb_jump = 1

elif cv_in == 'somxl010':
    cfield == 'MLD'
    tmin = 50.
    tmax = 1500.
    df = 50.
    cpal_fld = 'viridis_r'

# Time record stuff...
bt.chck4f(cf_fld)
id_fld = Dataset(cf_fld)
list_var = id_fld.variables.keys()
if 'time_counter' in list_var:
    vtime = id_fld.variables['time_counter'][:]
    Nt = len(vtime)
    print '\n There is a "time_counter" in file ' + cf_fld + ' !'
    print '   => ' + str(Nt) + ' snapshots!'
    if jt <= 0 or jt > Nt:
        print ' PROBLEM: your time record does not exist!', jt
        sys.exit(0)
else:
    print '\n There is NO "time_counter" in file ' + cf_fld + ' !'
    Nt = 0
id_fld.close()
Example #49
0
#cy1 = sys.argv[1] ; cy2 = sys.argv[2] ; jy1=int(cy1); jy2=int(cy2)



path_fig=vdic['DIAG_D']+'/'

fig_type='png'

voceans_u = [cc.upper() for cc in bo.voce2treat]  ; # same list but in uppercase


jo = 0
for coce in bo.voce2treat:

    cf_temp = cname_temp+'_mean_Vprofile_'+CONFRUN+'_'+coce+'.nc' ; bt.chck4f(cf_temp)
    cf_sali = cname_sali+'_mean_Vprofile_'+CONFRUN+'_'+coce+'.nc' ; bt.chck4f(cf_sali)

    id_temp = Dataset(cf_temp)
    if jo == 0:
        vyears = id_temp.variables['time'][:]
        vdepth = id_temp.variables['deptht'][:]
    XT = id_temp.variables[cname_temp][:,:]
    id_temp.close()

    id_sali = Dataset(cf_sali)
    XS = id_sali.variables[cname_sali][:,:]
    id_sali.close()


    if jo == 0:
Example #50
0
l_force_lim = True

cfig_type = 'png'

path_fig = DIAG_D+'/'

CONFRUN = CONF+'-'+RUN

print '  Using DENSITY_SECTION_FILE = '+DENSITY_SECTION_FILE
list_sections = bo.get_sections_names_from_file(DENSITY_SECTION_FILE)
print 'List of sections to treat: ', list_sections
nbsec = len(list_sections)



cf_in = DIAG_D+'/transport_by_sigma_class.nc' ; bt.chck4f(cf_in)



id_in = Dataset(cf_in)

vtime  = id_in.variables['time'][:]       ; nbm  = len(vtime)
vsigma = id_in.variables['sigma_bins'][:] ; nbin = len(vsigma)

print '      => '+str(nbin)+' sigma-density bins and '+str(nbm)+' time snapshots...'

if nbm % 12 != 0: print 'nbm is not a multiple of 12!'; sys.exit(0)


# Reconstructing bounds of bins:
vsigma_bounds = nmp.zeros(nbin+1)
Example #51
0
elif cv_in == 'sosstsst':
    cfield = 'SST'
    log_ctrl=0  ; # 0 if you want no log involved in the colorscale...
    tmin=-2. ;  tmax=32.   ;  dtemp = 2.
    #cpal_fld = 'ncview_hotres'
    #cpal_fld = 'hot_r'
    cunit = r'deg.C'
    cb_jump = 2




j1=ny_exclude_north

    
bt.chck4f(cf_in)

bt.chck4f(cf_mm)
id_mm = Dataset(cf_mm)
XLONo  =  id_mm.variables['glamt'][0,:,:]
(njo,nio) = nmp.shape(XLONo)
j1=ny_exclude_south
j2=njo-ny_exclude_north
del XLONo
XLONo  =  id_mm.variables['glamt'][0,j1:j2,:]
XLATo  =  id_mm.variables['gphit'][0,j1:j2,:]
if l_force_mask: XMSKo  = id_mm.variables['tmask'][0,0,j1:j2,:]
id_mm.close()


Example #52
0
if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)


jy1_clim = jy1 ; jy2_clim = jy2

print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'



store_dir = os.getenv('DIAG_D')
if store_dir == '': print 'The DIAG_D environement variable is no set'; sys.exit(0)


# Getting coordinates:
bt.chck4f(cf_mesh_mask) ; id_coor = Dataset(cf_mesh_mask)
xlon   = id_coor.variables['nav_lon'][:,:] ; xlat   = id_coor.variables['nav_lat'][:,:]
id_coor.close()


# Getting obs:
bt.chck4f(ICE_CLIM_12) ; id_clim = Dataset(ICE_CLIM_12)
xclim03 = id_clim.variables[NN_ICEF_CLIM][2,:,:]
xclim09 = id_clim.variables[NN_ICEF_CLIM][8,:,:]
id_clim.close()



# Getting land-sea mask:
#-----------------------
xmask = 0