Exemple #1
0
def plot_climate_indices(E,
                         index_name,
                         copies_to_plot,
                         climatology_option='NODA',
                         hostname='taurus',
                         verbose=False):
    """
	This subroutine computes a bunch of simple climate indices 
	for a given experiment, and plots them for all copies given by 'copies_to_plot'

	INPUTS:
	copies_to_plot: list containing keywords for what copies to plot. Here are the options:  
	+ any valid copystring in DART output data  (e.g. "ensemble member 1")
	+ 'ensemble' = plot the entire ensemble  
	+ 'ensemble mean' = plot the ensemble mean  
	+ 'operational' = plot the operational value of this index 
	"""

    # create a list of copies to load
    copy_list = []

    if "copystring" in copies_to_plot:
        copy_list.append(E['copystring'])

    if ("ensemble" in copies_to_plot):
        N = dart.get_ensemble_size_per_run(E['exp_name'])
        for iens in np.arange(1, N + 1):
            if iens < 10:
                spacing = '      '
            else:
                spacing = '     '
            copy_list.append("ensemble member" + spacing + str(iens))
    if ("ensemble mean" in copies_to_plot):
        copy_list.append("ensemble mean")

    # retrieve desired index for all the copies in the list
    L = []
    for copy in copy_list:
        E['copystring'] = copy
        x = compute_climate_indices(E, index_name, climatology_option,
                                    hostname, verbose)
        L.append(x)

    # plot it
    for copy, climate_index in zip(copy_list, L):

        # define a color for the ensemble mean - depending on experiment
        lcolor = "#000000"
        if E['exp_name'] == 'W0910_NODA':
            bmap = brewer2mpl.get_map('Dark2', 'qualitative', 7)
            lcolor = bmap.hex_colors[1]
        if E['exp_name'] == 'W0910_GLOBAL':
            # make this one black, since it's sort of the reference
            lcolor = "#000000"
        if E['exp_name'] == 'W0910_TROPICS':
            bmap = brewer2mpl.get_map('Dark2', 'qualitative', 7)
            lcolor = bmap.hex_colors[0]

        # make the ensemble a lighter version of their original color
        ensemble_color = plot_tools.colorscale(lcolor, 1.6)

        # here is the plot
        if (copy == 'ensemble mean'):
            plt.plot(E['daterange'], climate_index, color=lcolor, linewidth=2)
        if "ensemble member" in copy:
            plt.plot(E['daterange'],
                     climate_index,
                     color=ensemble_color,
                     linewidth=1)
Exemple #2
0
def plot_climate_indices(E,index_name,copies_to_plot,climatology_option = 'NODA',hostname='taurus',verbose=False):

	"""
	This subroutine computes a bunch of simple climate indices 
	for a given experiment, and plots them for all copies given by 'copies_to_plot'

	INPUTS:
	copies_to_plot: list containing keywords for what copies to plot. Here are the options:  
	+ any valid copystring in DART output data  (e.g. "ensemble member 1")
	+ 'ensemble' = plot the entire ensemble  
	+ 'ensemble mean' = plot the ensemble mean  
	+ 'operational' = plot the operational value of this index 
	"""

	# create a list of copies to load
	copy_list = []

	if "copystring" in copies_to_plot:
		copy_list.append(E['copystring'])

	if ("ensemble" in copies_to_plot): 
		N = dart.get_ensemble_size_per_run(E['exp_name'])
		for iens in np.arange(1,N+1):
			if iens < 10:
				spacing = '      '
			else:
				spacing = '     '
			copy_list.append("ensemble member"+spacing+str(iens))		
	if ("ensemble mean" in copies_to_plot): 
			copy_list.append("ensemble mean")

	# retrieve desired index for all the copies in the list
	L = []
	for copy in copy_list:
		E['copystring'] = copy
		x = compute_climate_indices(E,index_name,climatology_option,hostname,verbose)
		L.append(x)

	# plot it  
	for copy,climate_index in zip(copy_list,L):

		# define a color for the ensemble mean - depending on experiment   
		lcolor = "#000000"
		if E['exp_name'] == 'W0910_NODA':
			bmap = brewer2mpl.get_map('Dark2', 'qualitative', 7)
			lcolor = bmap.hex_colors[1]
		if E['exp_name'] == 'W0910_GLOBAL':
			# make this one black, since it's sort of the reference  
			lcolor = "#000000"
		if E['exp_name'] == 'W0910_TROPICS':
			bmap = brewer2mpl.get_map('Dark2', 'qualitative', 7)
			lcolor = bmap.hex_colors[0]

		# make the ensemble a lighter version of their original color  
		ensemble_color = plot_tools.colorscale(lcolor, 1.6)

		# here is the plot  
		if (copy == 'ensemble mean'):
			plt.plot(E['daterange'],climate_index,color=lcolor,linewidth=2)
		if "ensemble member" in copy:
			plt.plot(E['daterange'],climate_index,color=ensemble_color,linewidth=1)