예제 #1
0
파일: MJO.py 프로젝트: timhoar/DARTpy
def plot_variance_maps(E,cbar=True,hostname="taurus"):

	# given a certain experiment or dataset over a certain daterange, 
	# plot the MJO-related variance on a map

	# load the variance map  
	VV,lat,lon = variance_maps(E,hostname=hostname)  

 	# set up the  map projection
	map = Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\
		    #llcrnrlon=-180,urcrnrlon=180,resolution='c')
		    llcrnrlon=0,urcrnrlon=360,resolution='c')

        # draw coastlines, country boundaries, fill continents.
	map.drawcoastlines(linewidth=0.25)
	map.drawcountries(linewidth=0.25)

        # draw lat/lon grid lines every 30 degrees.
	map.drawmeridians(np.arange(0,360,30),linewidth=0.25)
	map.drawparallels(np.arange(-90,90,30),linewidth=0.25)

        # compute native map projection coordinates of lat/lon grid.
	X,Y = np.meshgrid(lon,lat)
	x, y = map(X, Y)

        # choose color map based on the variable in question
	E['extras'] = 'MJO variance'
	colors,cmap,cmap_type = DSS.state_space_HCL_colormap(E)

	## if no color limits are specified, at least make them even on each side
        #if clim is None:
        #        clim = np.nanmax(np.absolute(VV))
	#print('------clim----------')
	#print(clim)


        # contour data over the map.
	cs = map.contourf(x,y,VV,15,cmap=cmap)
	#cs = map.contourf(x,y,M,len(colors)-1,colors=colors)
	#cs = map.contourf(X,Y,M,len(colors)-1,cmap=cmap,extend="both",vmin=-clim,vmax=clim)

	# apply color limits, but not if it's a log contour plot
	#if log_levels is None:
	#	print('applying color limits')
	#	if cmap_type == 'divergent':
	#		plt.clim([-clim,clim])
	#	else:
	#		plt.clim([0,clim])

	#if cbar:
	#	if (clim > 1000):
	#		CB = plt.colorbar(cs, shrink=0.6, extend='both',format='%.1e')
	#	if (clim < 0.001):
	#		CB = plt.colorbar(cs, shrink=0.6, extend='both',format='%.1e')
	#	else:
	CB = plt.colorbar(cs, shrink=0.6, extend='both')
예제 #2
0
파일: MJO.py 프로젝트: timhoar/DARTpy
def plot_correlations_lag_lat_or_lon(E,climatology_option='NODA',maxlag=25,lag_versus_what='lon',nilter_order=50,cbar=True,hostname="taurus",debug=False):

	"""
	 given a certain experiment or dataset over a certain daterange, 
	 plot the correlation between wind or precip anomalies in one reference
	 region, relative to everywhere else, either 
	 as a function of latitude and longite, and Lag.  
	 this should produce figures like Figs. 5-6 of Waliser et al. 

	INPUTS:  
	E - a standard DART experiment dictionary, with the variable field and level range corresponding to some MJO variable  
	maxlag: the limit of the lag (in days) that we look at 
	lag_versus_what: choose 'lat' or 'lon'  
	cbar: set to True to have a colorbar  
	hostname: computer name - default is Taurus  
	climatology_option: choose which climatology to take the anomalies to respect with -- default is "NODA"  
	"""

	# load the correlation field 
	R,S,L,x = correlations_lag_lat_or_lon(E,maxlag,lag_versus_what,filter_order,climatology_option,hostname=hostname,verbose=debug)

        # choose color map based on the variable in question
	E['extras'] = 'Correlation'
	colors,cmap,cmap_type = DSS.state_space_HCL_colormap(E,reverse=True)
	
	# choose axis labels  
	plt.ylabel('Lag (days)')
	if lag_versus_what=='lat':
		plt.xlabel('Latitude')
	if lag_versus_what=='lon':
		plt.xlabel('Longitude')

	# set the contour levels - it depends on the color limits and the number of colors we have  
	clim = 1.0
	if cmap_type == 'divergent':
		clevels  = np.linspace(start=-clim,stop=clim,num=11)
	else:
		clevels  = np.linspace(start=0,stop=clim,num=11)

        # contour plot of the chosen variable
	cs = plt.contourf(x,L,R,levels=clevels,cmap=cmap)
	plt.clim([-1.0,1.0])

	if (cbar is not None):
		CB = plt.colorbar(cs, shrink=0.6, extend='both', orientation=cbar)

	return x,L,R,S