In [38]:
%matplotlib inline
import yt
import deepdish as dd
import numpy as np
from galaxy_analysis.plot.plot_styles import *
from galaxy_analysis.analysis import Galaxy
import matplotlib.pyplot as plt

import onezone.star as star


from galaxy_analysis.utilities import convert_abundances as ca

In [66]:
# run 1: 1.0E-4 IC metal  --- 1.0E-4 SFR
onez_data1 = np.genfromtxt('/home/aemerick/work/enzo_runs/sn_H2atten_H2sh/onezone/onez_model/newrun4/run0000_summary_output.txt',names = True)
# run 2: 1.0E-4 IC metal  --- 4.0E-4 SFR
onez_data2 = np.genfromtxt('/home/aemerick/work/enzo_runs/sn_H2atten_H2sh/onezone/onez_model/newrun5/run0000_summary_output.txt',names = True)
# run 3: 4.0E-4 IC metal  --- 1.0E-4 SFR
onez_data3 = np.genfromtxt('/home/aemerick/work/enzo_runs/sn_H2atten_H2sh/onezone/onez_model/newrun6/run0000_summary_output.txt',names = True)


def get_abundance(e1,e2, model_data = onez_data1, f1 = 1.0, f2 = 1.0):
    """
    return abundance ratio of two elements over sim time for onez model
    """
    
    A =[\
        ca.abundance_ratio(      (e1,model_data[e1 + '_mass'][i]*1.989E33*f1), 
                                 (e2,model_data[e2 + '_mass'][i]*1.989E33*f2),     
                                 input_type = 'mass')\
      for i in np.arange(np.size(model_data[e2 + '_mass']))\
    ]

    return np.array(A)

In [57]:
onez_data['m_metal']


Out[57]:
array([0.0001    , 0.0001    , 0.0001    , 0.0001    , 0.0001    ,
       0.00010015, 0.00010075, 0.00010118, 0.00010163, 0.00010201,
       0.00010267, 0.00010296, 0.00010424, 0.00010479, 0.00010511,
       0.0001056 , 0.0001068 , 0.00010764, 0.00010849, 0.00010904,
       0.00010951, 0.00011024, 0.00011056, 0.00011133, 0.00011221,
       0.000113  , 0.00011315, 0.0001135 , 0.00011448, 0.00011471,
       0.00011533, 0.00011592, 0.00011602, 0.00011636, 0.00011765,
       0.00011811, 0.00011887, 0.00011931, 0.00011971, 0.00012001,
       0.00012039, 0.00012084, 0.00012115, 0.00012129, 0.00012156,
       0.00012204, 0.00012233, 0.00012289, 0.00012304, 0.00012331,
       0.00012345, 0.0001239 , 0.00012428, 0.00012476, 0.00012525,
       0.00012573, 0.0001262 , 0.0001267 , 0.00012691, 0.00012748,
       0.00012769, 0.00012802, 0.00012829, 0.00012879, 0.0001294 ,
       0.00012971, 0.00012995, 0.00013051, 0.00013069, 0.00013143,
       0.00013208, 0.00013247, 0.00013308, 0.00013359, 0.00013384,
       0.00013491, 0.00013566, 0.00013615, 0.00013665, 0.00013671,
       0.00013741, 0.00013781, 0.00013794, 0.00013842, 0.00013868,
       0.00013926, 0.00013961, 0.00013987, 0.00013999, 0.00014056,
       0.00014088, 0.00014109, 0.00014144, 0.00014165, 0.00014222,
       0.00014273, 0.00014276, 0.00014306, 0.00014328, 0.00014407,
       0.00014448, 0.00014462, 0.00014463, 0.00014488, 0.0001454 ,
       0.00014586, 0.0001461 , 0.00014624, 0.00014647, 0.00014698,
       0.00014729, 0.00014831, 0.00014877, 0.00014943, 0.00014957,
       0.00014972, 0.00014996, 0.0001505 , 0.0001512 , 0.00015175,
       0.00015249, 0.00015285, 0.00015321, 0.00015321, 0.0001535 ,
       0.00015395, 0.00015454, 0.00015476, 0.00015477, 0.00015532,
       0.00015579, 0.000156  , 0.0001566 , 0.00015717, 0.00015755,
       0.00015816, 0.00015869, 0.00015895, 0.00015971, 0.00016052,
       0.00016063, 0.00016075, 0.00016124, 0.00016172, 0.00016178,
       0.00016214, 0.00016278, 0.0001629 , 0.00016354, 0.00016387,
       0.00016485, 0.00016521, 0.00016575, 0.000166  , 0.00016688,
       0.00016721, 0.00016729, 0.00016793, 0.00016822, 0.00016868,
       0.00016939, 0.00016985, 0.00016997, 0.00017046, 0.00017087,
       0.000171  , 0.0001714 , 0.00017213, 0.00017254, 0.00017278,
       0.00017296, 0.00017297, 0.00017351, 0.00017434, 0.00017448,
       0.00017463, 0.00017519, 0.00017526, 0.00017579, 0.00017611,
       0.00017641, 0.0001771 , 0.00017794, 0.00017907, 0.00017977,
       0.00018011, 0.00018039, 0.00018067, 0.00018085, 0.0001809 ,
       0.00018112, 0.00018157, 0.00018158, 0.00018212, 0.00018263,
       0.00018328, 0.00018434, 0.00018445, 0.00018461, 0.00018481,
       0.00018558, 0.00018666, 0.00018717, 0.0001878 , 0.00018878,
       0.00018925, 0.00019002, 0.00019038, 0.00019091, 0.00019202,
       0.00019255, 0.00019309, 0.00019323, 0.00019342, 0.00019412,
       0.00019459, 0.00019495, 0.00019509, 0.0001959 , 0.00019647,
       0.00019703, 0.0001977 , 0.00019799, 0.00019827, 0.0001984 ,
       0.00019914, 0.00019963, 0.00020011, 0.00020082, 0.00020147,
       0.00020186, 0.00020234, 0.00020258, 0.00020272, 0.00020332,
       0.00020368, 0.00020452, 0.00020528, 0.00020544, 0.00020583,
       0.00020635, 0.00020701, 0.00020743, 0.00020784, 0.00020873,
       0.00021006, 0.00021024, 0.00021054, 0.00021086, 0.0002111 ,
       0.00021191, 0.00021223, 0.00021258, 0.00021304, 0.00021363,
       0.00021416, 0.00021487, 0.00021562, 0.00021566, 0.00021633,
       0.00021762, 0.00021789, 0.00021841, 0.00021915, 0.00021963,
       0.00022017, 0.00022026, 0.00022032, 0.0002212 , 0.0002218 ,
       0.00022215, 0.00022216, 0.00022308, 0.00022323, 0.00022353,
       0.00022414, 0.000225  , 0.00022525, 0.00022571, 0.00022659,
       0.00022723, 0.00022751, 0.00022795, 0.00022854, 0.00022905,
       0.0002299 , 0.00023015, 0.00023062, 0.00023086, 0.00023125,
       0.00023133, 0.00023195, 0.000232  , 0.00023278, 0.0002334 ,
       0.00023438, 0.00023465, 0.0002353 , 0.00023581, 0.0002361 ,
       0.00023668, 0.00023774, 0.00023815, 0.00023854, 0.00023912,
       0.00023992, 0.00024029, 0.00024032, 0.00024118, 0.00024154,
       0.00024219, 0.00024304, 0.00024326, 0.00024382, 0.00024425,
       0.00024458, 0.00024503, 0.00024556, 0.00024617, 0.00024635,
       0.00024786, 0.00024822, 0.00024855, 0.00024882, 0.0002497 ,
       0.00024976, 0.00025012, 0.00025026, 0.00025126, 0.00025169,
       0.00025199, 0.00025238, 0.00025285, 0.00025351, 0.00025373,
       0.00025416, 0.00025496, 0.00025558, 0.00025595, 0.00025694,
       0.00025755, 0.00025832, 0.0002588 , 0.00025967, 0.00026008,
       0.00026031, 0.00026173, 0.00026232, 0.00026307, 0.00026359,
       0.00026388, 0.00026442, 0.00026544, 0.00026577, 0.00026631,
       0.00026658, 0.00026687, 0.00026715, 0.0002676 , 0.00026806,
       0.00026911, 0.00026913, 0.0002695 , 0.0002705 , 0.0002711 ,
       0.00027145, 0.00027228, 0.00027272, 0.00027313, 0.00027328,
       0.00027342, 0.00027368, 0.00027411, 0.00027447, 0.00027484,
       0.00027515, 0.00027516, 0.00027532, 0.00027683, 0.00027708,
       0.00027786, 0.00027803, 0.0002789 , 0.00027915, 0.00027979,
       0.00028024, 0.00028072, 0.00028118, 0.00028199, 0.00028222,
       0.00028301, 0.00028307, 0.00028344, 0.00028407, 0.00028437,
       0.00028583, 0.00028612, 0.00028614, 0.00028641, 0.00028758,
       0.00028784, 0.00028827, 0.00028913, 0.00028987, 0.00029089,
       0.00029152, 0.00029292, 0.00029349, 0.00029425, 0.00029543,
       0.00029587, 0.00029621, 0.00029646, 0.00029686, 0.00029741,
       0.00029795, 0.00029839, 0.00029876, 0.00029918, 0.00029966,
       0.0003    , 0.0003004 , 0.00030083, 0.00030151, 0.0003027 ,
       0.00030311, 0.00030379, 0.00030431, 0.0003049 , 0.00030494,
       0.00030534, 0.00030622, 0.00030685, 0.0003073 , 0.00030808,
       0.00030846, 0.00030881, 0.00030937, 0.00030956, 0.00030979,
       0.00031016, 0.00031096, 0.00031138, 0.00031176, 0.00031201,
       0.00031256, 0.00031313, 0.00031351, 0.000314  ])

