コード例 #1
0
    indirhn = '/data/ericglod/Density_binning/Prod_density_april15/mme_histNat/'
    filehn_2d = 'cmip5.multimodel_All.historicalNat.ensm.an.ocn.Omon.density_zon2D.nc'
    filehn_1d = 'cmip5.multimodel_All.historicalNat.ensm.an.ocn.Omon.density_zon1D.nc'
    fh2d = open_ncfile(indir_rcp85 + filercp85_2d, 'r')
    fh1d = open_ncfile(indir_rcp85 + filercp85_1d, 'r')
    fhn2d = open_ncfile(indirhn + filehn_2d, 'r')
    fhn1d = open_ncfile(indirhn + filehn_1d, 'r')

# ----- Variables ------

# == Read variables ==
lat = fh2d.variables['latitude'][:]

if name == 'Durack & Wijffels':
    # -- Choose wich variable to work on
    varname = defVarDurack('salinity'); v = 'S'
    # varname = defVarDurack('temp'); v = 'T'

    density = fh2d.variables['density'][:]
    var_mean = varname['var_mean_zonal']
    var_change = varname['var_change_zonal']
    var_change_er = varname['var_change_zonal_er']

    var_attributes = fh2d.variables[var_mean]
    var_mean = fh2d.variables[var_mean][:].squeeze()
    var_change = fh2d.variables[var_change][:].squeeze()
    var_change_er = fh2d.variables[var_change_er][:].squeeze()
    # -- Determine field in 1950 and 2000 from mean field
    var_1950 = var_mean - var_change/2
    var_2000 = var_mean + var_change/2
コード例 #2
0
if lat_choice == 'one':
    lat1 = -20
    lat1_idx = np.argmin(np.abs(lat - lat1))
else:
    latmin = -25
    latmax = -15
    latmin_idx = np.argmin(np.abs(lat - latmin))
    latmax_idx = np.argmin(np.abs(lat - latmax))
    weights = np.cos(lat*np.pi/180)
    weights = weights[latmin_idx:latmax_idx+1]
    #print(np.shape(weights))
    #print(weights)

# -- Read and build variables
if name == 'Durack&Wijffels':
    varname = defVarDurack(varname)
    var_diff = varname['var_change']
    if lat_choice == 'one':
        var_diff = f.variables[var_diff][:,:,lat1_idx,:].squeeze()
    else:
        var_diff = f.variables[var_diff][:,:,latmin_idx:latmax_idx+1,:].squeeze()
        var_diff = np.ma.average(var_diff, axis=1, weights=weights)
    density = f.variables['density'][:]
    #Masked values in white
    var_diff[var_diff > 4] = 0

elif name == 'mme_hist':
    varname = defVarmme(varname)
    var = varname['var_global']
    if lat_choice == 'one':
        var = f.variables[var][88:,:,lat1_idx,:].squeeze()
コード例 #3
0
indir = '/data/ericglod/Density_binning/Obs_Prod_density_april16/'
file = 'DurackandWijffels_GlobalOceanChanges-NeutralDensity_1950-2000_120209_11_46_11_beta.nc'
name = 'Durack & Wijffels'

data = indir + file

f = open_ncfile(data, 'r')

# ----- Variables ------

# Read variables
density = f.variables['density'][:]
lat = f.variables['latitude'][:]
lon = f.variables['longitude'][:]

varname = defVarDurack('temp')
v = 'T'
#varname = defVarDurack('salinity'); v='S'

# -- Look at zonal differences or not
zonal_change = 'No'
#zonal_change = 'global' # Zonal mean is global
#zonal_change = 'basin' # Differentiate the basins when building the zonal mean

# Define variable properties
minmax = varname['minmax']
clevsm = varname['clevsm']
clevsm_bold = varname['clevsm_bold']
legVar = varname['legVar']
unit = varname['unit']
var_change = varname['var_change']
コード例 #4
0
if lat_choice == 'one':
    lat1 = -20
    lat1_idx = np.argmin(np.abs(lat - lat1))
else:
    latmin = -25
    latmax = -15
    latmin_idx = np.argmin(np.abs(lat - latmin))
    latmax_idx = np.argmin(np.abs(lat - latmax))
    weights = np.cos(lat * np.pi / 180)
    weights = weights[latmin_idx:latmax_idx + 1]
    #print(np.shape(weights))
    #print(weights)

# -- Read and build variables
if name == 'Durack&Wijffels':
    varname = defVarDurack(varname)
    var_diff = varname['var_change']
    if lat_choice == 'one':
        var_diff = f.variables[var_diff][:, :, lat1_idx, :].squeeze()
    else:
        var_diff = f.variables[var_diff][:, :, latmin_idx:latmax_idx +
                                         1, :].squeeze()
        var_diff = np.ma.average(var_diff, axis=1, weights=weights)
    density = f.variables['density'][:]
    #Masked values in white
    var_diff[var_diff > 4] = 0

elif name == 'mme_hist':
    varname = defVarmme(varname)
    var = varname['var_global']
    if lat_choice == 'one':