Local Group Halo Properties: Demo Inference

We approximate the local group distance, radial velocity and proper motion likelihood function by sampling from the posterior distributions for these variables reported in the literature and transforming to kinematic variables in the M31-centric coordinate system.


In [1]:
%matplotlib inline
import localgroup
import triangle
import sklearn
from sklearn import mixture
import numpy as np
import pickle
import matplotlib.patches as mpatches

Inside the Likelihood object is a "triplet" object called T, which contains an array of sample local groups, each with kinematic parameters consistent with the observational data. Let's plot these kinematic parameters in a "triangle" figure, to show all their 1 and 2-D marginal distributions.


In [2]:
L = localgroup.Likelihood(isPair=False)
L.generate(Nsamples=200000)


Inside method: heliocentric_equatorial_spherical_to_galactocentric_cartesian
l =  [ 121.27686853  121.17907964  121.24069734 ...,  121.08910601  121.13311309
  121.16955274]
b =  [-21.45318338 -21.573936   -21.60876167 ..., -21.53155964 -21.5054986
 -21.65722091]
mu_l = 122.584095 +/- 30.714898
mu_b = -78.300601 +/- 28.417393
v_west:  -122.584095 +/- 30.714898
v_north: -78.300601 +/- 28.417393
Inside method: heliocentric_equatorial_spherical_to_galactocentric_cartesian
l =  [ 133.50331136  133.57202035  133.64067364 ...,  133.66658476  133.6178795
  133.54518835]
b =  [-31.39007961 -31.29592577 -31.28702404 ..., -31.32681859 -31.35960543
 -31.28920821]
mu_l = 21.373822 +/- 6.888174
mu_b = 11.823305 +/- 8.740508
v_west:  -80.450461 +/- 26.052068
v_north: 44.500946 +/- 32.938781
Inside method: heliocentric_equatorial_spherical_to_galactocentric_cartesian
l =  [ 279.5487055   279.4685385   280.08761032 ...,  280.03280121  279.71656441
  279.72168302]
b =  [-33.84995347 -33.22775497 -33.88732422 ..., -33.95279969 -33.57319965
 -33.88168976]
mu_l = -634.496453 +/- 640.051891
mu_b = 1818.226798 +/- 638.534582
v_west:  150.417687 +/- 157.469349
v_north: 431.133502 +/- 177.082232
localgroup/halo.py:134: RuntimeWarning: invalid value encountered in divide
  self.v_r = (self.x*self.vx + self.y*self.vy + self.z*self.vz)/self.D

In [3]:
L.set_PDF(mixture.GMM(n_components=10, covariance_type='full'))
L.approximate()

In [4]:
figure_obs = L.plot_samples(10, color='b', overlay=False)


Quantiles:
[(0.16, 0.7342858758612657), (0.5, 0.77417284690280042), (0.84, 0.8141933478443496)]
Quantiles:
[(0.16, -113.69100646383909), (0.5, -109.24415918287569), (0.84, -104.83394294275779)]
Quantiles:
[(0.16, 18.847547372981406), (0.5, 37.641514196767893), (0.84, 61.342596091607149)]
Quantiles:
[(0.16, 0.19988986986334739), (0.5, 0.20637107654160486), (0.84, 0.21492725397997198)]
Quantiles:
[(0.16, -200.43462084668417), (0.5, -152.85791018555153), (0.84, -104.11895612395733)]
Quantiles:
[(0.16, 97.186977570808082), (0.5, 132.43495432541602), (0.84, 168.03491541782097)]
Quantiles:
[(0.16, 0.039714743115674203), (0.5, 0.049517694554695735), (0.84, 0.059276246283034024)]
Quantiles:
[(0.16, 37.80231606561108), (0.5, 63.625949013842018), (0.84, 89.329896248153858)]
Quantiles:
[(0.16, 181.83689314051458), (0.5, 336.67577963815808), (0.84, 522.73842271327749)]

The above plot shows a Gaussian Mixture model fitted Gaussians. The shaded regions show two standard deviations. The samples data has been preprocessed to zero the mean and scale by standard deviation. Since we are using the Gaussian Mixture Model to model the underlying PDF of the data, more components is always better.

How to evaluate goodness of fit:

Due to lack of a standard goodness of fit test for GMM's, the best we can do is graphically show that the model reproduces the data well. We proceed by drawing a set of points from the fitted model, where each point is a local group with (MW_D, MW_vr, MW_vt, M33_D, M33_vr, M33_vt). We then plot the 1D and 2D marginalizations of the drawn point set and show that the marginalizations match the marginalizations of the true data.


In [5]:
figure_model = L.model_gof(L.T.Nsamples, color="r", fig=None)



In [6]:
figure_model


Out[6]:

In [7]:
L.model_gof(L.T.Nsamples, color="r", fig=figure_obs)
red_patch = mpatches.Patch(color='red')
blue_patch = mpatches.Patch(color='blue')
figure_obs.legend(handles=[red_patch, blue_patch], labels=["Model Generated", "Observation Generated"], fontsize=16)


Out[7]:
<matplotlib.legend.Legend at 0x129dc190>

In [8]:
figure_obs.suptitle("Likelihood Model Goodness of Fit", fontsize=16)


Out[8]:
<matplotlib.text.Text at 0x129f3dd0>

In [9]:
figure_obs


Out[9]:

The above plot shows that the points drawn from the model create a population that is very similar to the true data.


In [10]:
#figure_obs.savefig("/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/final_plots/Trip_LGMM_GOF.pdf", dpi=1200)

Reading Simulation Points:

Below we read the preconfigured files containing the Consuelo (soon to be Dark Sky) Local Group analogs into a Triplet object. We plot the marginalizations of the simulation data, which allows us to compare with the LG prior.


In [11]:
path = '/lustre/ki/pfs/mwillia1/LG_project/Consuelo_Boxes/All_Boxes_quad_dat_M31_larger.npy'
#path = '/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/data_files/complete_triplets.txt'
#path_054 = '/lustre/ki/pfs/mwillia1/LG_project/Consuelo_Boxes/All_Boxes_trip_dat_M31_larger_0.949.npy'

npoints = 200000
halo_props = ['MW_Mvir', 'M31_Mvir', 'M33_Mvir']

In [12]:
h=np.load(path)

In [13]:
h.size


Out[13]:
208303

In [12]:
Tr = localgroup.Triplet(isPair=False)
#Tr_054 = localgroup.Triplet(isPair=True)

Tr.read_sim_points(path, npoints, halo_props, h=0.7, a=1.0, npy=True)
#Tr_054.read_sim_points(path_054, npoints, halo_props, h=0.7, a=0.949, npy=True)

In [13]:
Tr.transform_to_M31(sim=True)
#Tr_054.transform_to_M31(sim=True)

In [25]:
Tr.sim_samples = np.vstack((Tr.sim_samples, Tr_054.sim_samples))
Tr.MW.Mvir = np.hstack((Tr.MW.Mvir, Tr_054.MW.Mvir))
Tr.M31.Mvir = np.hstack((Tr.M31.Mvir, Tr_054.M31.Mvir))
#Tr.M33.Mvir = np.hstack((Tr.M33.Mvir, Tr_054.M33.Mvir))

Tr.MW.Rvir = np.hstack((Tr.MW.Rvir, Tr_054.MW.Rvir))
Tr.M31.Rvir = np.hstack((Tr.M31.Rvir, Tr_054.M31.Rvir))
#Tr.M33.Rvir = np.hstack((Tr.M33.Rvir, Tr_054.M33.Rvir))

Tr.MW.Rs = np.hstack((Tr.MW.Rs, Tr_054.MW.Rs))
Tr.M31.Rs = np.hstack((Tr.M31.Rs, Tr_054.M31.Rs))
#Tr.M33.Rs = np.hstack((Tr.M33.Rs, Tr_054.M33.Rs))

Tr.MW.Cvir = np.hstack((Tr.MW.Cvir, Tr_054.MW.Cvir))
Tr.M31.Cvir = np.hstack((Tr.M31.Cvir, Tr_054.M31.Cvir))
#Tr.M33.Cvir = np.hstack((Tr.M33.Cvir, Tr_054.M33.Cvir))

Tr.LG_Mvir = np.hstack((Tr.LG_Mvir, Tr_054.LG_Mvir))

In [14]:
Tr.sim_samples.shape


Out[14]:
(200000, 9)

In [17]:
#Tr.mass_filter('sim')

In [15]:
Tr.dist_filter((Tr.sim_samples[:,0] < 10) & (Tr.sim_samples[:,3] < 10) & (Tr.sim_samples[:,6] < 10))
#Tr.dist_filter((Tr.sim_samples[:,0] < 10))


sim_sample length before:  (200000, 9)
sim_sample length after:  (199160, 9)
Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x12783f90>

In [29]:
max(Tr.sim_samples[:,3])


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-29-c650f171b6f9> in <module>()
----> 1 max(Tr.sim_samples[:,3])

IndexError: index 3 is out of bounds for axis 1 with size 3

In [16]:
Tr.preprocess(L.samples_means, L.samples_stds, mode='sim')

In [17]:
sim_plot = Tr.plot_kinematics('sim', L.samples_means, L.samples_stds, color='c', fig=None)


Quantiles:
[(0.16, 0.34655169609555891), (0.5, 0.62279158913839316), (0.84, 0.88929923458445037)]
Quantiles:
[(0.16, -286.09988957791188), (0.5, -140.43915412209287), (0.84, -47.280307327617805)]
Quantiles:
[(0.16, 43.22373960632018), (0.5, 104.05808305477206), (0.84, 223.59787453935294)]
Quantiles:
[(0.16, 0.091613337551036331), (0.5, 0.21250445059767764), (0.84, 0.34130233338583266)]
Quantiles:
[(0.16, -242.14880449468882), (0.5, -76.225393211895835), (0.84, 131.97555536312015)]
Quantiles:
[(0.16, 67.459606031079645), (0.5, 164.02601971561211), (0.84, 334.90944724160533)]
Quantiles:
[(0.16, 0.11130944640906683), (0.5, 0.25065505867765459), (0.84, 0.3578371812205019)]
Quantiles:
[(0.16, -202.89708237243354), (0.5, -63.048400811733785), (0.84, 67.808611251482759)]
Quantiles:
[(0.16, 62.920567322474092), (0.5, 145.78809557291942), (0.84, 291.68317330284674)]

In [ ]:


In [18]:
Tr.plot_kinematics('sim', L.samples_means, L.samples_stds, color='g', fig=figure_model)


Quantiles:
[(0.16, 0.34655169609555891), (0.5, 0.62279158913839316), (0.84, 0.88929923458445037)]
Quantiles:
[(0.16, -286.09988957791188), (0.5, -140.43915412209287), (0.84, -47.280307327617805)]
Quantiles:
[(0.16, 43.22373960632018), (0.5, 104.05808305477206), (0.84, 223.59787453935294)]
Quantiles:
[(0.16, 0.091613337551036331), (0.5, 0.21250445059767764), (0.84, 0.34130233338583266)]
Quantiles:
[(0.16, -242.14880449468882), (0.5, -76.225393211895835), (0.84, 131.97555536312015)]
Quantiles:
[(0.16, 67.459606031079645), (0.5, 164.02601971561211), (0.84, 334.90944724160533)]
Quantiles:
[(0.16, 0.11130944640906683), (0.5, 0.25065505867765459), (0.84, 0.3578371812205019)]
Quantiles:
[(0.16, -202.89708237243354), (0.5, -63.048400811733785), (0.84, 67.808611251482759)]
Quantiles:
[(0.16, 62.920567322474092), (0.5, 145.78809557291942), (0.84, 291.68317330284674)]
Out[18]:

In [19]:
red_patch = mpatches.Patch(color='red')
green_patch = mpatches.Patch(color='green')
figure_model.legend(handles=[red_patch, green_patch], labels=["Model Generated", "Consuelo Triplets"], fontsize=16)
figure_model.suptitle("Model Likelihood Overlayed with Consuelo Prior", fontsize=16)
figure_model


Out[19]:

In [ ]:


In [29]:
ax=np.reshape(np.array(figure_model.axes), (9,9))

In [31]:
AX=ax[8,0]

In [33]:
AX.set_xlim((0,10))


Out[33]:
(0, 10)

In [34]:
figure_model


Out[34]:

In [19]:
#sim_plot.savefig('/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/asurps/likelihood_prior.png', dpi=1200)

In [20]:
Tr.compute_model_weights(L, "sim")

In [21]:
N95 = Tr.calculate_N95()
N95


Out[21]:
(7, 0.0063197966968825689)

In [11]:
Tr.weights[Tr.weights[:]>.024797]


Out[11]:
array([ 0.31230457,  0.0671544 ,  0.02491648,  0.37146084,  0.06006868,
        0.12755218,  0.03086875])

In [15]:
MW_C200 = Tr.calculate_cvir_to_c200(Tr.MW.Cvir)
M31_C200 = Tr.calculate_cvir_to_c200(Tr.M31.Cvir)
M33_C200 = Tr.calculate_cvir_to_c200(Tr.M33.Cvir)

MW_M200 = Tr.calculate_Mvir_to_M200(Tr.MW.Mvir, Tr.MW.Cvir, MW_C200)
M31_M200 = Tr.calculate_Mvir_to_M200(Tr.M31.Mvir, Tr.M31.Cvir, M31_C200)
M33_M200 = Tr.calculate_Mvir_to_M200(Tr.M33.Mvir, Tr.M33.Cvir, M33_C200)

total_200 = M31_M200+MW_M200

In [20]:
#m33 = np.ones(len(Tr.MW.Mvir))
#m33[0]=1.5
#m33[1]=.5
total = Tr.MW.Mvir + Tr.M31.Mvir
all_mvir = np.log10(np.transpose(np.vstack((Tr.MW.Mvir, Tr.M31.Mvir, Tr.M33.Mvir, total))))
#all_mvir = np.log10(np.transpose(np.vstack((MW_M200, M31_M200, M33_M200, total_200))))
#labs = ["$M200_{MW}$", "$M200_{M31}$", "$M200_{M33}$", "$M_{MW+M31}$"]
labs = ["$Mvir_{MW}$", "$Mvir_{M31}$", "$Mvir_{M33}$", "$M_{MW+M31}$"]

In [56]:
all_mvir = np.transpose(np.vstack((Tr.MW.Cvir, Tr.M31.Cvir, Tr.M33.Cvir)))
labs = ["$Cvir_{MW}$", "$Cvir_{M31}$", "$Cvir_{M33}$"]

In [19]:
all_mvir.shape


Out[19]:
(298830, 3)

In [20]:
figure2 = triangle.corner(all_mvir, labels=labs, quantiles=[0.16,0.5,0.84], fig=None, weights=None,\
                         plot_contours=True, show_titles=False, title_args={"fontsize": 16}, label_args={"fontsize": 16},\
                         plot_datapoints=False, bins=20, color='c', alpha=0.1)
#figure.suptitle("Weighted Mass Posterior PDF", fontsize=16, horizontalalignment='left')


Quantiles:
[(0.16, 10.940392925174667), (0.5, 11.451707570865903), (0.84, 12.015602977024132)]
Quantiles:
[(0.16, 11.253713842978014), (0.5, 11.850828522970316), (0.84, 12.493067150644926)]
Quantiles:
[(0.16, 10.335300129946841), (0.5, 10.72064916069974), (0.84, 11.279204106008279)]
Quantiles:
[(0.16, 11.45528833327813), (0.5, 12.021401034440489), (0.84, 12.628223689433176)]

In [25]:
figure2


Out[25]:

In [28]:
figure2.savefig('/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/final_plots/W_vs_UW_Mass_Post.png', dpi=1200)

In [ ]:


In [21]:
figure = triangle.corner(all_mvir, labels=labs, quantiles=[0.16,0.5,0.84], fig=None, weights=Tr.weights,\
                         plot_contours=True, show_titles=True, title_args={"fontsize": 16}, label_args={"fontsize": 16},\
                         plot_datapoints=False, bins=20, color='r')
#figure.suptitle("Mass Posterior", fontsize=16, horizontalalignment='left')


Quantiles:
[(0.16, 11.836235475134568), (0.5, 11.836235475134568), (0.84, 11.985920220123568)]
Quantiles:
[(0.16, 11.943049111008406), (0.5, 11.943049111008406), (0.84, 12.076822423342774)]
Quantiles:
[(0.16, 11.004364371107751), (0.5, 11.004364371107751), (0.84, 11.004364371107751)]
Quantiles:
[(0.16, 12.19394786349483), (0.5, 12.19394786349483), (0.84, 12.355106552954492)]

In [63]:
figure


Out[63]:

In [62]:
#figure.suptitle("Concentration Posterior", fontsize=16, horizontalalignment='left')
red_patch = mpatches.Patch(color='k')
blue_patch = mpatches.Patch(color='c')
figure.legend(handles=[red_patch, blue_patch], labels=["Cvir from Narrow Mass Bin", "Weighted Triplet Cvir"], fontsize=16)


Out[62]:
<matplotlib.legend.Legend at 0x49046c10>

In [65]:
figure.savefig('/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/final_plots/TC_vs_MBC.png', dpi=1200)

In [29]:
h = np.load('/lustre/ki/pfs/mwillia1/LG_project/Consuelo_Boxes/4002/4002hlist.npy')

In [47]:
mw_h = h[np.abs(np.log10(h['mvir'])-11.7) < .1]
m31_h = h[np.abs(np.log10(h['mvir'])-12) < .1]
m33_h = h[np.abs(np.log10(h['mvir'])-10.8) < .1]

In [51]:
mwc = mw_h['rvir']/mw_h['rs']
m31c = m31_h['rvir']/m31_h['rs']
m33c = m33_h['rvir']/m33_h['rs']

mwc.shape, m31c.shape, m33c.shape


Out[51]:
((217665,), (117899,), (1122183,))

In [52]:
mwc = mwc[0:100000]
m31c = m31c[0:100000]
m33c = m33c[0:100000]

In [58]:
all_mvir = np.transpose(np.vstack((mwc, m31c, m33c)))
labs = ["$Cvir_{MW}$", "$Cvir_{M31}$", "$Cvir_{M33}$"]

In [59]:
figure_c = triangle.corner(all_mvir, labels=labs, quantiles=[0.,0.5,0.84], fig=figure, weights=None,\
                         plot_contours=True, show_titles=True, title_args={"fontsize": 16}, label_args={"fontsize": 16},\
                         plot_datapoints=False, bins=20, color='k')


Quantiles:
[(0.0, 2.1626035287540142), (0.5, 9.7768424877369338), (0.84, 13.064559736233724)]
Quantiles:
[(0.0, 2.1626225121906293), (0.5, 9.3402476001345551), (0.84, 12.231018804621753)]
Quantiles:
[(0.0, 2.1626365992465333), (0.5, 7.8392154432181913), (0.84, 12.678848920863308)]

In [ ]:


In [206]:
figure2 = triangle.corner(all_mvir, labels=labs, quantiles=[0.16,0.5,0.84], fig=figure, weights=Tr.weights,\
                         plot_contours=True, show_titles=True, title_args={"fontsize": 16}, label_args={"fontsize": 16},\
                         plot_datapoints=False, bins=20, color='r')


Quantiles:
[(0.16, 11.431572818585654), (0.5, 11.800785790327762), (0.84, 12.0893751608161)]
Quantiles:
[(0.16, 11.906550519101451), (0.5, 12.106360908806751), (0.84, 12.338137628331909)]
Quantiles:
[(0.16, 10.263896330604611), (0.5, 10.930745328311113), (0.84, 11.348207476685626)]
Quantiles:
[(0.16, 12.060180155027432), (0.5, 12.280305143255005), (0.84, 12.448350701995903)]

In [ ]:


In [209]:
figure


Out[209]:

In [208]:
#figure.suptitle("Mass Posterior", fontsize=16, horizontalalignment='left')
red_patch = mpatches.Patch(color='r')
blue_patch = mpatches.Patch(color='b')
figure.legend(handles=[red_patch, blue_patch], labels=["Triplets", "Pairs"], fontsize=16)


Out[208]:
<matplotlib.legend.Legend at 0x3ecb3590>

In [134]:
a=figure.gca()

In [138]:
a.legend_?

In [211]:
figure2.savefig('/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/final_plots/T_vs_P_mass.png', dpi=1200)

In [48]:
Tr.weights.shape


Out[48]:
(123382,)

In [66]:
xdata = total
plot(xdata, Tr.weights)
xscale('log')



In [67]:
bins = 20
xbins = np.logspace(np.log10(xdata.min()), np.log10(xdata.max()), bins)
ybins = [np.sum(Tr.weights[(xdata[:]>xbins[i]) & (xdata[:]<xbins[i+1])]) for i in range(bins-1)]
print len(xbins)
print len(ybins)
print len(xbins[:bins-1])


20
19
19

In [68]:
plot(xbins[:bins-1], ybins)
xscale('log')



In [40]:
xtrip = np.copy(xbins[:bins-1])
ytrip = np.copy(ybins)

In [45]:
xtripmw = np.copy(xbins[:bins-1])
ytripmw = np.copy(ybins)

In [65]:
xpairmw = np.copy(xbins[:bins-1])
ypairmw = np.copy(ybins)

In [69]:
xpair = np.copy(xbins[:bins-1])
ypair = np.copy(ybins)

In [80]:
plot(xtripmw, ytripmw, color='r')
plot(xpairmw, ypairmw, color='b')
ylabel('P(MMW)')
xlabel('MMW')

red_patch = mpatches.Patch(color='red')
blue_patch = mpatches.Patch(color='blue')
legend(["Trips, M33 dynamics", "Pairs, M33 existence"])
xscale('log')
#savefig("/afs/slac.stanford.edu/u/ki/mwillia1/Thesis/LocalGroupHaloProps/doc/thesis/plots/pdf_mw_plot.png")



In [ ]:


In [ ]:


In [ ]:


In [24]:
all_mvir = np.transpose(np.vstack((np.log10(Tr.MW.Mvir), Tr.MW.Cvir)))
labs = ["$Mvir_{MW}$", "$Cvir_{MW}$"]

In [103]:
figure = triangle.corner(all_mvir, labels=labs, quantiles=[0.16,0.5,0.84], fig=None, weights=Tr.weights,\
                         plot_contours=True, show_titles=True, title_args={"fontsize": 16}, label_args={"fontsize": 16},\
                         plot_datapoints=False, bins=20, color='r')


Quantiles:
[(0.16, 11.836235475134568), (0.5, 11.93464992290071), (0.84, 11.978636948384475)]
Quantiles:
[(0.16, 6.654068291707463), (0.5, 8.069138298997313), (0.84, 8.189792734022474)]

In [54]:
hlist_path = '/lustre/ki/pfs/mwillia1/LG_project/Consuelo_Boxes/4001/4001hlist.npy'
hlist = np.load(hlist_path)

In [55]:
hlist=hlist[np.abs(np.log10(hlist['mvir'])-12)<1.0]
cvir = hlist['rvir']/hlist['rs']
mvir = np.log10(hlist['mvir'])

In [59]:
hlist['mvir']


Out[59]:
array([  9.96500000e+12,   9.90300000e+12,   9.89600000e+12, ...,
         1.01200000e+11,   1.01200000e+11,   1.01200000e+11])

In [ ]:
def binMass(mvir, cvir, width):
    mvir_bins = np.arange(np.min(mvir), np.max(mvir), width)

In [95]:
bins = np.arange(np.min(mvir), np.max(mvir), .01)


Out[95]:
array([ 11.00518051,  11.01518051,  11.02518051,  11.03518051,
        11.04518051,  11.05518051,  11.06518051,  11.07518051,
        11.08518051,  11.09518051,  11.10518051,  11.11518051,
        11.12518051,  11.13518051,  11.14518051,  11.15518051,
        11.16518051,  11.17518051,  11.18518051,  11.19518051,
        11.20518051,  11.21518051,  11.22518051,  11.23518051,
        11.24518051,  11.25518051,  11.26518051,  11.27518051,
        11.28518051,  11.29518051,  11.30518051,  11.31518051,
        11.32518051,  11.33518051,  11.34518051,  11.35518051,
        11.36518051,  11.37518051,  11.38518051,  11.39518051,
        11.40518051,  11.41518051,  11.42518051,  11.43518051,
        11.44518051,  11.45518051,  11.46518051,  11.47518051,
        11.48518051,  11.49518051,  11.50518051,  11.51518051,
        11.52518051,  11.53518051,  11.54518051,  11.55518051,
        11.56518051,  11.57518051,  11.58518051,  11.59518051,
        11.60518051,  11.61518051,  11.62518051,  11.63518051,
        11.64518051,  11.65518051,  11.66518051,  11.67518051,
        11.68518051,  11.69518051,  11.70518051,  11.71518051,
        11.72518051,  11.73518051,  11.74518051,  11.75518051,
        11.76518051,  11.77518051,  11.78518051,  11.79518051,
        11.80518051,  11.81518051,  11.82518051,  11.83518051,
        11.84518051,  11.85518051,  11.86518051,  11.87518051,
        11.88518051,  11.89518051,  11.90518051,  11.91518051,
        11.92518051,  11.93518051,  11.94518051,  11.95518051,
        11.96518051,  11.97518051,  11.98518051,  11.99518051,
        12.00518051,  12.01518051,  12.02518051,  12.03518051,
        12.04518051,  12.05518051,  12.06518051,  12.07518051,
        12.08518051,  12.09518051,  12.10518051,  12.11518051,
        12.12518051,  12.13518051,  12.14518051,  12.15518051,
        12.16518051,  12.17518051,  12.18518051,  12.19518051,
        12.20518051,  12.21518051,  12.22518051,  12.23518051,
        12.24518051,  12.25518051,  12.26518051,  12.27518051,
        12.28518051,  12.29518051,  12.30518051,  12.31518051,
        12.32518051,  12.33518051,  12.34518051,  12.35518051,
        12.36518051,  12.37518051,  12.38518051,  12.39518051,
        12.40518051,  12.41518051,  12.42518051,  12.43518051,
        12.44518051,  12.45518051,  12.46518051,  12.47518051,
        12.48518051,  12.49518051,  12.50518051,  12.51518051,
        12.52518051,  12.53518051,  12.54518051,  12.55518051,
        12.56518051,  12.57518051,  12.58518051,  12.59518051,
        12.60518051,  12.61518051,  12.62518051,  12.63518051,
        12.64518051,  12.65518051,  12.66518051,  12.67518051,
        12.68518051,  12.69518051,  12.70518051,  12.71518051,
        12.72518051,  12.73518051,  12.74518051,  12.75518051,
        12.76518051,  12.77518051,  12.78518051,  12.79518051,
        12.80518051,  12.81518051,  12.82518051,  12.83518051,
        12.84518051,  12.85518051,  12.86518051,  12.87518051,
        12.88518051,  12.89518051,  12.90518051,  12.91518051,
        12.92518051,  12.93518051,  12.94518051,  12.95518051,
        12.96518051,  12.97518051,  12.98518051,  12.99518051])

In [96]:
dat = np.vstack((mvir, cvir)).T


Out[96]:
array([[ 12.9984773 ,   6.87133341],
       [ 12.99576678,   7.99383771],
       [ 12.99545969,   7.77361236],
       ..., 
       [ 11.00518051,  12.18733575],
       [ 11.00518051,   7.85078597],
       [ 11.00518051,  12.06802974]])

In [97]:
conc = [[el[1] for el in dat if ((el[0] > bins[i]) & (el[0] < bins[i+1]))] for i in range(len(bins)-1)]

In [98]:
conc_means = np.array([np.mean(np.array(c)) for c in conc])
conc_stds = np.array([np.std(np.array(c)) for c in conc])

In [99]:
conc_means


Out[99]:
array([  9.77936912,   9.84515484,   9.83913809,   9.91275656,
         9.99087617,   9.99557462,  10.04738105,  10.08994688,
        10.10991113,  10.1613277 ,  10.14419521,  10.18396736,
        10.2491665 ,  10.28590059,  10.30133357,  10.33444641,
        10.37542191,  10.39712478,  10.39152178,  10.38358153,
        10.39242448,  10.44051295,  10.42595113,  10.46683426,
        10.47281422,  10.49061161,  10.48247952,  10.47662531,
        10.51253532,  10.4846388 ,  10.43633595,  10.48347627,
        10.46158489,  10.45889344,  10.48919122,  10.47309588,
        10.48924248,  10.47801136,  10.4929785 ,  10.42641018,
        10.43279333,  10.45172279,  10.44513032,  10.36253961,
        10.4068741 ,  10.39128446,  10.3960775 ,  10.40129613,
        10.39090011,  10.3638259 ,  10.35932653,  10.29109556,
        10.31428333,  10.26008058,  10.24534699,  10.19532496,
        10.21423593,  10.24958915,  10.21288151,  10.12875722,
        10.17273007,  10.15432568,  10.12223138,  10.06358431,
        10.086467  ,  10.06126629,  10.05614368,  10.03155912,
         9.98326786,  10.00914168,   9.94263383,   9.93143923,
         9.8826634 ,   9.90475607,   9.90308536,   9.85828165,
         9.82731   ,   9.92616291,   9.87210839,   9.73616879,
         9.78127007,   9.69919068,   9.78190957,   9.70419718,
         9.6565871 ,   9.59701001,   9.68649831,   9.64197514,
         9.60607723,   9.59155174,   9.58420934,   9.5238126 ,
         9.55954221,   9.56724775,   9.49884423,   9.4578373 ,
         9.45247309,   9.45739641,   9.52158777,   9.44377597,
         9.41666614,   9.35656999,   9.33784559,   9.3988433 ,
         9.37274065,   9.23238229,   9.36434332,   9.2628529 ,
         9.25558533,   9.27538322,   9.16660076,   9.27278844,
         9.23922918,   9.15317225,   9.10392426,   9.14526106,
         9.09903102,   8.99346106,   9.07128272,   9.02214654,
         8.9399598 ,   9.01645755,   8.98806756,   9.00068745,
         8.88514786,   8.86438886,   8.88105515,   8.83740778,
         8.81608959,   8.83030122,   8.8114919 ,   8.80121284,
         8.69440446,   8.78123772,   8.60328049,   8.67573477,
         8.55294074,   8.6229809 ,   8.52556712,   8.62419803,
         8.64856815,   8.61309793,   8.48386097,   8.49261608,
         8.44748785,   8.49489944,   8.42038747,   8.5271544 ,
         8.3952607 ,   8.42545715,   8.30700296,   8.34696002,
         8.29050239,   8.35942268,   8.2909446 ,   8.283447  ,
         8.37351901,   8.16682682,   8.26740301,   8.20034555,
         8.21127887,   8.12730458,   8.21806036,   8.16052059,
         8.17848546,   8.11907268,   8.11517602,   8.10795657,
         7.97171669,   7.96078367,   8.01544868,   7.9801173 ,
         8.00328467,   7.92817912,   7.88226909,   7.9163933 ,
         7.94885042,   7.90608909,   7.8898565 ,   7.84200235,
         7.81206668,   7.70350687,   7.80284927,   7.78462273,
         7.61142116,   7.68910197,   7.58437771,   7.66404839,
         7.60937456,   7.57779209,   7.62798084,   7.70335697,
         7.62033255,   7.60000478,   7.47337763,   7.333897  ,
         7.51066326,   7.50559779,   7.5321532 ])

In [106]:
faxes = np.reshape(figure.axes, (2,2))
ax=faxes[1,0]

In [107]:
ax.plot(bins[1:], conc_means, lw=2, color='blue')
ax.fill_between(bins[1:], conc_means+conc_stds, conc_means-conc_stds, facecolor='blue', alpha=0.5)


Out[107]:
<matplotlib.collections.PolyCollection at 0x8da37950>

In [109]:
ax.set_xlim((11,13))
ax.set_ylim((4, 20))


Out[109]:
(4, 20)

In [110]:
figure


Out[110]:

In [92]:
hlist_path = '/lustre/ki/pfs/mwillia1/LG_project/Consuelo_Boxes/4001/4001hlist.npy'
hlist = np.load(hlist_path)
hlist=hlist[np.abs(np.log10(hlist['mvir'])-12)<1.0]

In [94]:
scatter(np.log10(hlist['mvir']), hlist['rvir']/hlist['rs'])


Out[94]:
<matplotlib.collections.PathCollection at 0x6eb74950>

In [111]:
H, xedge, yedge = np.histogram2d(mvir, cvir, bins=[10,10])

In [114]:
H[0,:]


Out[114]:
array([  3.69041000e+05,   2.90229000e+05,   3.67120000e+04,
         3.74100000e+03,   5.09000000e+02,   7.90000000e+01,
         1.00000000e+01,   3.00000000e+00,   0.00000000e+00,
         1.00000000e+00])

In [ ]: