Exemplo n.º 1
0
def convert(unit,var):
    mmrtovmr=1/(variables_attributes.attributes(var)[4])
    molmass=variables_attributes.attributes(var)[-1]
    if unit=='ppmv':
        conversion = 1E6*mmrtovmr
    elif unit=='ppbv':
        conversion = 1E9*mmrtovmr
    elif unit=='pptv':
        conversion = 1E12*mmrtovmr
    elif unit=='h':
        conversion = (1/3600.0)		# from s
    elif unit=='days':
        conversion = (1/(3600.0*24))	# from s
    else:
        conversion=1
    return conversion
Exemplo n.º 2
0
def convert(unit, var):
    mmrtovmr = 1 / (variables_attributes.attributes(var)[4])
    molmass = variables_attributes.attributes(var)[-1]
    if unit == 'ppmv':
        conversion = 1E6 * mmrtovmr
    elif unit == 'ppbv':
        conversion = 1E9 * mmrtovmr
    elif unit == 'pptv':
        conversion = 1E12 * mmrtovmr
    elif unit == 'h':
        conversion = (1 / 3600.0)  # from s
    elif unit == 'days':
        conversion = (1 / (3600.0 * 24))  # from s
    else:
        conversion = 1
    return conversion
Exemplo n.º 3
0
def convert2(unit,var,airmass):
    mmrtovmr=1/(variables_attributes.attributes(var)[4])
    molmass=variables_attributes.attributes(var)[-1]
    if unit=='ppmv':
        conversion = 1E6*mmrtovmr
    elif unit=='ppbv':
        conversion = 1E9*mmrtovmr
    elif unit=='pptv':
        conversion = 1E12*mmrtovmr
    elif unit==r'$\mathrm{molecules\ cm^{-3}}$': 
# OH(kg/kg) * mAir(kg) * Na(mol-1) / (Vgridcell(cm-3) * mMol(kg.mol-1) )
        volfile = ncdf.Dataset('/homes/pjt50/plotting/idl/newncfiles/ukca_geovol.nc','r')
        Vcell = np.array(volfile.variables['vol_theta'], dtype=np.float64)[:]
        conversion = airmass*6.022E23/(1E6*Vcell*molmass*1E-3)
    elif unit=='h':
        conversion = (1/3600.0)		# from s
    elif unit=='days':
        conversion = (1/(3600.0*24))	# from s
    else:
        conversion=1
    return conversion
Exemplo n.º 4
0
def convert2(unit, var, airmass):
    mmrtovmr = 1 / (variables_attributes.attributes(var)[4])
    molmass = variables_attributes.attributes(var)[-1]
    if unit == 'ppmv':
        conversion = 1E6 * mmrtovmr
    elif unit == 'ppbv':
        conversion = 1E9 * mmrtovmr
    elif unit == 'pptv':
        conversion = 1E12 * mmrtovmr
    elif unit == r'$\mathrm{molecules\ cm^{-3}}$':
        # OH(kg/kg) * mAir(kg) * Na(mol-1) / (Vgridcell(cm-3) * mMol(kg.mol-1) )
        volfile = ncdf.Dataset(
            '/homes/pjt50/plotting/idl/newncfiles/ukca_geovol.nc', 'r')
        Vcell = np.array(volfile.variables['vol_theta'], dtype=np.float64)[:]
        conversion = airmass * 6.022E23 / (1E6 * Vcell * molmass * 1E-3)
    elif unit == 'h':
        conversion = (1 / 3600.0)  # from s
    elif unit == 'days':
        conversion = (1 / (3600.0 * 24))  # from s
    else:
        conversion = 1
    return conversion
Exemplo n.º 5
0
file1 = '/' + disk + '/ih280/um/' + jobid + '/' + jobid + stash + '.nc'
ncbase = ncdf.Dataset(file1, 'r')
# time,model_level_number,latitude,longitude

# dimensions
lat = np.array(ncbase.variables['latitude'], dtype=np.float64)[:]
hgt = np.array(ncbase.variables['level_height'], dtype=np.float64)[:]

data = ncbase.variables[var]
print data

#import numpy.ma as ma
#new_data = np.ma.masked_where(np.ma.getmask(mask), data)

# attributes
attributes = variables_attributes.attributes(var)
name = attributes[0]
formula = attributes[2]
# Convert unit
conversion = convert_unit.convert(unit, var)
data = data[:] * conversion
data = data[:] * mask[:]

#data_m     = data[:]
#np.ma.set_fill_value(data_m,0.)
#data_m[data_m.mask] = data_m.fill_value

# Zonal mean
data1 = np.mean(np.mean(\
 data[:,:,:,:]\
 , axis=3, dtype=np.float64)\
Exemplo n.º 6
0
cmap = cm.bwr
cnorm=clrs.Normalize(cmap,clip=False)
cmap.set_under(color=cmap(0.0),alpha=1.0)
cmap.set_over(color=cmap(1.0),alpha=1.0)
#************************************************************
# Read in files
# time,model_level_number,latitude,longitude

file1     = '/'+disk+'/ih280/um/'+jobid+'/'+jobid+stash+'.nc'
ncbase    = ncdf.Dataset(file1,'r')

data       = ncbase.variables[var]
print data

# attributes
attributes = variables_attributes.attributes(var)
varname       = attributes[0]
formula    = attributes[2]

# convert to unit
conversion = convert_unit.convert(unit,var)
data       = data[:]*conversion

#***********************************************************
# Tropospheric mask: 1 for troposphere, 0 other				
#INPUT: 
#ncfile	= file containing tropopause height
#LTROP  = 1 for troposphere (i.e. mask out stratosphere); 0 otherwise
#tmean  = 0 (no time meaning),
#	  1 (climatological monthly mean), 
#	  2 (full time mean),