In [40]:
obs_data = np.genfromtxt('datafile6_v2.txt',names=True,skip_header=23,delimiter = ',',
                          dtype='|U3,|U8,|U14,|U14,f8,f8,f8,f8,f8,f8,f8,f8,f8,f8')

In [41]:
obs_data.dtype.names


Out[41]:
('dSph',
 'Name',
 'RA',
 'DEC',
 'Teff',
 'e_Teff',
 'logg',
 'vt',
 'FeH',
 'e_FeH',
 'alphaFe',
 'e_alphaFe',
 'BaFe',
 'e_BaFe')

In [42]:
dsname = 'DD0991'

gal  = Galaxy(dsname, wdir = '/home/aemerick/work/enzo_runs/sn_H2atten_H2sh/')
#data = dd.io.load('/home/aemerick/work/enzo_runs/sn_H2atten_H2sh/' + dsname + '_galaxy_data.h5')


Parsing Hierarchy : 100%|██████████| 290/290 [00:00<00:00, 21057.20it/s]

In [43]:
dSph   = {'Dra':'Draco', 'UMi' : 'Ursa Minor' , 'Scl' : 'Sculptor', 'For' : 'Fornax'}
colors = {'Dra':'C0', 'UMi' : 'C1', 'Scl' : 'C2', 'For' : 'C3'}

In [44]:
xfield = ('io','particle_Fe_over_H')

y2field = ('io','particle_Ba_over_Fe')
y1field = ('io','particle_Mg_over_Fe')


select = (gal.df['particle_type'] == 11)*\
         (gal.df['creation_time'] > 159 * yt.units.Myr)


fig, ax = plt.subplots(1,2)
fig.set_size_inches(16,8)
x = gal.df[xfield][select]
y = gal.df[y1field][select]
ax[0].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[0].set_xlim(-6,0)
ax[0].set_ylim(-1.5,1.5)
ax[0].plot(ax[0].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[0].set_xlabel('[Fe/H]')
ax[0].set_ylabel('[Mg/Fe]')

for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['alphaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_alphaFe'][obs_select]

    ax[0].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])



x = gal.df[xfield][select]
y = gal.df[y2field][select]
ax[1].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[1].set_xlim(-6,0)
ax[1].set_ylim(-3.2,2.0)
ax[1].plot(ax[1].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[1].set_xlabel('[Fe/H]')
ax[1].set_ylabel('[Ba/Fe]')



for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['BaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_BaFe'][obs_select]

    ax[1].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])

ax[1].legend(loc = 'best')

plt.tight_layout()
plt.minorticks_on()
fig.savefig('Mg_Ba_stellar_abundances.png')



In [45]:
xfield = ('io','particle_Fe_over_H')

y2field = ('io','particle_Ba_over_Fe')
y1field = ('io','particle_Mg_over_Fe')


select = (gal.df['particle_type'] == 11)*\
         (gal.df['creation_time'] > 159 * yt.units.Myr)


fig, ax = plt.subplots(1,2)
fig.set_size_inches(16,8)
x = gal.df[xfield][select]
y = gal.df[y1field][select]
ax[0].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[0].set_xlim(-6,0)
ax[0].set_ylim(-1.5,1.5)
ax[0].plot(ax[0].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[0].set_xlabel('[Fe/H]')
ax[0].set_ylabel('[Mg/Fe]')

for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['alphaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_alphaFe'][obs_select]

    ax[0].scatter(xobs,yobs,
                  #xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k],  label = dSph[k])



x = gal.df[xfield][select]
y = gal.df[y2field][select]
ax[1].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[1].set_xlim(-6,0)
ax[1].set_ylim(-3.2,2.0)
ax[1].plot(ax[1].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[1].set_xlabel('[Fe/H]')
ax[1].set_ylabel('[Ba/Fe]')



for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['BaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_BaFe'][obs_select]

    ax[1].scatter(xobs,yobs,
                 # xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], label = dSph[k])

ax[1].legend(loc = 'best')

plt.tight_layout()
plt.minorticks_on()
fig.savefig('Mg_Ba_stellar_abundances_noerror.png')



In [65]:
xfield = ('io','particle_Fe_over_H')

y2field = ('io','particle_Ba_over_Fe')
y1field = ('io','particle_Mg_over_Fe')


select = (gal.df['particle_type'] == 11)*\
         (gal.df['creation_time'] > 159 * yt.units.Myr)


fig, ax = plt.subplots(1,2)
fig.set_size_inches(16,8)
x = gal.df[xfield][select]
y = gal.df[y1field][select]
ax[0].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[0].set_xlim(-6,0)
ax[0].set_ylim(-1.5,1.5)
ax[0].plot(ax[0].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[0].set_xlabel('[Fe/H]')
ax[0].set_ylabel('[Mg/Fe]')

# plot observational data
for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['alphaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_alphaFe'][obs_select]

    ax[0].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])


# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05)
ax[0].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05)
ax[0].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05)
ax[0].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0)
y = get_abundance('Mg','Fe', f1 = 1.0, f2  = 1.0)
ax[0].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

################################################################################################

x = gal.df[xfield][select]
y = gal.df[y2field][select]
ax[1].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[1].set_xlim(-6,0)
ax[1].set_ylim(-3.2,2.0)
ax[1].plot(ax[1].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[1].set_xlabel('[Fe/H]')
ax[1].set_ylabel('[Ba/Fe]')

# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05)
ax[1].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05)
ax[1].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')


x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0)
y = get_abundance('Ba','Fe', f1 = 0.05, f2  = 0.05)
ax[1].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0)
y = get_abundance('Ba','Fe', f1 = 1.0, f2  = 1.0)
ax[1].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['BaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_BaFe'][obs_select]

    ax[1].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])

ax[0].legend(loc = 'best',ncol=2)

plt.tight_layout()
plt.minorticks_on()
fig.savefig('Mg_Ba_stellar_abundances_onezmodel1.png')



In [67]:
xfield = ('io','particle_Fe_over_H')

y2field = ('io','particle_Ba_over_Fe')
y1field = ('io','particle_Mg_over_Fe')


select = (gal.df['particle_type'] == 11)*\
         (gal.df['creation_time'] > 159 * yt.units.Myr)


fig, ax = plt.subplots(1,2)
fig.set_size_inches(16,8)
x = gal.df[xfield][select]
y = gal.df[y1field][select]
ax[0].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[0].set_xlim(-6,0)
ax[0].set_ylim(-1.5,1.5)
ax[0].plot(ax[0].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[0].set_xlabel('[Fe/H]')
ax[0].set_ylabel('[Mg/Fe]')

# plot observational data
for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['alphaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_alphaFe'][obs_select]

    ax[0].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])


# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data =onez_data2)
ax[0].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1, model_data =onez_data2)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data =onez_data2)
ax[0].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data =onez_data2)
ax[0].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Mg','Fe', f1 = 1.0, f2  = 1.0, model_data =onez_data2)
ax[0].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

################################################################################################

x = gal.df[xfield][select]
y = gal.df[y2field][select]
ax[1].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[1].set_xlim(-6,0)
ax[1].set_ylim(-3.2,2.0)
ax[1].plot(ax[1].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[1].set_xlabel('[Fe/H]')
ax[1].set_ylabel('[Ba/Fe]')

# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05, model_data =onez_data2)
ax[1].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1, model_data =onez_data2)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05, model_data =onez_data2)
ax[1].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')


x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Ba','Fe', f1 = 0.05, f2  = 0.05, model_data =onez_data2)
ax[1].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0, model_data =onez_data2)
y = get_abundance('Ba','Fe', f1 = 1.0, f2  = 1.0, model_data =onez_data2)
ax[1].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['BaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_BaFe'][obs_select]

    ax[1].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])

ax[0].legend(loc = 'best',ncol=2)

plt.tight_layout()
plt.minorticks_on()
fig.savefig('Mg_Ba_stellar_abundances_onezmodel2.png')



In [64]:
xfield = ('io','particle_Fe_over_H')

y2field = ('io','particle_Ba_over_Fe')
y1field = ('io','particle_Mg_over_Fe')


select = (gal.df['particle_type'] == 11)*\
         (gal.df['creation_time'] > 159 * yt.units.Myr)


fig, ax = plt.subplots(1,2)
fig.set_size_inches(16,8)
x = gal.df[xfield][select]
y = gal.df[y1field][select]
ax[0].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[0].set_xlim(-6,0)
ax[0].set_ylim(-1.5,1.5)
ax[0].plot(ax[0].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[0].set_xlabel('[Fe/H]')
ax[0].set_ylabel('[Mg/Fe]')

# plot observational data
for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['alphaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_alphaFe'][obs_select]

    ax[0].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])


# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data = onez_data3)
ax[0].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1, model_data = onez_data3)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data = onez_data3)
ax[0].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Mg','Fe', f1 = 0.05, f2  = 0.05, model_data = onez_data3)
ax[0].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Mg','Fe', f1 = 1.0, f2  = 1.0, model_data = onez_data3)
ax[0].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

################################################################################################

x = gal.df[xfield][select]
y = gal.df[y2field][select]
ax[1].scatter(x, y, color = 'black', alpha = 0.5, s = 12)
ax[1].set_xlim(-6,0)
ax[1].set_ylim(-3.2,2.0)
ax[1].plot(ax[1].get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax[1].set_xlabel('[Fe/H]')
ax[1].set_ylabel('[Ba/Fe]')

# plot onezone simulation data
x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05, model_data = onez_data3)
ax[1].plot(x, y, color = 'C6', ls = '-', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^7$ M$_{\odot}$')

x = get_abundance('Fe','H', f1 = 0.05, f2 = 0.1, model_data = onez_data3)
y = get_abundance('Ba','Fe', f1 = 0.25, f2  = 0.05, model_data = onez_data3)
ax[1].plot(x, y, color = 'C6', ls = ':', lw = 5, label = r'M$_{\rm gas}$ = 1x10$^6$ M$_{\odot}$')


x = get_abundance('Fe','H', f1 = 0.05, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Ba','Fe', f1 = 0.05, f2  = 0.05, model_data = onez_data3)
ax[1].plot(x, y, color = 'C7', ls = '-', lw = 5, label = r'Uniform Metal Ejection')

x = get_abundance('Fe','H', f1 = 1.0, f2 = 1.0, model_data = onez_data3)
y = get_abundance('Ba','Fe', f1 = 1.0, f2  = 1.0, model_data = onez_data3)
ax[1].plot(x, y, color = 'C7', ls = '--', lw = 5, label = r'No Metal Ejection')

for k in dSph.keys():
    obs_select = obs_data['dSph'] == k
    
    xobs = obs_data['FeH'][obs_select]
    yobs = obs_data['BaFe'][obs_select]
    xerrobs = obs_data['e_FeH'][obs_select]
    yerrobs = obs_data['e_BaFe'][obs_select]

    ax[1].errorbar(xobs,yobs,
                  xerr=xerrobs,yerr=yerrobs, 
                  color = colors[k], fmt = 'o', label = dSph[k])

ax[0].legend(loc = 'best',ncol=2)

plt.tight_layout()
plt.minorticks_on()
fig.savefig('Mg_Ba_stellar_abundances_onezmodel3.png')



In [48]:
xfield = ('io','particle_Fe_over_H')
yfield = ('io','particle_Mg_over_Fe')

select = (gal.df['particle_type'] == 11)*\
         (gal.df[('io','particle_Mg_over_H')] > -8) *\
         (gal.df[('io','particle_Fe_over_H')] > -10) *\
         (gal.df['creation_time'] > 169 * yt.units.Myr)

x = gal.df[xfield][select]
y = gal.df[yfield][select]

fig, ax = plt.subplots()

ax.scatter(x, y, color = 'C0', alpha = 0.5, s = 12)
ax.set_xlim(-6,0)
ax.set_ylim(-2,2)
ax.plot(ax.get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax.set_xlabel('[Fe/H]')
ax.set_ylabel('[Mg/Fe]')
plt.tight_layout()
plt.minorticks_on()



In [49]:
xfield = ('io','particle_O_over_H')
yfield = ('io','particle_Mg_over_Fe')

select = (gal.df['particle_type'] == 11)*\
         (gal.df[('io','particle_O_over_H')] > -8) *\
         (gal.df[('io','particle_Fe_over_H')] > -10) *\
         (gal.df['creation_time'] > 169 * yt.units.Myr)

x = gal.df[xfield][select]
y = gal.df[yfield][select]

fig, ax = plt.subplots()

ax.scatter(x, y, color = 'C0', alpha = 0.5, s = 12)
ax.set_xlim(-6,0)
ax.set_ylim(-2,2)
ax.plot(ax.get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax.set_xlabel('[O/H]')
ax.set_ylabel('[Mg/Fe]')
plt.tight_layout()
plt.minorticks_on()



In [50]:
xfield = ('io','particle_O_over_H')
yfield = ('io','particle_Ba_over_O')

select = (gal.df['particle_type'] == 11)*\
         (gal.df[('io','particle_O_over_H')] > -8) *\
         (gal.df[('io','particle_Ba_over_H')] > -10) *\
         (gal.df['creation_time'] > 169 * yt.units.Myr)

x = gal.df[xfield][select]
y = gal.df[yfield][select]

fig, ax = plt.subplots()

ax.scatter(x, y, color = 'C0', alpha = 0.5, s = 12)
ax.set_xlim(-6,0)
#ax.set_ylim(-2,2)
ax.plot(ax.get_xlim(),[0.0,0.0], lw = 1.5, ls = ':', color = 'black')
ax.set_xlabel('[O/H]')
ax.set_ylabel('[Ba/O]')
plt.tight_layout()
plt.minorticks_on()



In [51]:
plt.hist(gal.df['Fe_over_H'][gal.df['number_density'] > 25.0], weights = gal.df['cell_mass'][gal.df['number_density'] > 25.0])


Out[51]:
(array([1.93940948e+37, 2.37457342e+37, 6.10815112e+37, 7.64531610e+37,
        1.32193822e+38, 9.28416639e+37, 2.36950254e+37, 4.71154048e+36,
        7.26062087e+36, 1.83292626e+36]),
 YTArray([-3.22971845, -3.10090207, -2.97208569, -2.84326931, -2.71445292,
          -2.58563654, -2.45682016, -2.32800378, -2.1991874 , -2.07037101,
          -1.94155463]) (dimensionless),
 <a list of 10 Patch objects>)

In [52]:
plt.hist?

In [53]:
s = star.Star(M = 4.0, Z = 4.0E-4, abundances = {'m_tot': 1.0, 'Ba' : 0.0, 'O':0.0,'Fe':0.0})
s.wind_ejecta_masses()


Out[53]:
OrderedDict([('m_tot', 3.099410989720843),
             ('Ba', 2.147598506666667e-09),
             ('O', 0.004813359410666667),
             ('Fe', 1.7779746666666667e-05)])

In [54]:
star.StarParticle?

In [ ]: