Пример #1
0
    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)

    # 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':
Пример #2
0
    id_temp.close()

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


    if jo == 0:
        vyears = nmp.trunc(vyears) + 0.5 ; # in case 1990 and not 1990.5 !!!
        yr1=float(int(min(vyears)))
        yr2=float(int(max(vyears)))


    [nby, nz] = XT.shape

    ixtics = bt.iaxe_tick(nby)

    # Number of NaN vertical points:
    visnan = nmp.isnan(XT[0,:])
    nz_nan = nmp.sum(visnan)
    nz = nz - nz_nan

    XTe = nmp.zeros((nz,nby))
    XTe[:,:] = nmp.flipud(nmp.rot90(XT[:,:nz]))

    XSe = nmp.zeros((nz,nby))
    XSe[:,:] = nmp.flipud(nmp.rot90(XS[:,:nz]))



    # Removing value for first year to all years:
Пример #3
0
nb_years = y2 - y1 + 1

clist_runs = vdic['LIST_RUNS'].split()
clist_confruns = []

for crun in clist_runs:
    clist_confruns.append(vdic['CONF'] + '-' + crun)

print sys.argv[0] + ': will compare following runs: '
print clist_confruns
print ' ... saved into ' + cd_diag + '\n'

nbrun = len(clist_confruns)

ittic = bt.iaxe_tick(nb_years)

vtime = nmp.zeros(nb_years)
Xf = nmp.zeros((nbrun, nb_years))


def test_nb_mnth_rec(nbmn, nbyr, cnd):
    print ' *** nb. mnth. records =', nbmn
    if nbmn % 12 != 0:
        print 'ERROR: compare_time_series.py => number of monthly records is not a multile of 12 in the netcdf file! diag = ' + cnd
        sys.exit(0)
    if nbmn / 12 > nbyr:
        print 'ERROR: compare_time_series.py => too many monthly records in netcdf file! diag = ' + cnd
        print '     number of expected monthy records =', nbyr * 12
        print '                          number found =', nbmn
        sys.exit(0)
Пример #4
0
fig_type = 'png'

cf_in = DIAG_D + '/merid_transport_T_S_' + CONFRUN + '.nc'

if not os.path.exists(cf_in):
    print ' ERROR: plot_hovm_merid_trsp.py => old ascii file system not supported anymore!'
    print '        => need file ' + cf_in + ' !!!'
    sys.exit(0)

nbasins = len(bo.voce2treat)

id_in = Dataset(cf_in)

vyear = id_in.variables['time'][:]
Nby = len(vyear)
ittic = bt.iaxe_tick(Nby)
vyear = vyear - 0.5
vlat = id_in.variables['lat'][:]
Nlat = len(vlat)

for jb in range(nbasins):

    cbasin = bo.voce2treat[jb]
    # long name of basin
    cbas = cbasin[:3]
    # name as in cf_in ...

    if jb == 0:
        Xheat = nmp.zeros(nbasins * Nby * Nlat)
        Xheat.shape = [nbasins, Nby, Nlat]
        Xsalt = nmp.zeros(nbasins * Nby * Nlat)
Пример #5
0

clist_runs = vdic['LIST_RUNS'].split()
clist_confruns = []

for crun in clist_runs:
    clist_confruns.append(vdic['CONF']+'-'+crun)

print sys.argv[0]+': will compare following runs: '; print clist_confruns
print ' ... saved into '+cd_diag+'\n'

nbrun = len(clist_confruns)



ittic = bt.iaxe_tick(nb_years)

vtime = nmp.zeros(nb_years)
Xf = nmp.zeros((nbrun, nb_years))


def test_nb_mnth_rec(nbmn, nbyr, cnd):
    print ' *** nb. mnth. records =', nbmn
    if nbmn%12 != 0:
        print 'ERROR: compare_time_series.py => number of monthly records is not a multile of 12 in the netcdf file! diag = '+cnd
        sys.exit(0)
    if nbmn/12 > nbyr:
        print 'ERROR: compare_time_series.py => too many monthly records in netcdf file! diag = '+cnd
        print '     number of expected monthy records =', nbyr*12
        print '                          number found =', nbmn
        sys.exit(0)
Пример #6
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)')
Пример #7
0
if not os.path.exists(cf_in):
    print ' ERROR: plot_hovm_merid_trsp.py => old ascii file system not supported anymore!'
    print '        => need file '+cf_in+' !!!' ; sys.exit(0)



#list_basin_names, list_basin_lgnms = bo.get_basin_info(vdic['BM_FILE'])
# As in cdfmhst.F90:
list_basin_names = [ 'GLO','atl','pac','ind' ]
list_basin_lgnms = [ 'Global Ocean','Atlantic Ocean','Pacific Ocean','Indian Ocean' ]
nbasins = len(list_basin_names)


id_in = Dataset(cf_in)

vyear = id_in.variables['time'][:]   ; Nby = len(vyear) ; ittic = bt.iaxe_tick(Nby)
vyear = vyear - 0.5
vlat  = id_in.variables['lat'][:]    ; Nlat = len(vlat)

for joce in range(nbasins):

    cbas   = list_basin_names[joce] ; # name as in cf_in ...
    cbasin = list_basin_lgnms[joce] ; # long name of basin
    
    if joce == 0:
        Xheat = nmp.zeros(nbasins*Nby*Nlat) ; Xheat.shape = [ nbasins, Nby, Nlat ]
        Xsalt = nmp.zeros(nbasins*Nby*Nlat) ; Xsalt.shape = [ nbasins, Nby, Nlat ]
        rmiss_val = id_in.variables['zomht_'+cbas].getncattr('_FillValue')

    Xheat[joce,:,:] = id_in.variables['zomht_'+cbas][:,:]
    Xsalt[joce,:,:] = id_in.variables['zomst_'+cbas][:,:]
Пример #8
0
for csec in list_sections:


    Xst = nmp.flipud(nmp.rot90(id_in.variables['sigtrsp_'+csec][:,:]))
    print ' Shape of "sigtrsp_'+csec+'" => ', nmp.shape(Xst)

    # Annual array:
    vtime_ann, Xst_ann = bt.monthly_2_annual(vtime, Xst)



    # 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)
    


    
Пример #9
0
cf_in = DIAG_D+'/merid_transport_T_S_'+CONFRUN+'.nc'


if not os.path.exists(cf_in):
    print ' ERROR: plot_hovm_merid_trsp.py => old ascii file system not supported anymore!'
    print '        => need file '+cf_in+' !!!' ; sys.exit(0)




nbasins = len(bo.voce2treat)

id_in = Dataset(cf_in)

vyear = id_in.variables['time'][:]   ; Nby = len(vyear) ; ittic = bt.iaxe_tick(Nby)
vyear = vyear - 0.5
vlat  = id_in.variables['lat'][:]    ; Nlat = len(vlat)

for jb in range(nbasins):

    cbasin = bo.voce2treat[jb] ; # long name of basin
    cbas   = cbasin[:3] ;           # name as in cf_in ...
    
    if jb == 0:
        Xheat = nmp.zeros(nbasins*Nby*Nlat) ; Xheat.shape = [ nbasins, Nby, Nlat ]
        Xsalt = nmp.zeros(nbasins*Nby*Nlat) ; Xsalt.shape = [ nbasins, Nby, Nlat ]

    Xheat[jb,:,:] = id_in.variables['zomht_'+cbas][:,:]
    Xsalt[jb,:,:] = id_in.variables['zomst_'+cbas][:,:]
    print ' *** zomht_'+cbas+' and zomst_'+cbas+' sucessfully read into '+cf_in
Пример #10
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)')
Пример #11
0
cf_in = DIAG_D + "/merid_transport_T_S_" + CONFRUN + ".nc"


if not os.path.exists(cf_in):
    print " ERROR: plot_hovm_merid_trsp.py => old ascii file system not supported anymore!"
    print "        => need file " + cf_in + " !!!"
    sys.exit(0)


nbasins = len(bo.voce2treat)

id_in = Dataset(cf_in)

vyear = id_in.variables["time"][:]
Nby = len(vyear)
ittic = bt.iaxe_tick(Nby)
vyear = vyear - 0.5
vlat = id_in.variables["lat"][:]
Nlat = len(vlat)

for jb in range(nbasins):

    cbasin = bo.voce2treat[jb]
    # long name of basin
    cbas = cbasin[:3]
    # name as in cf_in ...

    if jb == 0:
        Xheat = nmp.zeros(nbasins * Nby * Nlat)
        Xheat.shape = [nbasins, Nby, Nlat]
        Xsalt = nmp.zeros(nbasins * Nby * Nlat)
Пример #12
0
fig_type='png'


bt.chck4f(cf_in)
id_in = Dataset(cf_in)
vtime = id_in.variables['time'][:] ; nbm = len(vtime)
vsst  = id_in.variables[NN_SST][:]
id_in.close()


nt = len(vsst)
print ' => '+str(nt)+' months  => '+str(nt/12)+' years\n'


ittic = bt.iaxe_tick(nt/12)


# Array to contain nino series:
xnino = nmp.zeros(nt*4) ; xnino.shape = [ nt, 4 ]


for jt in nmp.arange(nt): xnino[jt,0] = vsst[jt]


# 5-month running mean:

for jt in nmp.arange(2,nt-2):
    xnino[jt,1] = (xnino[jt-2,0] + xnino[jt-1,0] + xnino[jt,0] + xnino[jt+1,0] + xnino[jt+2,0]) / 5.

xnino[0:2,1] = xnino[2,1] ; xnino[nt-2:nt,1] = xnino[nt-3,1]
Пример #13
0
print "\n"

fig_type = 'png'

bt.chck4f(cf_in)
id_in = Dataset(cf_in)
vtime = id_in.variables['time'][:]
nbm = len(vtime)
vsst = id_in.variables[NN_SST][:]
id_in.close()

nt = len(vsst)
print ' => ' + str(nt) + ' months  => ' + str(nt / 12) + ' years\n'

ittic = bt.iaxe_tick(nt / 12)

# Array to contain nino series:
xnino = nmp.zeros(nt * 4)
xnino.shape = [nt, 4]

for jt in nmp.arange(nt):
    xnino[jt, 0] = vsst[jt]

# 5-month running mean:

for jt in nmp.arange(2, nt - 2):
    xnino[jt, 1] = (xnino[jt - 2, 0] + xnino[jt - 1, 0] + xnino[jt, 0] +
                    xnino[jt + 1, 0] + xnino[jt + 2, 0]) / 5.

xnino[0:2, 1] = xnino[2, 1]