Plot all of the output on one T_eff v Z plane, w/ error bars.
In [1]:
from astropy.io import ascii
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from StellarSpectra.utils import saveall
from matplotlib.ticker import FormatStrFormatter as FSF
from matplotlib.ticker import MaxNLocator
from matplotlib.ticker import MultipleLocator
In [2]:
torres = ascii.read("torres.dat")
torres
Out[2]:
In [3]:
data = ascii.read("czekala.dat")
data
Out[3]:
In [4]:
def ellipse(ax, x, y, xerr, yerr, rho=0):
'''
Plot an error ellipse on an axes.
'''
#width and height of ellipse correspond to the semimajor and semiminor axes
cov = np.array([[xerr**2, xerr*yerr*rho], [xerr*yerr*rho, yerr**2]])
plot_cov_ellipse(cov, (x,y), ax=ax, fill=False, nstd=1)
ax.plot(x, y, "ko", markersize=4)
In [5]:
def plot_cov_ellipse(cov, pos, nstd=1, ax=None, **kwargs):
"""
Plots an `nstd` sigma error ellipse based on the specified covariance
matrix (`cov`). Additional keyword arguments are passed on to the
ellipse patch artist.
Parameters
----------
cov : The 2x2 covariance matrix to base the ellipse on
pos : The location of the center of the ellipse. Expects a 2-element
sequence of [x0, y0].
nstd : The radius of the ellipse in numbers of standard deviations.
Defaults to 2 standard deviations.
ax : The axis that the ellipse will be plotted on. Defaults to the
current axis.
Additional keyword arguments are pass on to the ellipse patch.
from: http://stackoverflow.com/questions/12301071/multidimensional-confidence-intervals
Returns
-------
A matplotlib ellipse artist
"""
def eigsorted(cov):
vals, vecs = np.linalg.eigh(cov)
order = vals.argsort()[::-1]
return vals[order], vecs[:,order]
if ax is None:
ax = plt.gca()
vals, vecs = eigsorted(cov)
theta = np.degrees(np.arctan2(*vecs[:,0][::-1]))
# Width and height are "full" widths, not radius
width, height = 2 * nstd * np.sqrt(vals)
ellip = Ellipse(xy=pos, width=width, height=height, angle=theta, **kwargs)
ax.add_artist(ellip)
return ellip
In [21]:
fig = plt.figure(figsize=(3.2,3.2))
ax = fig.add_subplot(111)
spc = torres[0:3] #first three rows
ax.errorbar(spc["Z"], spc["T"], xerr=spc["Zerr"], yerr=spc["Terr"], fmt="o", color="b", markersize=4)
sme = torres[4]
ax.errorbar(sme["Z"], sme["T"], xerr=sme["Zerr"], yerr=sme["Terr"], fmt="o", color="m", markersize=4)
moog = torres[5:6]
ax.errorbar(moog["Z"], moog["T"], xerr=moog["Zerr"], yerr=moog["Terr"], fmt="o", color="g", markersize=4)
avg = torres[6]
ax.errorbar(avg["Z"], avg["T"], xerr=avg["Zerr"], yerr=avg["Terr"], fmt="o", color="k", markersize=4)
#ax.errorbar(torres["Z"], torres["T"], xerr=torres["Zerr"], yerr=torres["Terr"], fmt="o", markersize=4)
for row in data:
ellipse(ax, row["Z"], row["T"], xerr=row["Zerr"], yerr=row["Terr"], rho=row["rho"])
ax.annotate("CfA", (-0.38, 6500), color="k")
ax.annotate("PHOENIX", (-0.55, 6350), color="k")
ax.annotate("SPC", (-0.1, 6550), color="b")
ax.annotate("SME", (-0.32, 6400), color="m")
ax.annotate("MOOG", (-0.32, 6100), color="g")
ax.annotate("AVG", (-0.1, 6410), color="k")
ax.yaxis.set_major_formatter(FSF("%.0f"))
ax.set_xlabel(r"$[{\rm m}/{\rm H}]$")
ax.set_ylabel(r"$T_{\rm eff}$")
ax.set_ylim(6020, 6600)
ax.set_xlim(-0.6, 0)
fig.subplots_adjust(bottom=0.16, left=0.19)
saveall(fig, "../../plots/metacomparison")
plt.show()
What should we do about coloring in this plot? I suppose we should categorize by Torres v. Czekala, SPC v. SME v. MOOG, and PHOENIX v. Kurucz? Also, how many orders, etc..
In [ ]: