import pandas as pd
import numpy as np
import os
import SpectralTypeRelations
%pylab inline
Warning! emcee module not loaded! BayesFit Module will not be available! Populating the interactive namespace from numpy and matplotlib
# First, read in the data
filename = '{}/School/Research/McDonaldData/Sensitivity_Summary.csv'.format(os.environ['HOME'])
data = pd.read_csv(filename)
Lets see what the plot looks like with just the standard axes
def plot_normal(df):
# Plot, given a dataframe
stars = df.groupby('star')
fig, ax = pylab.subplots()
for starname in stars.groups.keys():
g = stars.get_group(starname)
ax.plot(g['temperature'].values, g['significance'].values, lw=2, label=starname)
ax.set_xlabel('Temperature')
ax.set_ylabel('Detection significance')
return fig, ax
fig, ax = plot_normal(data)
pylab.show()
What I want is to put the spectral type corresponding to the given temperature along the top. I have a handy module for that
MS = SpectralTypeRelations.MainSequence()
def add_top_axis(axis, spt_values=('M5', 'M0', 'K5', 'K0', 'G5', 'G0')):
# Find the temperatures at each spectral type
temp_values = MS.Interpolate('Temperature', spt_values)
# make the axis
top = axis.twiny()
# Set the full range to be the same as the data axis
xlim = axis.get_xlim()
top.set_xlim(xlim)
# Set the ticks at the temperatures corresponding to the right spectral type
top.set_xticks(temp_values)
top.set_xticklabels(spt_values)
top.set_xlabel('Spectral Type')
return top
fix, ax = plot_normal(data)
top = add_top_axis(ax)
pylab.show()