Exemple #1
0
if lfig0:

    if CC == 'CLIM':
        ctt = CONFRUN + ': Mean Annual Zonal Anomaly of SST / Reynolds, (' + cy1 + '-' + cy2 + ')'
    else:
        ctt = CONFRUN + ': Mean Annual Zonal Anomaly of SST / ' + CC + ', (' + cy1 + '-' + cy2 + ')'

    vzc[:] = bt.mk_zonal(SSTnemo_annual[:, :] - SSTclim_annual[:, :],
                         imask[0, :, :])
    # Only at the end of all the runs we do 2d plotting:
    bp.plot("zonal")(vlat,
                     vzc,
                     cfignm=path_fig + '1d_zonal_temp_anom_vs_' + CC,
                     zmin=-5.,
                     zmax=5.,
                     dz=1.,
                     xmin=-75.,
                     xmax=65.,
                     czunit=r'$^{\circ}$C',
                     cfig_type=fig_type,
                     ctitle=ctt)

    if CC == 'CLIM':
        ctt = CONFRUN + ': Mean Annual Zonal Anomaly of SSS / WOA2009, (' + cy1 + '-' + cy2 + ')'
    else:
        ctt = CONFRUN + ': Mean Annual Zonal Anomaly of SSS / ' + CC + ', (' + cy1 + '-' + cy2 + ')'

    vzc[:] = bt.mk_zonal(Snemo_annual[0, :, :] - Sclim_annual[0, :, :],
                         imask[0, :, :])
    # Only at the end of all the runs we do 2d plotting:
    bp.plot("zonal")(vlat,
Exemple #2
0
[ nt, nj, ni ] = rnf.shape ; print ' Shape of Runoffs :', nt, nj, ni, '\n'





rnf_plot = nmp.zeros(nj*ni) ; rnf_plot.shape = [ nj , ni ]


rnf_plot[:,:] = nmp.mean(rnf[:,:,:],axis=0)
#rnf_plot[:,:] = nmp.log(rnf_plot[:,:]+1.0)

# With lat-lon axis:
#bp.plot_2d(xlon[0,:], xlat[:,ji_lat0], rnf_plot[:,:], Xmask[0,:,:], 0., zmax_rnf_atl, dz_rnf,
#              corca=ORCA, lkcont=False, cpal='sst',
#              cfignm=path_fig+'runoffs_mean_'+CONFRUN, cbunit=r'10$^{-3}$mm/day',
#              ctitle='Mean Runoffs, '+CONFRUN+' ('+cy1+'-'+cy2+')', lforce_lim=True, i_sub_samp=2,
#              cfig_type=fig_type, lat_min=-79., lat_max=85., lpix=True)

# Without:
bp.plot("2d")([0], [0], rnf_plot[:,:], Xmask[0,:,:], 0., zmax_rnf_atl, dz_rnf,
           corca=ORCA, lkcont=False, cpal='sst',
           cfignm=path_fig+'runoffs_mean_'+CONFRUN, cbunit=r'10$^{-3}$mm/day',
           ctitle='Mean Runoffs, '+CONFRUN+' ('+cy1+'-'+cy2+')', lforce_lim=True, i_sub_samp=2,
           cfig_type=fig_type, lpix=True)


print '\n Bye!'

Exemple #3
0
xclim090[js_ext:nje,:] = xclim09[:,:]



ratio = 1.

#if COMP2D == 'CLIM': ratio = 100.
if xclim03.max()>90.:
    ratio = 100.


#DEBUG:
if False:
    bp.plot("nproj")('spstere', 0., 1., 0.1, xlon0, xlat0, xclim090[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_SP_sept_obs', cpal='ice', cbunit='frac.',
                     ctitle='Sea-Ice, Sept., obs.',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)
    
    bp.plot("nproj")('npol2', 0., 1., 0.1, xlon, xlat, xclim03[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_NP_march_obs', cpal='ice', cbunit='frac.',
                     ctitle='Sea-Ice, March, obs.',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)

    sys.exit(0)
#DEBUG.



# September


    # FIGURE 1
    ###########

    ittic = bt.iaxe_tick(nbm/12)

    # We want rmax to be a multile of 0.2:
    rmax = nmp.amax(nmp.abs(Xst_ann))
    r1   = round(rmax+0.05,1)*100; rmax = (r1 + r1%20)/100. ; rmin = -rmax
    dc = (int(round(100*(rmax+0.6)/20.,2))/5*5)/100.
    
    bp.plot("trsp_sig_class")(vtime_ann, vsigma_bounds, Xst_ann, rmin, rmax, dc, dsigma,
                              lkcont=True, cpal='bbr2_r', dt_year=ittic,
                              cfignm='transport_sigma_class_'+csec+'_'+CONFRUN,
                              cfig_type='png', ctitle=r'Transport by $\sigma_0$ class, '+csec+', '+CONFRUN,
                              lforce_lim=False, vcont_spec1 = [], i_colorbar_jump=2)
    


    
    # Volume transport for density > rsigma_dense
    # ====================================

    if jsec == 0:
        v278 = nmp.zeros(nbm/12*nbsec) ; v278.shape = [ nbsec, nbm/12 ]
        j278 = 0 ; nsig = len(vsigma)
        while vsigma[j278] < rsigdense0: j278 = j278 + 1
        
    for jt in range(nbm/12): v278[jsec,jt] = nmp.sum(Xst_ann[j278:,jt])
                                             cv_t='time',
                                             l_return_time=True)
                nbm = len(vt0)
                test_nb_mnth_rec(nbm, nb_years, cdiag)
                VY, FY = bt.monthly_2_annual(vt0, vd0)
                vtime[:nbm / 12] = VY[:]
                Xf[jrun, :nbm / 12] = FY[:]
                Xf[jrun, nbm / 12:] = -999.
                jrun = jrun + 1

            bp.plot("1d_multi")(vtime[:],
                                Xf[:, :],
                                clist_runs,
                                cfig_type=cffig,
                                cfignm=cdiag + '_comparison_' + cocean,
                                dt_year=ittic,
                                loc_legend=DEFAULT_LEGEND_LOC,
                                cyunit=vunit[jvar],
                                ctitle=vname[jvar] + ', ' + cocean,
                                ymin=0,
                                ymax=0)

        jvar = jvar + 1

if imld == 1:

    cvar = vdic['NN_MLD']
    cdiag = 'mean_' + cvar
    vname = [r'Mixed layer depth']
    lplot = True
Exemple #6
0
    cm = "%02d" % (jt + 1)
    cdate = cy + cm

    if cvar == 'sst':
        # SST:
        bp.plot("2d")(vlon,
                      vlat,
                      SSXnemo[jt, :, :] - SSXclim[jt, :, :],
                      imask[0, :, :],
                      tmin,
                      tmax,
                      dtemp,
                      corca=vdic['ORCA'],
                      lkcont=False,
                      cpal='RdBu_r',
                      cfignm=path_fig + '/' + cv_dsst + '_' + cdate,
                      cbunit='K',
                      cfig_type=fig_type,
                      lat_min=-65.,
                      lat_max=75.,
                      ctitle='SST (NEMO - obs) ' + CONFRUN + ' (' + cdate +
                      ')',
                      lforce_lim=True,
                      i_cb_subsamp=2)

    if cvar == 'sss':
        # SSS:
        bp.plot("2d")(vlon,
                      vlat,
                      SSXnemo[jt, :, :] - SSXclim[jt, :, :],
Exemple #7
0
bt.chck4f(cf_nemo_moc)
id_nemo = Dataset(cf_nemo_moc)
vz = id_nemo.variables['depthw'][:]
amoc = id_nemo.variables[cv_moc][0, :, :]
id_nemo.close()

[nk, nj] = amoc.shape
print ' Shape of AMOC :', nk, nj, '\n'

# Building a latitude vector:
vlat = nmp.zeros(nj)
ji_lat_mid_atlantic = bt.find_index_from_value(-28., xlon[0, :])
vlat[:] = xlat[:, ji_lat_mid_atlantic]

# Building the vertical mask:
msk_vert = nmp.zeros((nk, nj))
msk_vert[:, :] = nmp.sum(Xmask[:, :, :], axis=2)
idxm = nmp.where(msk_vert[:, :] > 0.)
msk_vert[idxm] = 1.


bp.plot("amoc_lat_depth")(vlat[:], -vz[:], amoc[:,:], msk_vert[:,:], -3., 20., 1., \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_annual_'+CONFRUN, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, '+CONFRUN+' ('+cy1+'-'+cy2+')',
                          lforce_lim=True, i_cb_subsamp=1)

print '\n Bye!'
Exemple #8
0
#ztot = nmp.sum(psi_plot*Xmask*Xe1t*Xe2t)/nmp.sum(Xmask*Xe1t*Xe2t)
#print 'ztot =', ztot
#
#psi_plot = psi_plot - ztot
#cztot = str(round(ztot,2))

# the Jean-Marc Molines method:
ji_lat0 = nmp.argmax(xlat[nj - 1, :])

bp.plot("2d")(xlon[0, :],
              xlat[:, ji_lat0],
              psi_plot[:, :],
              Xmask,
              -100.,
              100.,
              5.,
              corca=vdic['ORCA'],
              lkcont=True,
              cpal='BrBG_r',
              cfignm=path_fig + 'psi_mean_' + CONFEXP,
              cbunit=r'$(10^{6} m^3/s)$',
              ctitle='Mean barotropic stream function , ' + CONFEXP + ' (' +
              cy1 + '-' + cy2 + ')',
              lforce_lim=True,
              i_cb_subsamp=2,
              cfig_type=fig_type,
              lat_min=-70.,
              lat_max=68.,
              lpix=False,
              vcont_spec=[0.])
Exemple #9
0
a = ( sumx*sumy - nt*sumxy ) / ( sumx*sumx - nt*sumxx )
b = ( sumy - a*sumx ) / nt
print 'a, b =', a, b

# least-square linear trend:
xnino[:,2] = a*vtime[:] + b
print 'mean value for least-square linear trend = ', nmp.sum(xnino[:,2])/nt

# anomaly
xnino[:,3] = xnino[:,1] - xnino[:,2] ; # anomaly for 5-month running mean
print 'mean value for anomaly = ', nmp.sum(xnino[:,3])/nt



# save serie into a file:
#cf_out = cname+'_anomaly.nc'
#f = open(cf_out, 'w')
#f.write('# created with '+sys.argv[0]+' from file '+cf_in+'\n')
#f.write('# time, mean SST,  5-month RM,  linear trend,    anomaly     \n')
#for jt in range(nt):
#    f.write(str(round(vtime[jt],3))+'   '+str(round(xnino[jt,0],5))+'   '\
#            +str(round(xnino[jt,1],5))+'   '+str(round(xnino[jt,2],5))+'   '+str(round(xnino[jt,3],5))+'\n')
#print '\n'
#print ' ascii file '+cf_out+' created!\n'



bp.plot("enso")( vtime, xnino[:,0], cfignm=cname, dt_year=ittic )


Exemple #10
0
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, vvar, FY, cfignm=cdiag+'_'+CONFRUN, dt_year=ittic,
                          cyunit=cyu, ctitle = CONFRUN+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)



if idfig == 'htf':

    l_qsr = False
    cf_in = cdiag+'_'+CONFRUN+'_global.nc' ;  bt.chck4f(cf_in, script_name=csn)

    id_in = Dataset(cf_in)
    list_var = id_in.variables.keys()
    vtime = id_in.variables['time'][:] ; nbm = len(vtime)
    vqnt  = id_in.variables[cvar][:]
    if cvr2 in list_var[:]:
        l_qsr = True
        vqsr  = id_in.variables[cvr2][:]
for jt in range(Nt):

    jy = jt/12 + 1
    if jt % 12 == 0: jm = 0    
    jm = jm + 1


    #print 'jt, jm, jy =', jt, jm, jy

    ct = str(jt).zfill(4)
    cm = str(jm).zfill(2)
    cy = str(jy).zfill(4)



    cfig = cv_in+'_'+cfig_suff+'_'+ct

    print '  *** will create fig '+cfig+' (year = '+cy+', month = '+cm+')'
    
    bp.plot("nproj")('spstere', rmin, rmax, dr, xlon, xlat, XF2D[jt,:,:],
                     cfignm=cfig, cpal=colmap, cbunit=cunit,
                     ctitle='Sea-Ice, year = '+cy+', month = '+cm,
                     lkcont=True, cfig_type=FIF,
                     lforce_lim=True)



cfig_out = cv_in+'_'+cfig_suff+'.gif'

os.system("convert -delay 100 -loop 0 "+cv_in+"*.png "+cfig_out+" > out_conv.out")
Exemple #12
0
for jt in range(nt):

    cm = "%02d" % (jt + 1)
    cdate = cy + cm

    if cvar == 'sst':
        bp.plot("2d")(vlon,
                      vlat,
                      Vnemo[jt, :, :] - Vclim[jt, :, :],
                      imask[:, :],
                      tmin,
                      tmax,
                      dtemp,
                      corca=vdic['ORCA'],
                      lkcont=False,
                      cpal='RdBu_r',
                      cfignm=path_fig + '/' + cv + '_' + cdate,
                      cbunit='K',
                      cfig_type=fig_type,
                      lat_min=-65.,
                      lat_max=75.,
                      ctitle='SST (NEMO - obs) ' + CONFRUN + ' (' + cdate +
                      ')',
                      lforce_lim=True,
                      i_cb_subsamp=2)

    if cvar == 'sss':
        bp.plot("2d")(vlon,
                      vlat,
                      Vnemo[jt, :, :] - Vclim[jt, :, :],
                      imask[:, :],
        for cocean in bo.voce2treat:
            Xf[:,:] = 0. ; jrun = 0
            for confrun in clist_confruns:

                cf_in = DIAG_DIR+'/'+confrun+'/'+cdiag+'_'+confrun+'_'+cocean+'.nc'
                vt0, vd0 = bn.read_1d_series(cf_in, cvar, cv_t='time', l_return_time=True)
                nbm = len(vt0) ; print ' *** nmb =', nbm
                if nbm%12 != 0: print 'ERROR: compare_time_series.py => PROBLEM#1. diag ='+cdiag; sys.exit(0)
                if nbm/12 > nb_years: print 'ERROR: compare_time_series.py => PROBLEM#2. diag ='+cdiag, nbm/12, nb_years ; sys.exit(0)
                VY, FY = bt.monthly_2_annual(vt0, vd0)
                vtime[:nbm/12]   = VY[:]
                Xf[jrun,:nbm/12] = FY[:] ; Xf[jrun,nbm/12:] = -999.
                jrun = jrun + 1
    
            bp.plot("1d_multi")(vtime[:], Xf[:,:], clist_confruns, cfig_type=FIG_FORMAT,
                                cfignm=cdiag+'_comparison_'+cocean, dt_year=ittic, loc_legend=DEFAULT_LEGEND_LOC,
                                cyunit=vunit[jvar], ctitle = vname[jvar]+', '+cocean, ymin=0, ymax=0)
    
        jvar = jvar+1
    
    









if imld == 1:
Exemple #14
0
            zz = vlev[jk]
            Sigma0_nemo[jk, :, :] = Sigma0_nemo[jk, :, :] * mmask[:, :]
            Sigma0_nemo[jk + 1, :, :] = Sigma0_nemo[jk + 1, :, :] * mmask[:, :]
            ijloc = nmp.where(
                Sigma0_nemo[jk + 1, :, :] - 0.01 > Sigma0_nemo[jk, :, :])
            Xmld_obs[ijloc] = zz
            mmask[ijloc] = 0.
            # these points won't be checked again only first occurence of the criterion matters!
            bp.plot("nproj")('nseas',
                             200.,
                             zmax_mld_atl,
                             dz_mld,
                             xlon,
                             xlat,
                             Xmld_obs[:, :],
                             cfignm=path_fig + 'mld_NEMO_001_NSeas_march_' +
                             CONFRUN + '_vs_' + vdic['COMP2D'],
                             cpal='sst0',
                             cbunit='m',
                             ctitle='MLD NEMO, March, ' + CONFRUN + ' (' +
                             cy1 + '-' + cy2 + ')',
                             lkcont=True,
                             cfig_type=fig_type,
                             lforce_lim=True)

# FIGURES MARCH #
#################

# the Jean-Marc Molines method:
ji_lat0 = nmp.argmax(xlat[nj - 1])

bp.plot("nproj")('nseas',
Exemple #15
0
    # We want rmax to be a multile of 0.2:
    rmax = nmp.amax(nmp.abs(Xst_ann))
    r1 = round(rmax + 0.05, 1) * 100
    rmax = (r1 + r1 % 20) / 100.0
    rmin = -rmax
    dc = (int(round(100 * (rmax + 0.6) / 20.0, 2)) / 5 * 5) / 100.0

    bp.plot("trsp_sig_class")(
        vtime_ann,
        vsigma_bounds,
        Xst_ann,
        rmin,
        rmax,
        dc,
        dsigma,
        lkcont=True,
        cpal="bbr2_r",
        dt_year=ittic,
        cfignm="transport_sigma_class_" + csec + "_" + CONFRUN,
        cfig_type="png",
        ctitle=r"Transport by $\sigma_0$ class, " + csec + ", " + CONFRUN,
        lforce_lim=False,
        vcont_spec1=[],
        i_cb_subsamp=2,
    )

    # bp.plot("vert_section")(vtime_ann, vsigma_bounds, Xst_ann, Xst_ann*0.+1., rmin, rmax, dc,
    #                        lkcont=True, cpal='bbr2_r', xmin=nmp.min(vtime_ann), xmax=nmp.max(vtime_ann), dx=ittic,
    #                        cfignm='transport_sigma_class_'+csec+'_'+CONFRUN,
    #                        cfig_type='png', czunit=r'$\sigma_0$',
    #                        ctitle=r'Transport by $\sigma_0$ class, '+csec+', '+CONFRUN, i_cb_subsamp=1 )
Exemple #16
0
rnf_plot[:, :] = nmp.mean(rnf[:, :, :], axis=0)
#rnf_plot[:,:] = nmp.log(rnf_plot[:,:]+1.0)

# With lat-lon axis:
#bp.plot_2d(xlon[0,:], xlat[:,ji_lat0], rnf_plot[:,:], Xmask[0,:,:], 0., zmax_rnf_atl, dz_rnf,
#              corca=vdic['ORCA'], lkcont=False, cpal='sst',
#              cfignm=path_fig+'runoffs_mean_'+CONFRUN, cbunit=r'10$^{-3}$mm/day',
#              ctitle='Mean Runoffs, '+CONFRUN+' ('+cy1+'-'+cy2+')', lforce_lim=True, i_cb_subsamp=2,
#              cfig_type=fig_type, lat_min=-79., lat_max=85., lpix=True)

# Without:
bp.plot("2d")([0], [0],
              rnf_plot[:, :],
              Xmask[0, :, :],
              0.,
              zmax_rnf_atl,
              dz_rnf,
              corca=vdic['ORCA'],
              lkcont=False,
              cpal='sst',
              cfignm=path_fig + 'runoffs_mean_' + CONFRUN,
              cbunit=r'10$^{-3}$mm/day',
              ctitle='Mean Runoffs, ' + CONFRUN + ' (' + cy1 + '-' + cy2 + ')',
              lforce_lim=True,
              i_cb_subsamp=2,
              cfig_type=fig_type,
              lpix=True)

print '\n Bye!'
    [rmin, rmax, rdf] = bt.get_min_max_df(Xheat[jb, jt_ini:, :], 40)

    bp.plot("vert_section")(
        vyear[:],
        vlat[:],
        nmp.flipud(nmp.rot90(Xheat[jb, :, :])),
        nmp.flipud(nmp.rot90(imask[:, :])),
        rmin,
        rmax,
        rdf,
        cpal="RdBu",
        xmin=yr1,
        xmax=yr2 + 1.0,
        dx=ittic,
        lkcont=False,
        zmin=vlat[0],
        zmax=vlat[Nlat - 1],
        l_zlog=False,
        cfignm=path_fig + "MHT_" + CONFRUN + "_" + cbasin,
        cbunit="PW",
        cxunit="",
        czunit=r"Latitude ($^{\circ}$N)",
        ctitle=CONFRUN + ": Northward advective meridional heat transport, " + cbasin,
        cfig_type=fig_type,
        lforce_lim=False,
        i_cb_subsamp=2,
        l_z_increase=True,
    )

    # Salt transport
Exemple #18
0
vtmp = nmp.zeros(Nt)
vtime = nmp.zeros(Nt - 5)
xplot = nmp.zeros((Nt - 5, 4))
# Nt-5 because 5-month-running mean

vtime[:] = vt[2:-3]
vtmp = bs.running_mean_5(vsst)
# 5-month running mean
xplot[:, 0] = vsst[2:-3]
xplot[:, 1] = vtmp[2:-3]

(za, zb) = bs.least_sqr_line(vtime[:], xplot[:, 1])
# Least-square linear trend
xplot[:, 2] = za * vtime[:] + zb

xplot[:, 3] = xplot[:, 1] - xplot[:, 2]
# anomaly for 5-month running mean

ittic = bt.iaxe_tick(Nt / 12)

bp.plot("oscillation_index")(vtime,
                             xplot[:, 3],
                             ymax=2.1,
                             dy=0.5,
                             yplusminus=0.4,
                             dt=ittic,
                             cfignm=cname,
                             cfig_type=fig_form,
                             cyunit=r'SST anomaly ($^{\circ}$C)',
                             ctitle='ENSO (over Nino box 3.4)')
Exemple #19
0
    # FIGURE 1
    ###########
    rmax = nmp.amax(nmp.abs(Xst_ann))
    rmin = -rmax
    rmin, rmax, dc = bp.__suitable_axis_dx__(rmin, rmax, nb_val=25, lsym0=True)
    i_cbssmp = 2
    if dc in [0.5, 1., 2., 5.]: i_cbssmp = 1

    bp.plot("trsp_sig_class")(
        vtime_ann,
        vsigma_bounds,
        Xst_ann,
        rmin,
        rmax,
        dc,
        lkcont=False,
        cpal='ncview_jaisnb',
        dt=ittic,
        cfignm='transport_sigma_class_' + csec + '_' + CONFEXP,
        cfig_type='png',
        ctitle=r'Transport by $\sigma_0$ class, ' + csec + ', ' + CONFEXP,
        vcont_spec1=[],
        i_cb_subsamp=i_cbssmp)

    # Volume transport for density > rsigma_dense
    # ====================================

    if jsec == 0:
        v278 = nmp.zeros(nby * nbsec)
        v278.shape = [nbsec, nby]
        j278 = 0
Exemple #20
0
    [rmin, rmax, rdf] = bt.get_min_max_df(Xheat[jb, jt_ini:, :], 40)

    bp.plot("vert_section")(
        vyear[:],
        vlat[:],
        nmp.flipud(nmp.rot90(Xheat[jb, :, :])),
        nmp.flipud(nmp.rot90(imask[:, :])),
        rmin,
        rmax,
        rdf,
        cpal='RdBu',
        xmin=yr1,
        xmax=yr2 + 1.,
        dx=ittic,
        lkcont=False,
        zmin=vlat[0],
        zmax=vlat[Nlat - 1],
        l_zlog=False,
        cfignm=path_fig + 'MHT_' + CONFRUN + '_' + cbasin,
        cbunit='PW',
        cxunit='',
        czunit=r'Latitude ($^{\circ}$N)',
        ctitle=CONFRUN + ': Northward advective meridional heat transport, ' +
        cbasin,
        cfig_type=fig_type,
        lforce_lim=False,
        i_cb_subsamp=2,
        l_z_increase=True)

    # Salt transport
Exemple #21
0
if n_run_mean == 11:
    vtmp = bs.running_mean_11(vsst)
    # 11-month running mean
if n_run_mean == 21:
    vtmp = bs.running_mean_21(vsst)
    # 21-month running mean
xplot[:, 0] = vsst[n1:n2]
xplot[:, 1] = vtmp[n1:n2]

(za, zb) = bs.least_sqr_line(vtime[:], xplot[:, 1])
# Least-square linear trend
xplot[:, 2] = za * vtime[:] + zb

xplot[:, 3] = xplot[:, 1] - xplot[:, 2]
# anomaly for 11-month running mean

ittic = bt.iaxe_tick(Nm / 12)

bp.plot("oscillation_index")(vtime,
                             xplot[:, 3],
                             ymax=0.3,
                             dy=0.05,
                             tmin=vt_m[0],
                             tmax=vt_m[-1],
                             dt=ittic,
                             cfignm=cname,
                             cfig_type=fig_form,
                             cyunit=r'SST anomaly ($^{\circ}$C)',
                             ctitle='Atlantic Multidecadal Oscillation (' +
                             str(n_run_mean) + '-year running mean)')
Exemple #22
0




# Time for figures:
# -----------------

if lfig0:

    ctt = CONFEXP+': Mean Annual Zonal Anomaly of SST / "'+cname_obs+'", ('+cy1+'-'+cy2+')'

    vzc[:] = bt.mk_zonal(SSTnemo_annual[:,:] - SSTobs_annual[:,:], XMSK=imask[0,:,:])
    # Only at the end of all the experiments we do 2d plotting:
    bp.plot("zonal")(vlat, vzc, cfignm=path_fig+'1d_zonal_temp_anom_vs_'+CC, zmin=-5., zmax=5., dz=1.,
                     xmin=-75., xmax=65., czunit=r'$^{\circ}$C', cfig_type=fig_type,
                     ctitle=ctt)

    ctt = CONFEXP+': Mean Annual Zonal Anomaly of SSS / "'+cname_obs+'", ('+cy1+'-'+cy2+')'

    vzc[:] = bt.mk_zonal(SSSnemo_annual[:,:] - Sobs_annual[0,:,:], XMSK=imask[0,:,:])
    # Only at the end of all the experiments we do 2d plotting:
    bp.plot("zonal")(vlat, vzc, cfignm=path_fig+'1d_zonal_sali_anom_vs_'+CC , zmin=-2.5, zmax=2.5, dz=0.5,
                     xmin=-75., xmax=65., czunit='PSU', cfig_type=fig_type,
                     ctitle=ctt)



if lfig1:

    #                    SST / Reynolds
Exemple #23
0
xlon   = id_mm.variables['glamt'][0,:,:] ; xlat = id_mm.variables['gphit'][0,:,:]
Xmask = id_mm.variables['tmask'][0,:,:,:]
id_mm.close()


#  Getting NEMO mean monthly climatology of SSH 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)
ssh   = id_nemo.variables[NN_SSH][:,:,:]
id_nemo.close()

[ nt, nj, ni ] = ssh.shape ; print ' Shape of SSH :', nt, nj, ni, '\n'



ssh_plot = nmp.zeros(nj*ni) ; ssh_plot.shape = [ nj , ni ]


ssh_plot[:,:] = nmp.mean(ssh[:,:,:],axis=0)



bp.plot("2d")(xlon[0,:], xlat[:,ji_lat0], ssh_plot[:,:], Xmask[0,:,:], -2.6, 1.6, 0.1,
              corca=ORCA, lkcont=True, cpal='jet',
              cfignm=path_fig+'ssh_mean_'+CONFRUN, cbunit='m',
              ctitle='Mean SSH, '+CONFRUN+' ('+cy1+'-'+cy2+')', lforce_lim=True, i_sub_samp=2,
              cfig_type=fig_type, lat_min=-77., lat_max=75., lpix=False, vcont_spec = [ 0. ])

Exemple #24
0
if nt != 1:
    print 'ERROR: AMOC clim supposed to have only 1 time record'
    sys.exit(0)

# Building the vertical mask:
msk_vert = nmp.zeros(nk * nj)
msk_vert.shape = [nk, nj]
msk_vert[:, :] = nmp.sum(Xmask_atl[:, :, :], axis=2)
idxm = nmp.where(msk_vert[:, :] > 0.)
msk_vert[idxm] = 1.


bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc1[0,:,:], msk_vert[:,:], -3.5, 22., 0.5, \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'-'+crun1, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, ('+cy1_1+'-'+cy2_1+'), '+ORCA+'-'+crun1, lforce_lim=True)

bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc2[0,:,:], msk_vert[:,:], -3.5, 22., 0.5, \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'-'+crun2, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, ('+cy1_2+'-'+cy2_2+'), '+ORCA+'-'+crun1, lforce_lim=True)

# Difference of AMOC:
bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc2[0,:,:]-Amoc1[0,:,:], msk_vert[:,:], -0.36, 0.36, 0.02, \
                          cfig_type=fig_type, lkcont=True, cpal='bbr2', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'_'+crun2+'-'+crun1, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, ('+cy1_1+'-'+cy2_1+'), '+ORCA+' '+crun2+'-'+crun1, lforce_lim=True)
Exemple #25
0
xclim090[js_ext:nje,:] = xclim09[:,:]



ratio = 1.

#if vdic['COMP2D'] == 'OBS': ratio = 100.
if xclim03.max()>90.:
    ratio = 100.


#DEBUG:
if False:
    bp.plot("nproj")('spstere', 0., 1., 0.1, xlon0, xlat0, xclim090[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_SP_sept_obs', cpal='ice', cbunit='(frac.)',
                     ctitle='Ice fraction, Sept., "'+cn_obs+'"',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)
    
    bp.plot("nproj")('npol2', 0., 1., 0.1, xlon, xlat, xclim03[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_NP_march_obs', cpal='ice', cbunit='(frac.)',
                     ctitle='Ice fraction, March, "'+cn_obs+'"',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)

    sys.exit(0)
#DEBUG.



# September
Exemple #26
0
[ nt0, nk0, nj0 ] = Amoc2.shape
if [ nt0, nk0, nj0 ] != [ nt, nk, nj ]: print 'ERROR: AMOC clim and mesh_mask do no agree in shape! #2'; sys.exit(0)

if nt != 1: print 'ERROR: AMOC clim supposed to have only 1 time record'; sys.exit(0)

# Building the vertical mask:
msk_vert = nmp.zeros(nk*nj) ; msk_vert.shape = [ nk, nj ]
msk_vert[:,:] = nmp.sum(Xmask_atl[:,:,:],axis=2)
idxm = nmp.where(msk_vert[:,:] > 0.);
msk_vert[idxm] = 1.


bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc1[0,:,:], msk_vert[:,:], -3.5, 22., 0.5, \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'-'+crun1, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, ('+cy1_1+'-'+cy2_1+'), '+ORCA+'-'+crun1, lforce_lim=True)

bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc2[0,:,:], msk_vert[:,:], -3.5, 22., 0.5, \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'-'+crun2, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, ('+cy1_2+'-'+cy2_2+'), '+ORCA+'-'+crun1, lforce_lim=True)


# Difference of AMOC:
bp.plot("amoc_lat_depth")(vlat[:], -vz[:], Amoc2[0,:,:]-Amoc1[0,:,:], msk_vert[:,:], -0.36, 0.36, 0.02, \
                          cfig_type=fig_type, lkcont=True, cpal='bbr2', ymin=0., ymax=70.,
                          cfignm='AMOC_'+ORCA+'_'+crun2+'-'+crun1, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
Exemple #27
0
    #print 'jt, jm, jy =', jt, jm, jy

    ct = str(jt).zfill(4)
    cm = str(jm).zfill(2)
    cy = str(jy).zfill(4)

    cfig = cv_in + '_' + cfig_suff + '_' + ct

    print '  *** will create fig ' + cfig + ' (year = ' + cy + ', month = ' + cm + ')'

    bp.plot("nproj")('spstere',
                     rmin,
                     rmax,
                     dr,
                     xlon,
                     xlat,
                     XF2D[jt, :, :],
                     cfignm=cfig,
                     cpal=colmap,
                     cbunit=cunit,
                     ctitle='Sea-Ice, year = ' + cy + ', month = ' + cm,
                     lkcont=True,
                     cfig_type=FIF,
                     lforce_lim=True)

cfig_out = cv_in + '_' + cfig_suff + '.gif'

os.system("convert -delay 100 -loop 0 " + cv_in + "*.png " + cfig_out +
          " > out_conv.out")
Exemple #28
0
amoc   = id_nemo.variables[cv_moc][0,:,:]
id_nemo.close()

[ nk, nj ] = amoc.shape ; print ' Shape of AMOC :', nk, nj, '\n'


# Building a latitude vector:
vlat = nmp.zeros(nj)
ji_lat_mid_atlantic = bt.find_index_from_value( -28., xlon[0,:] )
vlat[:] = xlat[:,ji_lat_mid_atlantic]


# Building the vertical mask:
msk_vert = nmp.zeros((nk,nj))
msk_vert[:,:] = nmp.sum(Xmask[:,:,:],axis=2)
idxm = nmp.where(msk_vert[:,:] > 0.);
msk_vert[idxm] = 1.


bp.plot("amoc_lat_depth")(vlat[:], -vz[:], amoc[:,:], msk_vert[:,:], -3., 20., 1., \
                          cfig_type=fig_type, lkcont=True, cpal='amoc', ymin=0., ymax=70.,
                          cfignm='AMOC_annual_'+CONFRUN, cbunit='Sv',
                          cxunit=r'Latitude ($^{\circ}$N)', zmin = 5000., zmax = 0., l_zlog=False,
                          czunit='Depth (m)', ctitle='AMOC, '+CONFRUN+' ('+cy1+'-'+cy2+')',
                          lforce_lim=True, i_cb_subsamp=1)



print '\n Bye!'

Exemple #29
0
if cvar == 'ice':
    # Extraoplating sea values on continents:
    bt.drown(Vnemo[:,:,:], imask, k_ew=2, nb_max_inc=10, nb_smooth=10)



for jt in range(nt):

    cm = "%02d" % (jt+1)
    cdate = cy+cm

    if cvar == 'sst':
        bp.plot("2d")(vlon, vlat, Vnemo[jt,:,:] - Vclim[jt,:,:],
                      imask[:,:],  tmin, tmax, dtemp,
                      corca=vdic['ORCA'], lkcont=False, cpal='RdBu_r',
                      cfignm=path_fig+'/'+cv+'_'+cdate,
                      cbunit='K', cfig_type=fig_type, lat_min=-65., lat_max=75.,
                      ctitle='SST (NEMO - obs) '+CONFRUN+' ('+cdate+')',
                      lforce_lim=True, i_cb_subsamp=2)

    if cvar == 'sss':
        bp.plot("2d")(vlon, vlat, Vnemo[jt,:,:] - Vclim[jt,:,:],
                      imask[:,:],  smin, smax, dsali,
                      corca=vdic['ORCA'], lkcont=False, cpal='PiYG_r',
                      cfignm=path_fig+'/'+cv+'_'+cdate,
                      cbunit='PSU', cfig_type=fig_type, lat_min=-65., lat_max=75.,
                      ctitle='SSS (NEMO - obs) '+CONFRUN+' ('+cdate+')',
                      lforce_lim=True, i_cb_subsamp=2)

    
    if cvar == 'ice':
Exemple #30
0
    # We want rmax to be a multile of 0.2:
    rmax = nmp.amax(nmp.abs(Xst_ann))
    r1 = round(rmax + 0.05, 1) * 100
    rmax = (r1 + r1 % 20) / 100.
    rmin = -rmax
    dc = (int(round(100 * (rmax + 0.6) / 20., 2)) / 5 * 5) / 100.

    bp.plot("trsp_sig_class")(
        vtime_ann,
        vsigma_bounds,
        Xst_ann,
        rmin,
        rmax,
        dc,
        dsigma,
        lkcont=True,
        cpal='bbr2_r',
        dt_year=ittic,
        cfignm='transport_sigma_class_' + csec + '_' + CONFRUN,
        cfig_type='png',
        ctitle=r'Transport by $\sigma_0$ class, ' + csec + ', ' + CONFRUN,
        lforce_lim=False,
        vcont_spec1=[],
        i_cb_subsamp=2)

    #bp.plot("vert_section")(vtime_ann, vsigma_bounds, Xst_ann, Xst_ann*0.+1., rmin, rmax, dc,
    #                        lkcont=True, cpal='bbr2_r', xmin=nmp.min(vtime_ann), xmax=nmp.max(vtime_ann), dx=ittic,
    #                        cfignm='transport_sigma_class_'+csec+'_'+CONFRUN,
    #                        cfig_type='png', czunit=r'$\sigma_0$',
    #                        ctitle=r'Transport by $\sigma_0$ class, '+csec+', '+CONFRUN, i_cb_subsamp=1 )
Exemple #31
0
        mmask[ijloc] = 0. ; # these points won't be checked again only first occurence of the criterion matters!


    if ldebug:
        # Testing my MLD method built of T and S from NEMO (to check the obs. MLD I build the same way...)
        Xmld_obs[:,:] = 0.
        mmask[:,:] = 1.
        for jk in range(nk-1):
            zz = vlev[jk]
            Sigma0_nemo[jk,:,:]   = Sigma0_nemo[jk,:,:]*mmask[:,:]
            Sigma0_nemo[jk+1,:,:] = Sigma0_nemo[jk+1,:,:]*mmask[:,:]
            ijloc = nmp.where( Sigma0_nemo[jk+1,:,:] - 0.01 > Sigma0_nemo[jk,:,:] )
            Xmld_obs[ijloc] = zz
            mmask[ijloc] = 0. ; # these points won't be checked again only first occurence of the criterion matters!
        bp.plot("nproj")('nseas', 200., zmax_mld_atl, dz_mld, xlon, xlat, Xmld_obs[:,:],
                         cfignm=path_fig+'mld_NEMO_001_NSeas_march_'+CONFRUN+'_vs_'+COMP2D, cpal='sst0', cbunit='m',
                         ctitle='MLD NEMO (0.01 crit.), March, '+CONFRUN+' ('+cy1+'-'+cy2+')',
                         lkcont=True, cfig_type=fig_type, lforce_lim=True)



# FIGURES MARCH #
#################


bp.plot("nproj")('nseas', 200., zmax_mld_atl, dz_mld, xlon, xlat, mldr10[imnth,:,:],
                 cfignm=path_fig+'mld_NSeas_march_'+CONFRUN, cpal='sst0', cbunit='m',
                 ctitle='MLD, March, '+CONFRUN+' ('+cy1+'-'+cy2+')',
                 lkcont=True, cfig_type=fig_type,
                 lforce_lim=True)

bp.plot("nproj")('spstere', 50., 200., 10., xlon, xlat, mldr10[imnth,:,:],
Exemple #32
0
    cm = "%02d" % (jt + 1)
    cdate = cy + cm
    cdatet = cy + '/' + cm

    if cvar == 'sst':
        bp.plot("2d")(vlon,
                      vlat,
                      Vnemo[jt, :, :] - Vclim[jt, :, :],
                      imask[:, :],
                      tmin,
                      tmax,
                      dtemp,
                      corca=vdic['ORCA'],
                      lkcont=False,
                      cpal='RdBu_r',
                      cfignm=path_fig + '/' + cv + '_' + cdate,
                      cbunit='K',
                      cfig_type=fig_type,
                      lat_min=-77.,
                      lat_max=75.,
                      ctitle='SST (NEMO - "' + cn_obs_ts + '"), ' + CONFEXP +
                      ' (' + cdatet + ')',
                      lforce_lim=True,
                      i_cb_subsamp=2,
                      lpix=lpix)

    if cvar == 'sss':
        bp.plot("2d")(vlon,
                      vlat,
                      Vnemo[jt, :, :] - Vclim[jt, :, :],
                      imask[:, :],
Exemple #33
0

# Time for figures:       
# -----------------

if lfig0:

    if COMP2D == 'CLIM':
        ctt = CONFRUN+': Mean Annual Zonal Anomaly of SST / Reynolds, ('+cy1+'-'+cy2+')'
    else:
        ctt = CONFRUN+': Mean Annual Zonal Anomaly of SST / '+COMP2D+', ('+cy1+'-'+cy2+')'

    vzc[:] = bt.mk_zonal(SSTnemo_annual[:,:] - SSTclim_annual[:,:], imask[0,:,:])
    # Only at the end of all the runs we do 2d plotting:
    bp.plot("zonal")(vlat, vzc, cfignm=path_fig+'1d_zonal_temp_anom_vs_'+COMP2D, zmin=-5., zmax=5., dz=1.,
                     xmin=-75., xmax=65., cyunit=r'$^{\circ}$C', cfig_type=fig_type,
                     ctitle=ctt)

    if COMP2D == 'CLIM':
        ctt = CONFRUN+': Mean Annual Zonal Anomaly of SSS / WOA2009, ('+cy1+'-'+cy2+')'
    else:
        ctt = CONFRUN+': Mean Annual Zonal Anomaly of SSS / '+COMP2D+', ('+cy1+'-'+cy2+')'

    vzc[:] = bt.mk_zonal(Snemo_annual[0,:,:] - Sclim_annual[0,:,:], imask[0,:,:])
    # Only at the end of all the runs we do 2d plotting:
    bp.plot("zonal")(vlat, vzc, cfignm=path_fig+'1d_zonal_sali_anom_vs_'+COMP2D , zmin=-2.5, zmax=2.5, dz=0.5,
                     xmin=-75., xmax=65., cyunit='PSU', cfig_type=fig_type,
                     ctitle=ctt)


        for cocean in bo.voce2treat:
            Xf[:,:] = 0. ; jrun = 0
            for confrun in clist_confruns:

                cf_in = cd_diag+'/'+confrun+'/'+cdiag+'_'+confrun+'_'+cocean+'.nc'
                vt0, vd0 = bn.read_1d_series(cf_in, cvar, cv_t='time', l_return_time=True)
                nbm = len(vt0)
                test_nb_mnth_rec(nbm, nb_years, cdiag)
                VY, FY = bt.monthly_2_annual(vt0, vd0)
                vtime[:nbm/12]   = VY[:]
                Xf[jrun,:nbm/12] = FY[:] ; Xf[jrun,nbm/12:] = -999.
                jrun = jrun + 1

            bp.plot("1d_multi")(vtime[:], Xf[:,:], clist_runs, cfig_type=cffig,
                                cfignm=cdiag+'_comparison_'+cocean, dt_year=ittic, loc_legend=DEFAULT_LEGEND_LOC,
                                cyunit=vunit[jvar], ctitle = vname[jvar]+', '+cocean, ymin=0, ymax=0)

        jvar = jvar+1











if imld == 1:
for jb in range(nbasins):

    cbasin = bo.voce2treat[jb]; print '\n *** Basin: '+cbasin

    imask[:,:] = 0
    Lfinite = nmp.isfinite(Xheat[jb,:,:]) ; idx_good = nmp.where(Lfinite)
    imask[idx_good] = 1
            
    [ rmin, rmax, rdf ] = bt.get_min_max_df(Xheat[jb,5:,:],40)
    #print ' After get_min_max_df => rmin, rmax, rdf = ', rmin, rmax, rdf

    bp.plot("vert_section")(vyear[:], vlat[:], nmp.flipud(nmp.rot90(Xheat[jb,:,:])), nmp.flipud(nmp.rot90(imask[:,:])),
                            rmin, rmax, rdf,
                            cpal='jet', xmin=vyear[0], xmax=vyear[Nby-1], dx=ittic, lkcont=False,
                            zmin = vlat[0], zmax = vlat[Nlat-1], l_zlog=False, 
                            cfignm=path_fig+'MHT_'+CONFRUN+'_'+cbasin, cbunit='PW', cxunit='',
                            czunit=r'Latitude ($^{\circ}$N)',
                            ctitle=CONFRUN+': Northward advective meridional heat transport, '+cbasin,
                            cfig_type=fig_type, lforce_lim=False, i_sub_samp=2, l_z_increase=True)



    # Salt transport
    #imask[:,:] = 0
    #Lfinite = nmp.isfinite(Xsalt[jb,:,:]) ; idx_good = nmp.where(Lfinite)
    #imask[idx_good] = 1

    [ rmin, rmax, rdf ] = bt.get_min_max_df(Xsalt[jb,5:,:],40)
    #print ' After get_min_max_df => rmin, rmax, rdf = ', rmin, rmax, rdf

    bp.plot("vert_section")(vyear[:], vlat[:], nmp.flipud(nmp.rot90(Xsalt[jb,:,:])), nmp.flipud(nmp.rot90(imask[:,:])),
Exemple #36
0
    [rmin, rmax, rdf] = bt.get_min_max_df(Xheat[joce, jt_ini:, js + 1:je - 1],
                                          40)

    bp.plot("hovmoeller")(vyear[:],
                          vlat[:],
                          nmp.flipud(nmp.rot90(Xheat[joce, :, :])),
                          mask,
                          rmin,
                          rmax,
                          rdf,
                          c_y_is='latitude',
                          cpal='RdBu_r',
                          tmin=yr1,
                          tmax=yr2 + 1.,
                          dt=ittic,
                          lkcont=True,
                          ymin=ymin,
                          ymax=ymax,
                          dy=dy,
                          cfignm=path_fig + 'MHT_' + CONFEXP + '_' + cbas,
                          cbunit='PW',
                          ctunit='',
                          cyunit=r'Latitude ($^{\circ}$N)',
                          ctitle=CONFEXP +
                          ': Northward advective meridional heat transport, ' +
                          cbasin,
                          cfig_type=fig_type,
                          i_cb_subsamp=2,
                          l_y_increase=True)

    # Salt transport
Exemple #37
0
xclim090[js_ext:nje,:] = xclim09[:,:]



ratio = 1.

#if vdic['COMP2D'] == 'CLIM': ratio = 100.
if xclim03.max()>90.:
    ratio = 100.


#DEBUG:
if False:
    bp.plot("nproj")('spstere', 0., 1., 0.1, xlon0, xlat0, xclim090[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_SP_sept_obs', cpal='ice', cbunit='(frac.)',
                     ctitle='Ice fraction, Sept., obs.',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)
    
    bp.plot("nproj")('npol2', 0., 1., 0.1, xlon, xlat, xclim03[:,:]/ratio,
                     cfignm=path_fig+'sea-ice_NP_march_obs', cpal='ice', cbunit='(frac.)',
                     ctitle='Ice fraction, March, obs.',
                     lkcont=True, cfig_type=fig_type, 
                     lforce_lim=True)

    sys.exit(0)
#DEBUG.



# September
Exemple #38
0
bt.chck4f(cf_nemo_mnmc)
id_nemo = Dataset(cf_nemo_mnmc)
ssh   = id_nemo.variables[vdic['NN_SSH']][:,:,:]
id_nemo.close()

[ nt, nj, ni ] = ssh.shape ; print ' Shape of SSH :', nt, nj, ni, '\n'

ssh_plot = nmp.zeros((nj,ni))

ssh_plot[:,:] = nmp.mean(ssh[:,:,:],axis=0)


ztot = nmp.sum(ssh_plot*Xmask*Xe1t*Xe2t)/nmp.sum(Xmask*Xe1t*Xe2t)
print 'ztot =', ztot

ssh_plot = ssh_plot - ztot
cztot = str(round(ztot,2))


# the Jean-Marc Molines method:
ji_lat0 = nmp.argmax(xlat[nj-1])  ; 

bp.plot("2d")(xlon[0,:], xlat[:,ji_lat0], ssh_plot[:,:], Xmask, -2., 2., 0.1,
              corca=vdic['ORCA'], lkcont=True, cpal='BrBG_r',
              cfignm=path_fig+'ssh_mean_'+CONFRUN, cbunit=r'$(m)$',
              ctitle='Mean SSH (corrected about z=0, removed '+cztot+'m), '+CONFRUN+' ('+cy1+'-'+cy2+')',
              lforce_lim=True, i_cb_subsamp=2,
              cfig_type=fig_type, lat_min=-77., lat_max=75., lpix=False, vcont_spec = [ 0. ])

Exemple #39
0
cf_nemo_moc = vdic[
    'DIAG_D'] + '/clim/aclim_' + CONFEXP + '_' + cy1 + '-' + cy2 + '_MOC.nc4'

bt.chck4f(cf_nemo_moc)
id_nemo = Dataset(cf_nemo_moc)
vz = id_nemo.variables['depthw'][:]
amoc = id_nemo.variables[cv_moc][0, :, :]
id_nemo.close()

[nk, nj] = amoc.shape
print ' Shape of AMOC :', nk, nj, '\n'

# Building a latitude vector:
vlat = nmp.zeros(nj)
ji_lat_mid_atlantic = bt.find_index_from_value(-28., xlon[0, :])
vlat[:] = xlat[:, ji_lat_mid_atlantic]

# Building the vertical mask:
msk_vert = nmp.zeros((nk, nj))
msk_vert[:, :] = nmp.sum(Xmask[:, :, :], axis=2)
idxm = nmp.where(msk_vert[:, :] > 0.)
msk_vert[idxm] = 1.

bp.plot("vert_section")( vlat[:], -vz[:], amoc[:,:], msk_vert[:,:], -4., 20., 1., \
                         lkcont=True, cpal='ncview_nrl', lzonal=False, xmin=10., xmax=70., dx=5.,
                         cfignm='AMOC_annual_'+CONFEXP, cbunit='Sv',
                         zmin=0., zmax=5000., l_zlog=False, cfig_type=fig_type,
                         czunit='Depth (m)', ctitle='AMOC, '+CONFEXP+' ('+cy1+'-'+cy2+')' )

print '\n Bye!'
Exemple #40
0
#############################################################

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'
        Fimb = nmp.zeros(nby)
        for jy in range(1,nby):
            Fimb[jy] = (FY[jy] - FY[jy-1])*Socean/Lt_1y
        Fimb[0] = nmp.nan
        bp.plot("1d_mon_ann")(VY, VY, Fimb, Fimb, cfignm=cdiag+'-imb_'+CONFEXP, dt=ittic,
                              cyunit='Sv', ctitle = CONFEXP+': '+clnm,
                              ymin=-0.8, ymax=0.8, dy=0.1, cfig_type=ff, y_cst_to_add=0.)



############################################################
# Time series of 3D-averaged 3D fields such as SST, SSS, SSH
    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)




if idfig == 'ts3d':

    nb_oce = len(bo.voce2treat)

    vzrange = [ '0-bottom', '0-100'  , '100-1000',   '1000-bottom'  ] ;  nbzrange = len(vzrange)
    vlab    = [ 'AllDepth', '0m-100m', '100m-1000m', '1000m-bottom' ]

    joce = 0
    for coce in bo.voce2treat[:]:

        cf_in = '3d_'+cvar+'_'+CONFRUN+'_'+coce+'.nc' ;  bt.chck4f(cf_in, script_name='plot_time_series.py')
ztot = nmp.sum(ssh_plot * Xmask * Xe1t * Xe2t) / nmp.sum(Xmask * Xe1t * Xe2t)
print 'ztot =', ztot

ssh_plot = ssh_plot - ztot
cztot = str(round(ztot, 2))

# the Jean-Marc Molines method:
ji_lat0 = nmp.argmax(xlat[nj - 1, :])

bp.plot("2d")(xlon[0, :],
              xlat[:, ji_lat0],
              ssh_plot[:, :],
              Xmask,
              -2.,
              2.,
              0.1,
              corca=vdic['ORCA'],
              lkcont=True,
              cpal='BrBG_r',
              cfignm=path_fig + 'ssh_mean_' + CONFEXP,
              cbunit=r'$(m)$',
              ctitle='Mean SSH (corrected about z=0, removed ' + cztot +
              'm), ' + CONFEXP + ' (' + cy1 + '-' + cy2 + ')',
              lforce_lim=True,
              i_cb_subsamp=2,
              cfig_type=fig_type,
              lat_min=-77.,
              lat_max=75.,
              lpix=False,
              vcont_spec=[0.])
Exemple #43
0
    # Summer

# the Jean-Marc Molines method:
ji_lat0 = nmp.argmax(xlat[nj - 1, :])

# Annual Curl:
bp.plot("2d")(xlon[0, :],
              xlat[:, ji_lat0],
              Xcurl_plot[0, :, :],
              Xmask,
              -Rmax,
              Rmax,
              dR,
              corca=vdic['ORCA'],
              lkcont=False,
              cpal=CPAL_CURL,
              cfignm=path_fig + 'tau_curl_annual_' + CONFEXP,
              cbunit=r'$(10^{-6}s^{-1})$',
              ctitle='Wind stress curl, ' + CONFEXP + ' (' + cy1 + '-' + cy2 +
              ')' + cextra_crl,
              lforce_lim=False,
              i_cb_subsamp=1,
              cfig_type=fig_type,
              lat_min=-77.,
              lat_max=75.,
              lpix=True)

if not l_tau_is_annual:
    # JFM Curl:
    bp.plot("2d")(xlon[0, :],
                  xlat[:, ji_lat0],
                  Xcurl_plot[1, :, :],
Exemple #44
0
    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)

    # 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,
                          cfig_type=ff)

if idfig == 'fwf':

    l_rnf = False
    l_emp = False
    l_prc = False
    l_clv = False
    l_evp = False
    l_evb = False
Exemple #45
0
vlat[:] = xlat[:, ji_lat0]

vz_nemo = nmp.zeros((Nt, nj))
# a zonal profile...
vz_nemo[:, :] = bt.mk_zonal(Xqsol_nemo, XMSK=Xmask)

ctt = 'Zonnaly-averaged annual Net Solar heat flux, ' + CONFEXP + ' (' + cy1 + '-' + cy2 + ') vs OBS.'
bp.plot("zonal")(vlat,
                 nmp.mean(vz_nemo, axis=0),
                 VY1=vlat_obs,
                 VZ1=nmp.mean(vz_obs, axis=0),
                 cfignm=path_fig + 'zonal_Qsol_vs_obs_annual_' + CONFEXP,
                 zmin=50.,
                 zmax=250.,
                 dz=10.,
                 xmin=-70.,
                 xmax=65.,
                 dx=10.,
                 czunit=r'$(W/m^2)$',
                 cfig_type=fig_type,
                 ctitle=ctt,
                 lab='NEMO (' + cv_qsol + ')',
                 lab1=vdic['NM_QSOL_OBS'],
                 loc_legend='center')

if Nt == 12:

    ctt = 'Zonnaly-averaged JFM Net Solar heat flux, ' + CONFEXP + ' (' + cy1 + '-' + cy2 + ') vs OBS.'
    bp.plot("zonal")(vlat,
                     nmp.mean(vz_nemo[:3, :], axis=0),
                     VY1=vlat_obs,
Exemple #46
0

    # Removing value for first year to all years:
    vy1 = nmp.zeros(nz) ; vy1[:] = XTe[:,0]
    for jy in range(nby): XTe[:,jy] = XTe[:,jy] - vy1[:]
    vy1 = nmp.zeros(nz) ; vy1[:] = XSe[:,0]
    for jy in range(nby): XSe[:,jy] = XSe[:,jy] - vy1[:]

    z0 = vdepth[0]
    zK = max(vdepth)

    [ rmin, rmax, rdf ] = bt.get_min_max_df(XTe,40)
    bp.plot("vert_section")(vyears[:], vdepth[:nz], XTe[:,:], XTe[:,:]*0.+1., rmin, rmax, rdf,
                            cpal='bbr2', xmin=yr1, xmax=yr2+1., dx=ixtics, lkcont=False,
                            zmin = z0, zmax = zK, l_zlog=True,
                            cfignm=path_fig+'hov_temperature_'+CONFRUN+'_'+coce, cbunit=r'$^{\circ}$C', cxunit='',
                            czunit='Depth (m)',
                            ctitle=CONFRUN+': Spatially-averaged temperature evolution, '+voceans_u[jo]+', ('+str(int(yr1))+'-'+str(int(yr2))+')',
                            cfig_type=fig_type, lforce_lim=True, i_cb_subsamp=2)

    XSe = 1000.*XSe
    [ rmin, rmax, rdf ] = bt.get_min_max_df(XSe,40)
    bp.plot("vert_section")(vyears[:], vdepth[:nz], XSe[:,:], XSe[:,:]*0.+1., rmin, rmax, rdf,
                            cpal='bbr2', xmin=yr1, xmax=yr2+1., dx=ixtics, lkcont=False,
                            zmin = z0, zmax = zK, l_zlog=True,
                            cfignm=path_fig+'hov_salinity_'+CONFRUN+'_'+coce, cbunit=r'10$^{-3}$PSU', cxunit='',
                            czunit='Depth (m)',
                            ctitle=CONFRUN+': Spatially-averaged salinity evolution, '+voceans_u[jo]+', ('+str(int(yr1))+'-'+str(int(yr2))+')',
                            cfig_type=fig_type, lforce_lim=True, i_cb_subsamp=2)

Exemple #47
0
# least-square curve for 5-month running mean:
sumx = nmp.sum(vtime[:])
sumy = nmp.sum(xnino[:, 1])
sumxx = nmp.sum(vtime[:] * vtime[:])
sumxy = nmp.sum(vtime[:] * xnino[:, 1])
a = (sumx * sumy - nt * sumxy) / (sumx * sumx - nt * sumxx)
b = (sumy - a * sumx) / nt
print 'a, b =', a, b

# least-square linear trend:
xnino[:, 2] = a * vtime[:] + b
print 'mean value for least-square linear trend = ', nmp.sum(xnino[:, 2]) / nt

# anomaly
xnino[:, 3] = xnino[:, 1] - xnino[:, 2]
# anomaly for 5-month running mean
print 'mean value for anomaly = ', nmp.sum(xnino[:, 3]) / nt

# save serie into a file:
#cf_out = cname+'_anomaly.nc'
#f = open(cf_out, 'w')
#f.write('# created with '+sys.argv[0]+' from file '+cf_in+'\n')
#f.write('# time, mean SST,  5-month RM,  linear trend,    anomaly     \n')
#for jt in range(nt):
#    f.write(str(round(vtime[jt],3))+'   '+str(round(xnino[jt,0],5))+'   '\
#            +str(round(xnino[jt,1],5))+'   '+str(round(xnino[jt,2],5))+'   '+str(round(xnino[jt,3],5))+'\n')
#print '\n'
#print ' ascii file '+cf_out+' created!\n'

bp.plot("enso")(vtime, xnino[:, 0], cfignm=cname, dt_year=ittic)