APOGEE Standards Data

In [1]:
import matplotlib.pyplot as plt
from astropy.io import ascii
import numpy as np
In [3]:
#This example will run through plotting in color
#and plotting with errorbars
#First lets read in some APOGEE data which I have grabbed from Sloan
#These stars all have S/N ratios greater than 180 and are spectral standards
dat = ascii.read('APOGEE_parameters.csv',delimiter=',')
In [6]:
#The first column is an unique ID
#columns 2-4 are sloan pointing information 
#RA and Dec are positions on the sky
#SN is signal to noise
#RV is radial velocity in the Local Standard of Rest (LSR)
#Teff is the effective temperature
#logg is the log surface gravity of a star
#fe_h is the log iron abundance of a star with respect to the sun
dat.colnames
Out[6]:
['MassID',
 'PlateID',
 'MJD',
 'Fiber',
 'RA',
 'Dec',
 'ReductionVersion',
 'SN',
 'RV',
 'teff',
 'teff_err',
 'logg',
 'logg_err',
 'fe_h',
 'fe_h_err']
In [11]:
#Now these are standard stars with high SN so hopefully they are well understood
#However it is never a bad idea to check
#First let us plot a (hopefully) familiar diagram (The HR Diagram)
fig, ax = plt.subplots()
#When plotting error bars it is similar to regular plotting only you can (not required)
#also you mush specify the point format type (fmt='o' in this example) otherwise 
#the points will be connected by lines
ax.errorbar(dat['teff'],dat['logg'],xerr=dat['teff_err'],yerr=dat['logg_err'],fmt='o',color='black')
ax.set_xlabel('T$_{eff}$',fontsize=18)
ax.set_ylabel('log(g)',fontsize=18)
#Note the limits are backwards
ax.set_ylim([3.5,-1])
ax.set_xlim([5500.,3000])
Out[11]:
(5500.0, 3000)
In [18]:
#Hmmm low log(g) (i.e. low surface gravity and therefore large radii) and low Temperatures I wonder what kind of stars these are?
#Or another way to think of this is where are these stars on the HR Diagram
#The answer is red giant branch stars
#But why is there a scatter in log(g)? The red giant branch is usually quite tight when you look at HR Diagrams
#Let us try another variable in this plot to hopefully shine some light on this
fig, ax = plt.subplots()
#Now lets plot color corresponding to [Fe/H] values (i.e. iron abudance or metallicity)
#cmap paramter takes colormaps built into matplotlib cm.jet is my favorite
#but cm.spectral and cm.Dark2 are also good in my opinion
#The c parameter tells you what to base the color map on in this case [Fe/H]
#vmax and vmin tell the color bar where to stop giving unique colors
plot = ax.scatter(dat['teff'],dat['logg'],c=dat['fe_h'],cmap=plt.cm.jet,vmin=-4.,vmax=1.)
#create a colorbar on the side of the plot so we know what [Fe/H] value a color corresponds to
cbar = fig.colorbar(plot)
#tell matplotlib what to label the color bar axis as 
cbar.set_label('$[$Fe/H$]$',fontsize=18)
ax.set_xlabel('T$_{eff}$',fontsize=18)
ax.set_ylabel('log(g)',fontsize=18)
#Note the limits are backward
ax.set_ylim([3.5,-1])
ax.set_xlim([5500.,3000])
Out[18]:
(5500.0, 3000)
In [17]:
#Interesting the more blue (i.e. [Fe/H] poor) objects are more luminous on average than the red (i.e. [Fe/H] rick) objects for a given temperature
#Does this mean that the more [Fe/H] poor you are the higher your log(g) will be ?
#Lets make a high quality plot to explore this
#Import a module to make minor ticks
from matplotlib.ticker import AutoMinorLocator
#Set up to tell matplotlib to autoselect minor tick locations
minorLocator   = AutoMinorLocator()


fig, ax = plt.subplots()

ax.errorbar(dat['logg'],dat['fe_h'],xerr=dat['logg_err'],yerr=dat['fe_h_err'],fmt='o',color='black')

#Actually tell matplotlib to find best minor tick locations
ax.xaxis.set_minor_locator(minorLocator)
ax.yaxis.set_minor_locator(minorLocator)
#Turn minor ticks on
ax.minorticks_on()
#set the width of the ticks
ax.tick_params(which='both',width=1)
#set the length of the major ticks
ax.tick_params(which='major',length=7)
#set length of the minor ticks
ax.tick_params(which='minor',length=3)

ax.set_ylabel('$[$Fe/H$]$',fontsize=18)
ax.set_xlabel('log(g)',fontsize=18)
#Note the limits are backward
ax.set_xlim([3.5,-1])
ax.set_ylim([-3.,1.])
Out[17]:
(-3.0, 1.0)
In []: