In [68]:
%matplotlib inline

import matplotlib.pyplot as plt
from scipy.stats import norm, lognorm
import pandas as pd
import numpy as np
from bigmali.grid import Grid
from bigmali.prior import TinkerPrior

tmp = pd.read_csv('~/Code/PanglossNotebooks/MassLuminosityProject/mock_data.csv')
mass = tmp.mass.as_matrix()
z = tmp.z.as_matrix()

In [69]:
# tmp.drop('mass', axis=1)
np.random.seed(5)
tp = TinkerPrior(Grid())
for i in xrange(len(z)):
    mass[i] = tp.fetch(z[i]).rvs()

In [70]:
np.random.seed(0)
alpha1 = norm(10.709, 0.022).rvs()
alpha2 = norm(0.359, 0.009).rvs()
alpha3 = 2.35e14
alpha4 = norm(1.10, 0.06).rvs()
S = norm(0.155, 0.0009).rvs()
sigma_L = 0.05
mu_li = np.exp(alpha1) * ((mass / alpha3) ** (alpha2))* ((1+z) ** (alpha4))
li = lognorm(S, scale=mu_li).rvs()
observed = lognorm(sigma_L, scale=li).rvs()

tmp['lum'] = li
tmp['lum_obs'] = observed

In [71]:
tmp.lum_obs.mean()


Out[71]:
4720.7123694413303

In [75]:
tmp[['z', 'lum_obs']].to_csv('mock_data_prior.txt', sep=' ', header=None, index=False)

In [77]:
! head -n 20 mock_data_prior.txt


2.07709 6715.29074505
2.00452 5607.89308131
1.99264 5450.83793785
1.99573 7452.97118222
2.04182 5720.09278598
2.12403 5763.26948185
2.01065 6228.30112917
2.14909 7316.61272003
2.04232 5842.4452677
2.12085 4802.50080084
1.97194 4854.72031055
1.99453 6425.0733143
1.99308 5618.79956444
2.03242 4738.59387442
1.98944 7287.72795434
1.97385 4498.15449063
2.10828 3638.51776142
2.08523 5822.3131512
2.0117 6562.25760826
2.01723 4527.11025555

In [74]:
! ls


IMG_20170623_090935.jpg
MassMapsFromMassLuminosity_20170626.ipynb
PhilMarshallMeeting_20170623.ipynb
PhilMarshallMeeting_20170629.ipynb
QuantifyingScalingAccuracy1_20170623.ipynb
RegenerateMockDataWithPriorForTesting_20170626.ipynb
ValidatingBigmaliAtScale_20170626.ipynb
ValidatingFullModelWithManySamples_20170629.ipynb
ValidatingLikelihoodVarianceAndSingleLikelihoodWeightDistribution_20170627.ipynb
ValidatingSimpleModelWithManySamples_20170627.ipynb
ValidatingSimplerModel_20160626.ipynb
bigmaliorig.out
bigmaliprior.out
foo.txt
fullexp10000.txt
justStest.txt
likelihoodvariancetest.txt
likelihoodvariancetest10000samples.txt
likelihoodvariancetest1000samples.txt
mock_data_prior.txt
simpletest10000.txt
singleintegralweightvariancetest.txt

In [79]:
tmp[['z', 'lum_obs', 'mass', 'ra', 'dec']].to_csv('mass_mapping.txt', sep=' ', header=None, index=False)

In [80]:
!head mass_mapping.txt


2.07709 6715.29074505 13932548093.8 -108.623172266 -101.696112523
2.00452 5607.89308131 34337650943.5 -106.131149632 -104.863308623
1.99264 5450.83793785 13808393964.5 -105.764685826 -102.987673984
1.99573 7452.97118222 43200001525.4 -105.287526574 -101.737709259
2.04182 5720.09278598 17187654319.5 -105.776374165 -102.895886146
2.12403 5763.26948185 19725390868.1 -107.538906934 -104.58450736
2.01065 6228.30112917 25528258777.6 -107.512780059 -102.34344024
2.14909 7316.61272003 17712533985.4 -108.392843232 -102.238932738
2.04232 5842.4452677 14656919082.6 -106.649905619 -103.2901957
2.12085 4802.50080084 13634319262.5 -106.629966688 -103.928585276

In [ ]: