예제 #1
0
def plot_data(ax, data, dwarf):
    """
	Plots an individual dwarf galaxy's abundance data on the subplot.

	Parameters
	==========
	ax :: matplotlib subplot
		The axis to plot the abundance data on
	data :: 2D-list
		The raw data itself
	dwarf :: str
		A key denoting which dwarf is being plotted. These appear in the first
		column of the argument data.
	"""
    FeH_column = 12
    MgFe_column = 14
    fltrd = list(filter(lambda x: x[0] == dwarf, data))
    kwargs = {
        "c": visuals.colors()[_COLORS_[dwarf]],
        "marker": visuals.markers()[_MARKERS_[dwarf]],
        "linestyle": "None",
        "label": _NAMES_[dwarf],
        "s": _SIZES_[dwarf]
    }
    if dwarf == "LeoI": kwargs["zorder"] = 0
    ax.scatter([row[FeH_column] for row in fltrd],
               [row[MgFe_column] for row in fltrd], **kwargs)
예제 #2
0
def plot_yield(ax, element, study, MH, vrot, marker, color):
    """
	Plots a single IMF-averaged CCSN yield of Sr on the axis

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to plot on
	element :: str
		The element to plot the yield of
	study :: str
		The study to adopt the yields from
	MH :: real number
		The value of [M/H] to calculate the yield for
	vrot :: real number
		The rotational velocity of the stars in km/s
	marker :: str
		The name of the marker to plot the point in
	color :: str
		The name of the color to plot the yield in
	"""
    y = vice.yields.ccsne.fractional(element,
                                     study=study,
                                     MoverH=MH,
                                     rotation=vrot)[0]
    ax.scatter(MH,
               y,
               c=visuals.colors()[color],
               marker=visuals.markers()[marker],
               s=100)
예제 #3
0
def plot_ssp_legend(ax):
    """
	Draws the labels for the SN Ia DTD

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the legend on
	"""
    lines = 2 * [None]
    labels = [
        r"$R_\text{Ia}\propto t^{-1.1}$",
        r"$R_\text{Ia}\propto e^{-t/\tau_\text{Ia}}$"
    ]
    for i in range(2):
        lines[i] = ax.plot([1, 2], [1, 2],
                           c=visuals.colors()["black"],
                           label=labels[i],
                           linestyle=[':', '--'][i])[0]
    leg = ax.legend(loc=visuals.mpl_loc()["upper left"],
                    ncol=1,
                    bbox_to_anchor=(0.01, 0.99),
                    frameon=False)
    for i in range(2):
        lines[i].remove()
예제 #4
0
def plot_fractional_ssp_yield(ax, element, color, linestyle, z, ria): 
	""" 
	Plot the fractional single stellar population yield for a given element 
	and metallicity of the stellar population. 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	element :: str 
		The element to plot the enrichment of 
	color :: str 
		The name of the color to plot in 
	linestyle :: str 
		The matplotlib linestyle to use 
	z :: real number 
		The metallicity of the stellar population 
	ria :: real number 
		The SN Ia DTD to adopt 
	""" 
	mass, times = vice.single_stellar_population(element, Z = z, RIa = ria)
	final = mass[-1]
	fractional = [i/final for i in mass]
	ax.plot(times, fractional, c = visuals.colors()[color], 
		linestyle = linestyle) 
예제 #5
0
def legend(ax):
    """
	Draws the legend differentiating between the yield models

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the yield on
	"""
    lines = 3 * [None]
    colors = ["black", "deepskyblue", "crimson"]
    labels = [
        r"Constant $y_\text{Sr}^\text{CC}$",
        r"$y_\text{Sr}^\text{CC} \propto 1-e^{-kZ}$",
        r"$y_\text{Sr}^\text{CC} \propto Z$"
    ]
    for i in range(3):
        lines[i] = ax.plot([1, 2], [1, 2],
                           c=visuals.colors()["white"],
                           label=labels[i])[0]
    leg = ax.legend(loc=visuals.mpl_loc()["lower right"],
                    ncol=1,
                    bbox_to_anchor=(0.98, 0.02),
                    frameon=False,
                    handlelength=0)
    for i in range(3):
        lines[i].remove()
        leg.get_texts()[i].set_color(colors[i])
예제 #6
0
def plot_vs_metallicity_legend(ax):
    """
	Plots the legend on the late-time panel denoting the form of the adopted
	CCSN yield of Sr

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the legend on
	"""
    lines = 4 * [None]
    labels = [
        r"$y_\text{Sr}^\text{CC} = 0$", r"Constant $y_\text{Sr}^\text{CC}$",
        r"$y_\text{Sr}^\text{CC} \propto Z$",
        r"$y_\text{Sr}^\text{CC} \propto 1 - e^{-kZ}$"
    ]
    colors = ["black", "crimson", "lime", "deepskyblue"]
    for i in range(len(lines)):
        lines[i] = ax.plot([1, 2], [1, 2],
                           c=visuals.colors()["white"],
                           label=labels[i])[0]
    leg = ax.legend(loc=visuals.mpl_loc()["upper left"],
                    ncol=1,
                    bbox_to_anchor=(0.02, 0.98),
                    frameon=False,
                    handlelength=0)
    for i in range(len(lines)):
        lines[i].remove()
        leg.get_texts()[i].set_color(colors[i])
예제 #7
0
def plot_legend(ax):
    """
	Draws the legend denoting the yield assumptions

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the legend on
	"""
    lines = 4 * [None]
    colors = ["black", "deepskyblue", "lime", "crimson"]
    labels = [
        r"Constant $y_\text{Sr}^\text{CC}$",
        r"$y_\text{Sr}^\text{CC} \propto 1 - e^{-kZ}$",
        r"$y_\text{Sr}^\text{CC} \propto Z$", r"$y_\text{Sr}^\text{CC}$ = 0"
    ]
    for i in range(4):
        lines[i] = ax.plot([1, 2], [1, 2],
                           c=visuals.colors()["white"],
                           label=labels[i])[0]
    leg = ax.legend(loc=visuals.mpl_loc()["upper left"],
                    ncol=1,
                    bbox_to_anchor=(0.0, 0.99),
                    frameon=False,
                    handlelength=0)
    for i in range(4):
        lines[i].remove()
        leg.get_texts()[i].set_color(colors[i])
예제 #8
0
def plot_history(axes, name, color, linestyle = '-'):
	"""
	Plots the relevant information for a given history on the 2x2 axis grid

	Parameters
	==========
	axes :: list
		The 2x2 list of matplotlib axis objects to plot on
	name :: str
		The name of the model to plot
	color :: str
		The name of the color to use in plotting the model
	"""
	hist = vice.history(name)
	# axes[0][0].plot(hist["time"], hist["ifr"], linestyle = '--',
	# 	c = visuals.colors()[color])
	axes[0][0].plot(hist["time"], hist["sfr"], c = visuals.colors()[color],
		linestyle = linestyle)
	if linestyle == '-':
		axes[0][1].plot(hist["[Fe/H]"], hist["[O/Fe]"],
			c = visuals.colors()[color], linestyle = linestyle)
		axes[1][0].plot(hist["time"], hist["[O/H]"], linestyle = '--',
			c = visuals.colors()[color])
		axes[1][0].plot(hist["time"], hist["[Fe/H]"], linestyle = '-',
			c = visuals.colors()[color])
	else:
		axes[1][0].plot(hist["time"], hist["[O/H]"], linestyle = linestyle,
			c = visuals.colors()[color])
		axes[1][0].plot(hist["time"], hist["[Fe/H]"], linestyle = linestyle,
			c = visuals.colors()[color])
	axes[1][1].plot(hist["time"], hist["[O/Fe]"], c = visuals.colors()[color],
		linestyle = linestyle)
예제 #9
0
def plot_AGB_yields_fixed_Z(ax, m, y, color):
	"""
	Plots AGB star yields as a function of mass on a given subplot 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	m :: list 
		The stellar masses 
	y :: list 
		The fractional yields 
	color :: str 
		The name of the color to plot the yields in 
	"""
	ax.scatter(m, y, c = visuals.colors()[color], 
		marker = visuals.markers()["circle"])
	ax.plot(m, y, c = visuals.colors()[color])
예제 #10
0
def plot_oscillatory(axes, output, color):
	"""
	Plot the oscillations in [O/Fe] and [Fe/H] against time

	Parameters
	==========
	axes :: list
		The list of matplotlib axis objects to plot on
	output :: vice.output
		The VICE output object containing the simulation results
	color :: str
		The name of the color to plot in

	"""
	axes[0].plot(output.history["time"], output.history["[Fe/H]"],
		c = visuals.colors()[color])
	axes[1].plot(output.history["time"], output.history["[O/Fe]"],
		c = visuals.colors()[color])
예제 #11
0
def plot_legend(ax):
    """
	Draws the legend on the axis

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the legend on
	"""

    # First label the studies ...
    lines = len(_STUDIES_) * [None]
    for i in range(len(lines)):
        lines[i] = ax.plot([-1, -2], [1.e-8, 1.e-6],
                           c=visuals.colors()["white"],
                           label=_NAMES_[_STUDIES_[i]])[0]
    leg = ax.legend(loc=visuals.mpl_loc()["lower right"],
                    ncol=1,
                    bbox_to_anchor=(0.99, 0.01),
                    frameon=False,
                    handlelength=0,
                    fontsize=18)
    for i in range(len(lines)):
        lines[i].remove()
        leg.get_texts()[i].set_color(_COLORS_[_STUDIES_[i]])
    ax.add_artist(leg)

    # ... then label the rotational velocities
    points = 3 * [None]
    for i in range(len(points)):
        points[i] = ax.scatter(
            [-1, -2], [1.e-8, 1.e-6],
            c=visuals.colors()["black"],
            s=50,
            marker=visuals.markers()[_MARKERS_[[0, 150, 300][i]]],
            label=r"$v_\text{rot}$ = %g km s$^{-1}$" % ([0, 150, 300][i]))
    ax.legend(loc=visuals.mpl_loc()["upper left"],
              ncol=1,
              bbox_to_anchor=(0.01, 0.99),
              frameon=False,
              fontsize=18,
              handlelength=1)
    for i in range(len(points)):
        points[i].remove()
예제 #12
0
def plot_legend(ax):
	lines = 3 * [None]
	linestyles = ['-', ':', '--']
	colors = ["red", "black", "black"]
	labels = ["Sr", r"Fe; $R_\text{Ia}\propto t^{-1.1}$",
		r"Fe; $R_\text{Ia}\propto e^{-t/\tau_\text{Ia}}$"]
	for i in range(3):
		lines[i] = ax.plot([1, 2], [1, 2], c = visuals.colors()[colors[i]],
			linestyle = linestyles[i], label = labels[i])[0]
	leg = ax.legend(loc = visuals.mpl_loc()["lower left"], ncol = 1,
		bbox_to_anchor = (0.01, 0.01), frameon = False)
	for i in range(3):
		lines[i].remove()
예제 #13
0
def plot_output(axes, name, color):
    """
	Plots a VICE output on the output figure

	Parameters
	==========
	axes :: 1-D list
		The list of matplotlib axis objects to plot on
	name :: str
		The name of the VICE output
	color :: str
		The name of the color to plot in
	"""
    out = vice.output(name)
    axes[0].plot(out.history["[Fe/H]"],
                 out.history["[Sr/Fe]"],
                 c=visuals.colors()[color])
    bin_centers = list(
        map(lambda x, y: (x + y) / 2., out.mdf["bin_edge_left"],
            out.mdf["bin_edge_right"]))
    axes[1].plot(bin_centers,
                 out.mdf["dn/d[sr/fe]"],
                 c=visuals.colors()[color])
예제 #14
0
def plot_output_3axes(axes, name, color):
    """
	Overrides the visuals.plot_output_3axes function to omit time = 0 for the
	infall rate. VICE does not know the infall rate at time = 0 when ran in
	star formation mode.
	"""
    out = vice.output(name)
    axes[0].plot(out.history["time"][1:],
                 out.history["ifr"][1:],
                 c=visuals.colors()[color],
                 linestyle='--')
    axes[0].plot(out.history["time"],
                 out.history["sfr"],
                 c=visuals.colors()[color],
                 linestyle='-')
    axes[1].plot(out.history["[Fe/H]"],
                 out.history["[O/Fe]"],
                 c=visuals.colors()[color])
    axes[2].plot(list(
        map(lambda x, y: (x + y) / 2., out.mdf["bin_edge_left"],
            out.mdf["bin_edge_right"])),
                 out.mdf["dn/d[O/Fe]"],
                 c=visuals.colors()[color])
예제 #15
0
def plot_track(ax, name, ref, color, linestyle):
	"""
	Plots [O/X]-[X/H] tracks on a matplotlib subplot

	Args:
	=====
	ax:				The name of the subplot
	name: 			The name of the VICE output
	ref: 			The symbol for the reference element
	color: 			The color of the line
	linestyle: 		The linestyle to use
	"""
	out = vice.output(name)
	ax.plot(out.history["[%s/h]" % (ref)], out.history["[o/%s]" % (ref)],
		c = visuals.colors()[color], linestyle = linestyle)
예제 #16
0
def plot_functional(ax, func): 
	""" 
	Plots the yield as a function of metallicity on the axis 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	func :: <function> 
		The function to plot on the axis 
	""" 
	small, big = ax.get_xlim() 
	xvals = [small + (big - small) / 1000 * i for i in range(1000)] 
	ax.plot(xvals, list(map(func, xvals)), linestyle = ':', 
		c = visuals.colors()["black"])
예제 #17
0
def plot_track(ax, name, color): 
	""" 
	Plots a single [Sr/O]-[O/H] track 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	name :: str 
		The name of the VICE output 
	color :: str 
		The name of the color to plot in 
	""" 
	output = vice.output(name) 
	ax.plot(output.history["[O/H]"], output.history["[Sr/O]"], 
		c = visuals.colors()[color]) 
예제 #18
0
def plot_vice_comparison(ax, name):
    """
	Plots the [Mg/Fe]-[Fe/H] track of a given VICE model on the subplot.

	Parameters
	==========
	ax :: matplotlib subplot
		The axis to plot on
	name :: str
		The relative path to the VICE output
	"""
    out = vice.output(name)
    ax.plot(out.history["[fe/h]"],
            out.history["[mg/fe]"],
            c=visuals.colors()["black"],
            linestyle='--')
예제 #19
0
def plot_pdf(ax, output, color):
    """ 
	Plot the [O/Fe] PDF in the specified [Fe/H] bin 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	output :: vice.output 
		The VICE output object containing the simulation results 
	color :: str 
		The color to plot in 
	"""
    bins, pdf = get_ofe_pdf(output)
    centers = list(map(lambda x, y: (x + y) / 2., bins[1:], bins[:-1]))
    ax.plot(centers, pdf, c=visuals.colors()[color])
예제 #20
0
def plot_ifr(ax, name, color):
	"""
	Plots the gas inflow rate on a given matplotlib subplot given the name of
	the VICE output

	Parameters
	==========
	ax :: subplot
		The matplotlib axis to plot the inflow rate on
	name :: str
		The name of the VICE output
	color :: str
		The name of the color to plot in
	"""
	out = vice.output(name)
	ax.plot(out.history["time"], out.history["ifr"], linestyle = '--',
		c = visuals.colors()[color])
예제 #21
0
def draw_ofe_legend(ax):
	"""
	Draws the legend differentiating between oxygen and iron in the plot of
	[X/H] against time.

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to put the legend on
	"""
	lines = 2 * [None]
	for i in range(2):
		lines[i] = ax.plot([1, 2], [1, 2], c = visuals.colors()["black"],
			label = ["O", "Fe"][i], linestyle = ['--', '-'][i])[0]
	ax.legend(loc = visuals.mpl_loc()["upper left"], frameon = False,
		bbox_to_anchor = (0.01, 0.99))
	for i in range(2):
		lines[i].remove()
예제 #22
0
def plot_AGB_legend(ax, z):
	""" 
	Draws the legend for the AGB yields on the subplot 

	Parameters 
	========== 
	ax :: subplot 
		The matplotlib axis object to plot on 
	z :: list 
		The metallicities 
	""" 
	lines = len(z) * [None]
	for i in range(len(z)):
		lines[i] = ax.plot([1, 2], [1, 2], c = visuals.colors()["white"], 
			label = "Z = %g" % (z[i]))[0]
	leg = ax.legend(loc = visuals.mpl_loc()["upper right"], ncol = 1, 
		bbox_to_anchor = (0.99, 0.99), frameon = False, handlelength = 0)
	for i in range(len(z)):
		lines[i].remove() 
		leg.get_texts()[i].set_color(_COLORS_[i])
예제 #23
0
def plot_yield_against_metallicity(ax, element, color, linestyle):
    """
	Plots the late-time fractional yield of a given element against
	metallicity.

	Parameters
	==========
	ax :: subplot
		The matplotlib axis object to plot on
	element :: str
		The element to plot the yield of
	color :: str
		The name of the color to plot in
	linestyle :: str
		The linestyle to adopt
	"""
    MonH = [-4. + 0.01 * i for i in range(401)]
    fractional = len(MonH) * [0.]
    for i in range(len(fractional)):
        mass, times = vice.single_stellar_population(element,
                                                     Z=_Z_SOLAR_ * 10**MonH[i])
        fractional[i] = 1.e8 * mass[-1] / 1.e6
    ax.plot(MonH, fractional, c=visuals.colors()[color], linestyle=linestyle)
예제 #24
0
def plot_representative_errorbar(ax, data, dwarf):
    """
	Plots a representative error bar in the lower-left corner of the figure

	Parameters
	==========
	ax :: matplotlib subplot
		The axis object to put the errorbar on
	data :: 2D-list
		The raw data itself
	dwarf :: str
		The name of the dwarf to take the median errors from
	"""
    err_FeH_column = 13
    err_MgFe_column = 15
    fltrd = list(filter(lambda x: x[0] == dwarf, data))
    ax.errorbar(-2.8,
                -0.4,
                xerr=sorted([row[err_FeH_column]
                             for row in fltrd])[len(fltrd) // 2],
                yerr=sorted([row[err_MgFe_column]
                             for row in fltrd])[len(fltrd) // 2],
                ms=0,
                color=visuals.colors()[_COLORS_[dwarf]])