コード例 #1
0
ファイル: Metrics.py プロジェクト: migtavares/DistExp
def filterMetric(reader, timeFrame=None):
    """
	@param reader is a MetricReader
	@param timeFrame is a tuple of start and end timestamps
		it can also be None (no time filter) or have one of
		the components (or both) as None (no filter on that
		respective side of time.
	@return two masked array"""
    import matplotlib.numerix.ma as MArray

    if timeFrame == None:
        timeFrame = [None, None]
    if timeFrame[0] == None:
        timeFrame[0] = 0
    if timeFrame[1] == None:
        timeFrame[1] = sys.maxint
    timeVector = []
    valueVector = []
    for m in reader:
        if m.timestamp != None:
            if m.timestamp >= timeFrame[0] and m.timestamp <= timeFrame[1]:
                timeVector.append(m.timestamp)
                valueVector.append(m.value)
    timeVector = MArray.array(timeVector)
    valueVector = MArray.array(valueVector)
    valueVector_masked = MArray.masked_where(valueVector == None, valueVector)
    return [timeVector, valueVector_masked]
コード例 #2
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def reconstruction_plot_w(mapobj, lats, lons, data_cube, lvl_num, parm, u, v,w, angs, mask, **kwargs):
	um=M.masked_where(M.array(mask) < 0.5, M.array(u))
	vm=M.masked_where(M.array(mask) < 0.5, M.array(v))
	mag=M.array(sqrt(u**2+v**2))
	magm=M.masked_where(M.array(mask)<0.5, mag)
	fig_name=kwargs.get('fig_name', 'recon_'+parm+'_.png')
	longr, latgr=meshgrid(lons,lats)
	xx, yy = mapobj(longr, latgr)
	mapobj.drawmapboundary()
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	mapobj.drawmeridians(array([130,130.5, 131, 131.5, 132]), labels=[1,0,0,1])
	mapobj.drawparallels(array([-13,-12.5,-12,-11.5,-11]), labels=[1,0,0,1])
	data=data_cube[parm][:,:,lvl_num]
	if parm in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff'}
	mapobj.contourf(xx,yy,data, levels=levs_dict[parm])
	colorbar()
	#mapobj.quiver(xx,yy,u/sqrt(u**2+v**2),v/sqrt(u**2+v**2), scale=50)
	qq=mapobj.quiver(xx,yy,um,vm, scale=kwargs.get('qscale', 200))
	quiverkey(qq, 0.1, 0.8, 10, '10 m/s', coordinates='figure')
	quiverkey(qq, 0.1, 0.75, 5, '5 m/s', coordinates='figure')
	quiverkey(qq, 0.1, 0.7, 2, '2 m/s', coordinates='figure')
	
	cobject=mapobj.contour(xx,yy,w, colors=['k'], levels=linspace(0,20,11))
	fon = { 'fontname':'Tahoma', 'fontsize':10 }
	clabel(cobject, fmt="%d", **fon)
	mapobj.contour(xx,yy,angs, levels=[30.0, 150.0],colors=['r']) 
コード例 #3
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def plot_slice_lon(lat_sl, data_cube, lats, lons, levs, u,w, mask, par='CZ', w_mag=2.0, **kwargs):
	ksp=kwargs.get('ksp', 0.05)
	bquiver=kwargs.get('bquiver', [0.1, 0.2])
	my_lat=argsort(abs(lats-lat_sl))[0]
	print lats[my_lat]
	data=M.masked_where(M.array(mask[my_lat,:,:])<0.5, M.array(data_cube[par][my_lat,:,:]))
	wm=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(w[my_lat,:,:]))
	um=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(u[my_lat,:,:]))
	if par in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-25,25,51), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31), 'VE':linspace(-25,25,51)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff', 'VE':'Edited velocity'}
	xx,yy=meshgrid(lons,levs)
	#gca().xaxis.major.formatter.set_powerlimits((-10.,10.))
	#contourf(xx, yy, transpose(data), levs_dict[par])
	pcolor(xx, yy, transpose(data), vmin=levs_dict[par].min(), vmax=levs_dict[par].max())
	#gca().xaxis.major.formatter.set_scientific(False)
	#print myaxis.formatter.limits
	colorbar()
	print "scale ", kwargs.get('qscale', 200)
	qq=quiver(xx, yy, transpose(um), transpose(wm*w_mag), scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	xlabel('Longitude (degrees)')
	ylabel('Height (Metres)')
	if 'box' in kwargs.keys():
		box=kwargs['box']
		ax=gca()
		cr=ax.axis()
		ax.axis([box[0], box[1], cr[2], cr[3]])
	return lats[my_lat]
コード例 #4
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def plot_slice_lat(lon_sl, data_cube, lats, lons, levs, v,w, mask, par='CZ', w_mag=2.0, **kwargs):
	ksp=kwargs.get('ksp', 0.05)
	bquiver=kwargs.get('bquiver', [0.95, 0.75])
	my_lon=argsort(abs(lons-lon_sl))[0]
	print lons[my_lon]
	data=M.masked_where(M.array(mask[:,my_lon,:])<0.5, M.array(data_cube[par][:,my_lon,:]))
	wm=M.masked_where(M.array(mask[:,my_lon,:]) < 0.5, M.array(w[:,my_lon,:]))
	vm=M.masked_where(M.array(mask[:,my_lon,:]) < 0.5, M.array(v[:,my_lon,:]))
	if par in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-25,25,51), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31), 'VE':linspace(-25,25,51)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff', 'VE':'Edited velocity'}
	print data.shape
	print wm.shape
	print vm.shape
	print lats.shape
	print levs.shape
	xx,yy=meshgrid(lats,levs)
	#contourf(xx, yy, transpose(data), levs_dict[par])
	pcolor(xx, yy, transpose(data), vmin=levs_dict[par].min(), vmax=levs_dict[par].max())
	colorbar()
	qq=quiver(xx, yy, transpose(vm), transpose(wm*w_mag), scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	xlabel('Latitude (degrees)')
	ylabel('Height (Metres)')
	if 'box' in kwargs.keys():
		box=kwargs['box']
		ax=gca()
		cr=ax.axis()
		ax.axis([box[2], box[3], cr[2], cr[3]])
	return lons[my_lon]
コード例 #5
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def plot_cappi(data,parm,lnum, **kwargs):
	x=data['xar']
	y=data['yar']
	radar_loc=data['radar_loc']
	radar_name=kwargs.get('radar_name', data['radar_name'])
	fig_name=kwargs.get('fig_name', 'cappi_'+parm+'_.png')
	f=figure()
	Re=6371.0*1000.0
	rad_at_radar=Re*sin(pi/2.0 -abs(radar_loc[0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
	lons=radar_loc[1]+360.0*(x-data['displacement'][0])/(rad_at_radar*2.0*pi)
	lats=radar_loc[0] + 360.0*(y-data['displacement'][1])/(Re*2.0*pi)
	def_loc_dict={'lat_0':lats.mean(), 'lon_0':lons.mean(),'llcrnrlat':lats.min(), 'llcrnrlon':lons.min(), 'urcrnrlat':lats.max() , 'urcrnrlon':lons.max(), 'lat_ts':lats.mean()}
	loc_dict=kwargs.get('loc_dict', def_loc_dict)
	#print 'Here'
	map= Basemap(projection='merc', resolution='l',area_thresh=1., **loc_dict)
	longr, latgr=meshgrid(lons,lats)
	xx, yy = map(longr, latgr)
	#print 'there'
	map.drawmapboundary()
	darwin_loc=[-12.5, 130.85]
	disp_from_darwin=mathematics.corner_to_point(darwin_loc, radar_loc)
	dist_from_darwin=sqrt(disp_from_darwin[0]**2+disp_from_darwin[1]**2)
	if dist_from_darwin < 500.*1000.: 
		map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	else:
		map.drawcoastlines()
	map.drawmeridians(array([129,130,131,132,133]), labels=[1,0,0,1])
	map.drawparallels(array([-14,-13,-12,-11,-10]), labels=[1,0,0,1])
	comp_levs=linspace(-1.,1., 30)
	#print 'everywhere'
	levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'PH': linspace(0,185,255), "RH": linspace(0,1.5,16), "SW":linspace(0, 5, 11), "ZD":linspace(-10,10,21), 'VE':linspace(-30,30,31), 'TI':linspace(-30,30,31)}
	#print 'or here?'
	titles_dict={'VR': 'Velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'PH': 'Differential Prop Phase (degrees)', 'RH':'Correlation Co-ef', 'SW':'Spectral Width (m/s)', 'ZD':'Differentail Reflectivity dBz', 'VE':'Edited Velocity (m/s)', 'TI':'Simualated winds,(m/s)'}
	#print parm
	if 'mask' in kwargs.keys():
		mask=kwargs['mask'][:,:,lnum]
		mdata=M.masked_where(M.array(mask) < 0.5, M.array(data[parm][:,:,lnum]))
		map.contourf(xx,yy,mdata, levels=levs_dict[parm])
	else:
		map.contourf(xx,yy,data[parm][:,:,lnum], levels=levs_dict[parm])
	colorbar()
	if 'angs' in kwargs.keys():
		map.contour(xx,yy,kwargs['angs'], levels=[30.0, 150.0],colors=['r']) 
	p=data['date']
	dtstr='%(#1)02d-%(#2)02d-%(#3)04d %(#4)02d%(#5)02dZ ' %{"#1":p.day, "#2":p.month, "#3":p.year, "#4":p.hour, '#5':p.minute}
	title(radar_name+' '+dtstr+titles_dict[parm])
	savefig(getenv('HOME')+'/bom_mds/output/'+fig_name)
	close(f)
コード例 #6
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def reconstruction_plot_pcolor(lats, lons, data_cube, lvl_num, parm, u, v,w, angs, mask, **kwargs):
	ber_loc=[-12.4, 130.85] #location of Berrimah radar
	gp_loc=[-12.2492,  131.0444]#location of CPOL at Gunn Point
	box=kwargs.get('box',[130.0, 132.0, -13.0, -11.5])#box for the plot
	bquiver=kwargs.get('bquiver', [0.1, 0.75])
	ksp=kwargs.get('ksp', 0.05)
	#Set up the map and projection
	mapobj= Basemap(projection='merc',lat_0=(box[2]+box[3])/2.0, lon_0=(box[0]+box[1])/2.0,llcrnrlat=box[2], llcrnrlon=box[0], urcrnrlat=box[3] , urcrnrlon=box[1], resolution='l',area_thresh=1., lat_ts=(box[2]+box[3])/2.0)
	#map.drawmapboundary()
	um=M.masked_where(M.array(mask) < 0.5, M.array(u))
	vm=M.masked_where(M.array(mask) < 0.5, M.array(v))
	mag=M.array(sqrt(u**2+v**2))
	magm=M.masked_where(M.array(mask)<0.5, mag)
	fig_name=kwargs.get('fig_name', 'recon_'+parm+'_.png')
	longr, latgr=meshgrid(lons,lats)
	xx, yy = mapobj(longr, latgr)
	mapobj.drawmapboundary()
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstqldmd_r', 'qcoast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	#mapobj.drawmeridians(array([130,130.5, 131, 131.5, 132]), labels=[1,0,0,1])
	#mapobj.drawparallels(array([-13,-12.5,-12,-11.5,-11]), labels=[1,0,0,1])
	data=M.masked_where(M.array(mask) < 0.5, M.array(data_cube[parm][:,:,lvl_num]))
	if parm in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-25,25,51), 'CZ': linspace(-8,64,10), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31), 'VE':linspace(-25,25,51)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff', 'VE':'Edited velocity'}
	mapobj.pcolor(xx,yy,data, vmin=levs_dict[parm].min(), vmax=levs_dict[parm].max())
	colorbar()
	#mapobj.quiver(xx,yy,u/sqrt(u**2+v**2),v/sqrt(u**2+v**2), scale=50)
	qq=mapobj.quiver(xx,yy,um,vm, scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	cobject=mapobj.contour(xx,yy,w, colors=['k'], levels=linspace(-10,10,6))
	fon = { 'fontname':'Tahoma', 'fontsize':5 }
	clabel(cobject, fmt="%1.1f", **fon)
	mapobj.contour(xx,yy,angs, levels=[30.0, 150.0],colors=['r']) 
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/nt_coast','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	mapobj.drawmeridians(linspace(0,4,41)+130., labels=[1,0,0,1], fontsize=rcParams['xtick.labelsize'])
	mapobj.drawparallels(linspace(0,4,41)-15.0, labels=[1,0,0,1], fontsize=rcParams['ytick.labelsize'])
	return mapobj
コード例 #7
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def plot_slice_lon_hydro_sym_refl(lat_sl, data_cube,hydro_cube, hydro_bins, u,w, mask, par='CZ', w_mag=2.0, **kwargs):
	lats=hydro_cube['lats']
	lons=hydro_cube['lons']
	levs=hydro_cube['zar']
	ksp=kwargs.get('ksp', 0.05)
	bquiver=kwargs.get('bquiver', [0.1, 0.2])
	my_lat=argsort(abs(lats-lat_sl))[0]
	print lats[my_lat]
	data=M.masked_where(M.array(hydro_cube['CZ'][my_lat,:,:])<0.0, M.array(hydro_cube['CZ'][my_lat,:,:]))
	wm=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(w[my_lat,:,:]))
	um=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(u[my_lat,:,:]))
	if par in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff'}
	xx,yy=meshgrid(lons,levs)
	plotting_syms={"unclassified":'k.', "Drizzle":'co', "Rain":'bo', "Dry LD snow":'cx', "Dry HD snow":'bx', "Melting Snow":'r+', "Dry Graupel":'bs', "Wet Graupel": 'rs', "Small Hail": 'cd', "Large Hail":'bD', "Rain + Hail":'g>'}
	for item in set(hydro_bins['bins'])-set(['unclassified']):
		plot(hydro_bins[item+"_lons"], hydro_bins[item+"_z"], plotting_syms[item])
	legend(set(hydro_bins['bins'])-set(['unclassified']))
	#gca().xaxis.major.formatter.set_powerlimits((-10.,10.))
	#gca().xaxis.major.formatter.set_scientific(False)
	#print myaxis.formatter.limits
	#pcolor(xx_hydro, yy_hydro, transpose(hydro_data), vmin=-0.5, vmax=10.5, cmap=cmap_discretize(cm.jet, 11))
	#colorbar()
	contour(xx, yy, transpose(data), levs_dict[par])
	print "QSCALE ", kwargs.get('qscale', 200)
	qq=quiver(xx, yy, transpose(um), transpose(wm*w_mag), scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	xlabel('Longitude (degrees)')
	ylabel('Height (Metres)')
	#item="Rain"
	if 'box' in kwargs.keys():
		box=kwargs['box']
		ax=gca()
		cr=ax.axis()
		ax.axis([box[0], box[1], cr[2], cr[3]])
	return lats[my_lat]
コード例 #8
0
ファイル: pres.py プロジェクト: scollis/bom_mds
def plot_slice_lon_hydro(lat_sl, data_cube, lats, lons, levs, hydro_cube, u,w, mask, par='CZ', w_mag=2.0, **kwargs):
	ksp=kwargs.get('ksp', 0.05)
	bquiver=kwargs.get('bquiver', [0.1, 0.2])
	my_lat=argsort(abs(lats-lat_sl))[0]
	my_lat_hydro=argsort(abs(hydro_cube['lats']-lat_sl))[0]
	print lats[my_lat]
	data=M.masked_where(M.array(mask[my_lat,:,:])<0.5, M.array(data_cube[par][my_lat,:,:]))
	hydro_data=M.masked_where(classify[my_lat_hydro,:,:]==-9.0, classify[my_lat_hydro,:,:])
	wm=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(w[my_lat,:,:]))
	um=M.masked_where(M.array(mask[my_lat,:,:]) < 0.5, M.array(u[my_lat,:,:]))
	if par in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff'}
	xx,yy=meshgrid(lons,levs)
	xx_hydro, yy_hydro=meshgrid(hydro_cube['lons'], hydro_cube['zar'])
	#gca().xaxis.major.formatter.set_powerlimits((-10.,10.))
	#gca().xaxis.major.formatter.set_scientific(False)
	#print myaxis.formatter.limits
	print "my_lat_hydro:", my_lat_hydro
	print hydro_cube['lats'][my_lat_hydro]
	pcolor(xx_hydro, yy_hydro, transpose(hydro_data), vmin=-0.5, vmax=10.5, cmap=cmap_discretize(cm.jet, 11))
	myc=colorbar()
	myc.ax.text(0.0, 3.0, "HD snow")
	#yticks((0,1,2,3),("Uncl", "Dz", "Ra", "HD Sn"))
	contour(xx, yy, transpose(data), levs_dict[par])
	qq=quiver(xx, yy, transpose(um), transpose(wm*w_mag), scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	xlabel('Longitude (degrees)')
	ylabel('Height (Metres)')
	if 'box' in kwargs.keys():
		box=kwargs['box']
		ax=gca()
		cr=ax.axis()
		ax.axis([box[0], box[1], cr[2], cr[3]])
	return lats[my_lat]
コード例 #9
0
X, Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z1 - Z2

# interior badmask doesn't work yet for filled contours
if test_masking:
    badmask = zeros(shape(Z))

    badmask[5, 5] = 1
    badmask[5, 6] = 1
    Z[5, 5] = 0
    Z[5, 6] = 0

    badmask[0, 0] = 1
    Z[0, 0] = 0
    Z = ma.array(Z, mask=badmask)

levels, colls = contourf(
    X,
    Y,
    Z,
    10,  # [-1, -0.1, 0, 0.1],
    #alpha=0.5,
    cmap=cm.bone,
    origin=origin)

levs2, colls2 = contour(X, Y, Z, levels, colors='r', origin=origin, hold='on')
savefig('contourf_demo')
show()
コード例 #10
0
ファイル: standard_curves.py プロジェクト: stuvet/bestpred
        b = mandg_means[breed][parity]['b']
        c = mandg_means[breed][parity]['c']
        d = mandg_means[breed][parity]['d']
        y = a - (b * day10) + ((c * day10**2) / 2) + (d / day10)
    return y


if __name__ == '__main__':

    for day in xrange(1, dimin + 1):
        dim.append(day)
        point = compute_curve_point(breed, trait, parity, day)
        std.append(point)
        stdsum = stdsum + point

    plotdim = M.array(dim)
    plotstd = M.array(std)
    maxdim = plotdim.max()

    if kgtolb == 1 and trait < 4:
        plotstd = plotstd * 2.2
        stdsum = stdsum * 2.2

    # Plot standard curves
    pylab.rcParams.update(params)
    fig = pylab.figure()
    plot = fig.add_subplot(111)
    plot_title = 'Standard curve for %s parity %s %s (%s d)' % ( number2parity[parity], \
        number2breed[breed], number2name[trait], dimin )
    pylab.title(plot_title)
    pylab.xlabel('DIM')
コード例 #11
0
ファイル: bestpred_curves.py プロジェクト: copen/bestpred
            if cowid != lastcowid or trait != lasttrait:
                if int(lasttrait) == int(plottrait) or int(plottrait) == 5:
                    if cowid != lastcowid:
                        #print 'Cowid changed from %s to %s' % ( lastcowid, cowid )
                        _cowid = lastcowid
                        _lacnum = lastlacnum
                    else:
                        _cowid = cowid
                        _lacnum = lacnum
                    if trait != lasttrait:
                        #print 'Trait changed from %s to %s' % ( lasttrait, trait )
                        _trait = lasttrait
                    else:
                        _trait = trait
                    # We're processing a new animal
                    plotdim = M.array(dim)
                    plottd_ = M.array(tdy)
                    plottdy = M.masked_where(plottd_ == threshold, plottd_)
                    plotla_ = M.array(lac)
                    plotlac = M.masked_where(plotla_ == -2.0, plotla_)
                    plotst_ = M.array(std)
                    plotstd = M.masked_where(plotst_ == threshold, plotst_)
                    plotdb_ = M.array(dbp)
                    plotdbp = M.masked_where(plotdb_ == threshold, plotdb_)
                    plotde_ = M.array(dev)
                    plotdev = M.masked_where(plotde_ == threshold, plotde_)
                    maxdim = plotdim.max()

                    if lbtokg == 1 and int(_trait) < 4:
                        plottdy = plottdy / 2.2
                        plotlac = plotlac / 2.2
コード例 #12
0
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10 * (Z1 - Z2)

# interior badmask doesn't work yet for filled contours
if test_masking:
    badmask = zeros(shape(Z))

    badmask[5,5] = 1
    badmask[5,6] = 1
    Z[5,5] = 0
    Z[5,6] = 0

    badmask[0,0] = 1
    Z[0,0] = 0
    Z = ma.array(Z, mask=badmask)

# We are using automatic selection of contour levels;
# this is usually not such a good idea, because they don't
# occur on nice boundaries, but we do it here for purposes
# of illustration.
CS = contourf(X, Y, Z, 10, # [-1, -0.1, 0, 0.1],
                        #alpha=0.5,
                        cmap=cm.bone,
                        origin=origin)

# Note that in the following, we explicitly pass in
# the contour levels used for the filled contours, so that
# the regions have outlines.  We could also pass in additional
# levels to provide extra resolution.
コード例 #13
0
ファイル: bestpred_curves.py プロジェクト: stuvet/bestpred
            if cowid != lastcowid or trait != lasttrait:
                if int(lasttrait) == int(plottrait) or int(plottrait) == 5:
                    if cowid != lastcowid:
                        #print 'Cowid changed from %s to %s' % ( lastcowid, cowid )
                        _cowid = lastcowid
                        _lacnum = lastlacnum
                    else:
                        _cowid = cowid
                        _lacnum = lacnum
                    if trait != lasttrait:
                        #print 'Trait changed from %s to %s' % ( lasttrait, trait )
                        _trait = lasttrait
                    else:
                        _trait = trait
                    # We're processing a new animal
                    plotdim = M.array(dim)
                    plottd_ = M.array(tdy)
                    plottdy = M.masked_where(plottd_ == threshold, plottd_)
                    plotla_ = M.array(lac)
                    plotlac = M.masked_where(plotla_ == -2.0, plotla_)
                    plotst_ = M.array(std)
                    plotstd = M.masked_where(plotst_ == threshold, plotst_)
                    plotdb_ = M.array(dbp)
                    plotdbp = M.masked_where(plotdb_ == threshold, plotdb_)
                    plotde_ = M.array(dev)
                    plotdev = M.masked_where(plotde_ == threshold, plotde_)
                    maxdim = plotdim.max()

                    if lbtokg == 1 and int(_trait) < 4:
                        plottdy = plottdy / 2.2
                        plotlac = plotlac / 2.2
コード例 #14
0
ファイル: analyze.py プロジェクト: leegao/Urban-RealEstate
def analyze(filter):
    sink = filter()
    #from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.axes
    import matplotlib.pyplot as plt
    import numpy as np
    import random
    import matplotlib.numerix.ma as M
    
    
    fig = plt.figure()
    ax=fig.add_subplot(111)
    
    X = []
    Y = []
    Z = []
    for k in sink:
        X += [k[0][0]]
        Y += [k[0][1]]
        Z += [k[1]]
    
    threshold = 1

    #prepare for masking arrays - 'conventional' arrays won't do it
    Y = M.array(Y)
    #mask values below a certain threshold
    Y = M.masked_where(Y < threshold , Y)
    
    X_min = min(X)
    X_range = max(X)-min(X)
    X_scale = 20.0/X_range
    
    Y_min = min(Y)
    Y_range = max(Y)-min(Y)
    Y_scale = 20.0/Y_range
    
    Z_min = min(Z)
    Z_range = max(Z)-min(Z)
    Z_scale = 1.0/Z_range
    
    colors = []
    for i in range(len(sink)):
        X[i] = (X[i]-X_min)*110.83575 #* X_scale
        Y[i] = (Y[i]-Y_min)*97.43888 #* Y_scale
        colors.append(tuple([0.2,0.1]+[1-Z[i]/max(Z)]*1+[1]))
    
    z = zip(*filter.coords)
    coords = zip( (np.array(z[0])-X_min)*110.83575, (np.array(z[1])-Y_min)*97.43888)

    X = np.array(X)
    Y = np.array(Y)
    Z = np.array(Z)
    
    ax.scatter(X, Y, marker = 's', color=colors, s = ((Z-Z_min+Z_min/Z_range)*Z_scale)**2*100)# color = [['r','b','y'][random.randint(0,2)] for i in range(len(sink))])
    ax.scatter(*zip(*coords), marker = '+')
    
    for i in range(len(filter.intersections)):
        ax.text(coords[i][0], coords[i][1], filter.intersections[i].replace(", Houston TX", "").replace("and", "\n"), fontsize=8, alpha = 0.5)
    #print ((Z-Z_min)*Z_scale)**4*15
    ax.set_xlabel('Latitudinal Offset')
    ax.set_ylabel('Longitudinal Offset')
    
    return plt
コード例 #15
0
ファイル: standard_curves.py プロジェクト: copen/bestpred
        a = mandg_means[breed][parity]['a']
        b = mandg_means[breed][parity]['b']
        c = mandg_means[breed][parity]['c']
        d = mandg_means[breed][parity]['d']
        y = a - ( b*day10 ) + (( c*day10**2 ) / 2) + ( d/day10 )
    return y

if __name__ == '__main__':

    for day in xrange(1,dimin+1):
        dim.append(day)
        point = compute_curve_point(breed,trait,parity,day)
        std.append(point)
        stdsum = stdsum + point

    plotdim = M.array(dim)
    plotstd = M.array(std)
    maxdim = plotdim.max()

    if kgtolb == 1 and trait < 4:
        plotstd = plotstd * 2.2
        stdsum = stdsum * 2.2

    # Plot standard curves
    pylab.rcParams.update(params)
    fig = pylab.figure()
    plot = fig.add_subplot(111)
    plot_title = 'Standard curve for %s parity %s %s (%s d)' % ( number2parity[parity], \
        number2breed[breed], number2name[trait], dimin )
    pylab.title(plot_title)
    pylab.xlabel('DIM')