In [1]:
try:
reload(apogee.modelspec.ferre)
except NameError:
import apogee.modelspec.ferre
import apogee.spec.plot as splot
from galpy.util import bovy_plot
from apogee.tools import paramIndx
numpy.random.seed(1)
Read the location and APOGEE IDs
In [2]:
with open('bulge-lowAlpha-id','r') as sfile:
apids= []
locids= []
for line in sfile:
if line[0] == '#': continue
apids.append(line.split()[0])
locids.append(int(line.split()[1]))
apids= numpy.array(apids)
locids= numpy.array(locids)
# Randomly re-arrange
randindx= numpy.random.permutation(len(locids))
apids= apids[randindx]
locids= locids[randindx]
ASPCAP fit for the first one
In [3]:
fparam= apogee.modelspec.ferre.fit(locids[1],apids[1])
In [4]:
felem= apogee.modelspec.ferre.elemfitall(locids[1],apids[1],fparam=fparam)
In [5]:
print fparam, felem
Let's look at the ASPCAP fit:
In [6]:
splot.waveregions(locids[1],apids[1],ext=1,zorder=1)
splot.waveregions(locids[1],apids[1],ext=3,zorder=0,overplot=True)
Oxygen in particular, because this drives the [a/Fe] abundances:
In [7]:
splot.windows(locids[1],apids[1],'O1',ext=1,zorder=1)
splot.windows(locids[1],apids[1],'O1',ext=3,zorder=0,overplot=True)
These both look quite good. Next we calculate the chi^2 surface in (Teff,abundance) for (O,C,S,Mg,Si,Ca)
In [29]:
def plotchi2(locid,apid,nabu=21,nteff=21,abus=['O','C','S','Mg','Si','Ca']):
fparam= apogee.modelspec.ferre.fit(locid,apid,initcannon=True)
print fparam
felem= apogee.modelspec.ferre.elemfitall(locid,apid,fparam=fparam)
print felem
figsize(18,12)
abudiff= (-0.5,0.5,21)
teffs= fparam[:,paramIndx('teff')]+numpy.linspace(-250.,250.,21)
for ii,abu in enumerate(abus):
if abu.lower() == 'c': cm= felem[abu]-numpy.ones_like(teffs)*fparam[:,paramIndx('metals')]
else: cm= numpy.ones_like(teffs)*fparam[:,paramIndx('c')]
if abu.lower() == 'n': nm= felem[abu]-numpy.ones_like(teffs)*fparam[:,paramIndx('metals')]
else: nm= numpy.ones_like(teffs)*fparam[:,paramIndx('n')]
if abu.lower() in ['o','s','mg','si','ca','ti']: am= felem[abu]-numpy.ones_like(teffs)*fparam[:,paramIndx('metals')]
else: am= numpy.ones_like(teffs)*fparam[:,paramIndx('alpha')]
c2= apogee.modelspec.ferre.elemchi2([locid for teff in teffs],
[apid for teff in teffs],
abu,abudiff,
teff=teffs,
logg=numpy.ones_like(teffs)*fparam[:,paramIndx('logg')],
metals=numpy.ones_like(teffs)*fparam[:,paramIndx('metals')],
am=am,cm=cm,nm=nm)
c2-= numpy.nanmin(c2)
subplot(2,3,ii+1)
imshow(c2,origin='lower',cmap='gray',extent=((abudiff[0],abudiff[1],teffs[0]-fparam[:,paramIndx('teff')],
teffs[-1]-fparam[:,paramIndx('teff')])),
aspect=1./500.,vmin=0.,vmax=30.,interpolation='nearest')
contour(c2,origin='lower',levels=[2.3,6.18,11.8],colors='w',extent=((abudiff[0],abudiff[1],
teffs[0]-fparam[:,paramIndx('teff')],
teffs[-1]-fparam[:,paramIndx('teff')])),
aspect=1./500.)
xlabel(r'$\Delta [\mathrm{%s/Fe}]$' % abu)
ylabel(r'$\Delta T_{\mathrm{eff}}$')
bovy_plot.bovy_text(r'$\mathrm{%s}$' % abu,top_left=True,size=16.)
if ii == 0: bovy_plot.bovy_text(r'$%i,\ \mathrm{%s}$' % (locid,apid),title=True,size=16.)
tight_layout()
In [9]:
plotchi2(locids[1],apids[1],nabu=21,nteff=21)
Another few:
In [10]:
plotchi2(locids[2],apids[2],nabu=21,nteff=21)
In [11]:
plotchi2(locids[3],apids[3],nabu=21,nteff=21)
In [12]:
plotchi2(locids[4],apids[4],nabu=21,nteff=21)
In [13]:
plotchi2(locids[5],apids[5],nabu=21,nteff=21)
In [14]:
plotchi2(locids[6],apids[6],nabu=21,nteff=21)
In [30]:
plotchi2(locids[7],apids[7],nabu=21,nteff=21,abus=['O','C','S','Mg','N','Ti'])
In [24]:
plotchi2(locids[12],apids[12],nabu=21,nteff=21,abus=['O','C','S','Mg','N','Ti'])
In [27]:
plotchi2(locids[15],apids[15],nabu=21,nteff=21,abus=['O','C','S','Mg','N','Ti'])
In [ ]: