In [1]:
%load_ext autoreload
%matplotlib inline
execfile ("_ImportScript.py")
import time


1

In [2]:
import matplotlib.pyplot as plt

In [3]:
beatbox.You.create_original_Universe()

In [4]:
numreal = 100

for i in range(numreal):
    beatbox.You.initiate_simulated_universe(truncated_nmax = 15)


Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
Generated  14146  potential Fourier coefficients
 with phases uniformly distributed between 0 and  6.28318530718
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/universe.py:597: RuntimeWarning: divide by zero encountered in power
  self.Power_Spectrum = self.PSnorm*10000*np.power((self.k/self.kstar) ,(-3+(self.n_s-1)))

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [5]:
if not os.path.isfile('../data/covCyy_lmax%d_lmin%d.txt' % (beatbox.Multiverse.truncated_lmax, beatbox.Multiverse.truncated_lmin)):
    beatbox.You.read_Planck_samples()
    beatbox.You.calculate_covariance_matrix(filename='lmax%d_lmin%d' % (beatbox.Multiverse.truncated_lmax, beatbox.Multiverse.truncated_lmin))
else:
    beatbox.You.load_covariance_matrix(filename='covCyy_lmax%d_lmin%d.txt' % (beatbox.Multiverse.truncated_lmax, beatbox.Multiverse.truncated_lmin))
    
# Calculate the inverse of the a_y covariance matrix
beatbox.You.calculate_sdv_Cyy_inverse()


datamap = beatbox.You.all_simulated_universes[0].ay2ayreal_for_inference(beatbox.You.all_simulated_universes[0].ay)+beatbox.You.generate_one_realization_of_noise()
beatbox.You.all_simulated_universes[-1].ay_real = datamap
 

MOCK = 1
beatbox.You.solve_for_3D_potential(datamap.T , A=None, print_alpha=0)


0.00809693336487
total time is:
0.266053915024
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/universe.py:431: ComplexWarning: Casting complex values to real discards the imaginary part
  ay_real[zero_ind] = value[zero_ind].astype(np.float)
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/multiverse.py:494: ComplexWarning: Casting complex values to real discards the imaginary part
  R_real[zero_ind,:] = beatbox.Universe.R[zero_ind,:].astype(np.float)
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/multiverse.py:440: RuntimeWarning: divide by zero encountered in power
  Power_Spectrum = PSnorm*10000*np.power((beatbox.Universe.k/kstar) ,(-3+(n_s-1)))

In [6]:
# cov_frac = np.zeros((numreal,1))
num_fn_rec = beatbox.Universe.numfn
num_fn_sim = beatbox.You.all_simulated_universes[0].get_instance_numfn()
num_l_modes = beatbox.You.inv_Cyy.shape[0]

true_fn_all = np.zeros((numreal,num_fn_sim))
true_fns = np.zeros((numreal,num_fn_rec))
datamap = np.zeros((numreal,num_l_modes))
noise_realization  = np.zeros((numreal,num_l_modes))
rec_fns = np.zeros((numreal,num_fn_rec))
diff_sigma = np.zeros((numreal,num_fn_rec))

ind = np.where(beatbox.You.all_simulated_universes[0].kfilter>0)
n = beatbox.Universe.n[ind]
n_fit = 7
nvec_long = np.zeros(2*len(ind[1]))
nvec_long[:len(ind[1])] = n
nvec_long[len(ind[1]): ] = n
nvec = np.zeros(len(ind[1]))
nvec[:len(ind[1])/2] = nvec_long[:len(ind[1])/2]
nvec[len(ind[1])/2: ] = nvec_long[len(ind[1]):3*len(ind[1])/2]
ind_fit = np.where(nvec <= n_fit)


for i in range(numreal):
# i =0
#     print i
    noise_realization[i,:] = beatbox.You.generate_one_realization_of_noise()
    true_alms = beatbox.You.all_simulated_universes[i].ay2ayreal_for_inference(beatbox.You.all_simulated_universes[i].ay)
    datamap[i,:] =  true_alms + noise_realization[i,:]
    beatbox.You.solve_for_3D_potential(datamap[i,:].T , A=1, print_alpha=0)

    We=beatbox.Universe()        
    beatbox.You.all_data_universes = np.append(beatbox.You.all_data_universes,We)
    beatbox.You.all_data_universes[i].fn = beatbox.You.reconstrunct_fn

    if i == 0:
            ordered_inds_largenmax = beatbox.You.all_simulated_universes[i].get_ordered_fn_indices()
            ordered_inds_smallnmax = beatbox.You.all_data_universes[i].get_ordered_fn_indices()
    min_n_mode = np.min((len(ordered_inds_largenmax), len(ordered_inds_smallnmax) )    )

    true_fn_all[i,:] = beatbox.You.all_simulated_universes[i].fn.reshape(1,-1)
    true_fns[i,:] = (beatbox.You.all_simulated_universes[i].fn[ind_fit])[ordered_inds_smallnmax]
    rec_fns[i,:] = beatbox.You.all_data_universes[i].fn[ordered_inds_smallnmax[:min_n_mode]].reshape(1,-1)
    abs_diff = np.abs(true_fns[i,:] - rec_fns[i,:])
    err_sig = np.sqrt(np.diag(beatbox.You.inv_A)[ordered_inds_smallnmax[:min_n_mode]])
    diff_sigma[i,:] = np.divide(abs_diff.reshape(1,-1) , err_sig.reshape(1,-1) ).reshape(1,-1)

cov_frac = np.double(np.sum(diff_sigma<=1,axis=0)) / np.double(numreal)

#     np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data/noise_" + str("%0.03d" % i) + ".txt", noise_realization)
#     np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data/true_alm_" + str("%0.03d" % i) + ".txt", true_alms)
#     np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data/true_fn_" + str("%0.03d" % i) + ".txt", true_fns )
#     np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data/rec_fn_" + str("%0.03d" % i) + ".txt", rec_fns )
#     np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data/abs_diff_" + str("%0.03d" % i) + ".txt", abs_diff)
print np.mean(cov_frac)


0.000550985336304
time for loading is:
0.00351190567017
successfully loaded A from the disk.
total time is:
0.00482892990112
0.000651121139526
time for loading is:
0.00981092453003
successfully loaded A from the disk.
total time is:
0.0114059448242
0.00090503692627
time for loading is:
0.00366401672363
successfully loaded A from the disk.
total time is:
0.00535583496094
0.000730991363525
time for loading is:
0.00394105911255
successfully loaded A from the disk.
total time is:
0.00549292564392
0.00120282173157
time for loading is:
0.00420594215393
successfully loaded A from the disk.
total time is:
0.00615382194519
0.000484943389893
time for loading is:
0.00359511375427
successfully loaded A from the disk.
total time is:
0.00518894195557
0.000707864761353
time for loading is:
0.00402903556824
successfully loaded A from the disk.
total time is:
0.00552201271057
0.000643968582153
time for loading is:
0.0054988861084
successfully loaded A from the disk.
total time is:
0.00825500488281
0.00127482414246
time for loading is:
0.00974202156067
successfully loaded A from the disk.
total time is:
0.0119609832764
0.000730037689209
time for loading is:
0.00607800483704
successfully loaded A from the disk.
total time is:
0.00787496566772
0.000489950180054
time for loading is:
0.00348615646362
successfully loaded A from the disk.
total time is:
0.00473999977112
0.00123190879822
time for loading is:
0.00531888008118
successfully loaded A from the disk.
total time is:
0.00735783576965
0.00182008743286
time for loading is:
0.0069260597229
successfully loaded A from the disk.
total time is:
0.010274887085
0.000657081604004
time for loading is:
0.00383496284485
successfully loaded A from the disk.
total time is:
0.00518488883972
0.000478029251099
time for loading is:
0.00345301628113
successfully loaded A from the disk.
total time is:
0.0046911239624
0.00046706199646
time for loading is:
0.00324988365173
successfully loaded A from the disk.
total time is:
0.00442314147949
0.000489950180054
time for loading is:
0.0040271282196
successfully loaded A from the disk.
total time is:
0.00514578819275
0.00071907043457
time for loading is:
0.0042519569397
successfully loaded A from the disk.
total time is:
0.0060338973999
0.00166416168213
time for loading is:
0.00442600250244
successfully loaded A from the disk.
total time is:
0.00819802284241
0.00100493431091
time for loading is:
0.00409579277039
successfully loaded A from the disk.
total time is:
0.00595688819885
0.000611066818237
time for loading is:
0.00397205352783
successfully loaded A from the disk.
total time is:
0.00621104240417
0.00078010559082
time for loading is:
0.00374102592468
successfully loaded A from the disk.
total time is:
0.00534105300903
0.00049090385437
time for loading is:
0.00350999832153
successfully loaded A from the disk.
total time is:
0.00510692596436
0.000764846801758
time for loading is:
0.00418591499329
successfully loaded A from the disk.
total time is:
0.00563192367554
0.0025520324707
time for loading is:
0.00670003890991
successfully loaded A from the disk.
total time is:
0.0108830928802
0.000656843185425
time for loading is:
0.00374221801758
successfully loaded A from the disk.
total time is:
0.00519800186157
0.000479936599731
time for loading is:
0.00331711769104
successfully loaded A from the disk.
total time is:
0.00441598892212
0.000468015670776
time for loading is:
0.00360608100891
successfully loaded A from the disk.
total time is:
0.00468897819519
0.000484943389893
time for loading is:
0.00355291366577
successfully loaded A from the disk.
total time is:
0.00471091270447
0.000468015670776
time for loading is:
0.00330781936646
successfully loaded A from the disk.
total time is:
0.00494003295898
0.000797986984253
time for loading is:
0.00403189659119
successfully loaded A from the disk.
total time is:
0.00577902793884
0.00147294998169
time for loading is:
0.00580811500549
successfully loaded A from the disk.
total time is:
0.00864291191101
0.00055193901062
time for loading is:
0.00377297401428
successfully loaded A from the disk.
total time is:
0.00511288642883
0.000463008880615
time for loading is:
0.00325107574463
successfully loaded A from the disk.
total time is:
0.00433611869812
0.000466108322144
time for loading is:
0.00340223312378
successfully loaded A from the disk.
total time is:
0.00467300415039
0.000488042831421
time for loading is:
0.00364995002747
successfully loaded A from the disk.
total time is:
0.00475597381592
0.000463962554932
time for loading is:
0.00326418876648
successfully loaded A from the disk.
total time is:
0.00488185882568
0.00074577331543
time for loading is:
0.00475382804871
successfully loaded A from the disk.
total time is:
0.00632286071777
0.000940084457397
time for loading is:
0.00454902648926
successfully loaded A from the disk.
total time is:
0.0061719417572
0.000485897064209
time for loading is:
0.00367283821106
successfully loaded A from the disk.
total time is:
0.005206823349
0.00116920471191
time for loading is:
0.00530099868774
successfully loaded A from the disk.
total time is:
0.0072181224823
0.000547170639038
time for loading is:
0.00427389144897
successfully loaded A from the disk.
total time is:
0.00568294525146
0.000695943832397
time for loading is:
0.00350499153137
successfully loaded A from the disk.
total time is:
0.00533485412598
0.00114178657532
time for loading is:
0.00493502616882
successfully loaded A from the disk.
total time is:
0.00682592391968
0.00218415260315
time for loading is:
0.00457787513733
successfully loaded A from the disk.
total time is:
0.00767993927002
0.00114393234253
time for loading is:
0.00592994689941
successfully loaded A from the disk.
total time is:
0.00786590576172
0.000752925872803
time for loading is:
0.00341296195984
successfully loaded A from the disk.
total time is:
0.00486493110657
0.000536918640137
time for loading is:
0.00355911254883
successfully loaded A from the disk.
total time is:
0.00481295585632
0.000464916229248
time for loading is:
0.00337815284729
successfully loaded A from the disk.
total time is:
0.00484800338745
0.000576019287109
time for loading is:
0.00449013710022
successfully loaded A from the disk.
total time is:
0.00607991218567
0.000764846801758
time for loading is:
0.00711798667908
successfully loaded A from the disk.
total time is:
0.00849986076355
0.000491142272949
time for loading is:
0.00580501556396
successfully loaded A from the disk.
total time is:
0.00740098953247
0.000781059265137
time for loading is:
0.00434803962708
successfully loaded A from the disk.
total time is:
0.00585412979126
0.000482082366943
time for loading is:
0.00433802604675
successfully loaded A from the disk.
total time is:
0.00683307647705
0.000691890716553
time for loading is:
0.0047619342804
successfully loaded A from the disk.
total time is:
0.00661492347717
0.000790119171143
time for loading is:
0.00708508491516
successfully loaded A from the disk.
total time is:
0.00909304618835
0.00359201431274
time for loading is:
0.00701498985291
successfully loaded A from the disk.
total time is:
0.0123178958893
0.0011420249939
time for loading is:
0.00497913360596
successfully loaded A from the disk.
total time is:
0.00694489479065
0.0015230178833
time for loading is:
0.00536704063416
successfully loaded A from the disk.
total time is:
0.00769591331482
0.000473976135254
time for loading is:
0.00413203239441
successfully loaded A from the disk.
total time is:
0.00779795646667
0.000733852386475
time for loading is:
0.00722312927246
successfully loaded A from the disk.
total time is:
0.00910687446594
0.00309586524963
time for loading is:
0.00653100013733
successfully loaded A from the disk.
total time is:
0.0104718208313
0.000462055206299
time for loading is:
0.00377202033997
successfully loaded A from the disk.
total time is:
0.00541210174561
0.000940084457397
time for loading is:
0.00484776496887
successfully loaded A from the disk.
total time is:
0.00641703605652
0.000463008880615
time for loading is:
0.00369691848755
successfully loaded A from the disk.
total time is:
0.00686502456665
0.00101089477539
time for loading is:
0.00431108474731
successfully loaded A from the disk.
total time is:
0.00602602958679
0.000827074050903
time for loading is:
0.00955080986023
successfully loaded A from the disk.
total time is:
0.0110759735107
0.000468015670776
time for loading is:
0.00332808494568
successfully loaded A from the disk.
total time is:
0.0044801235199
0.00119709968567
time for loading is:
0.00687909126282
successfully loaded A from the disk.
total time is:
0.00928401947021
0.000466108322144
time for loading is:
0.00355982780457
successfully loaded A from the disk.
total time is:
0.00478792190552
0.00092887878418
time for loading is:
0.00565505027771
successfully loaded A from the disk.
total time is:
0.00800180435181
0.000686883926392
time for loading is:
0.00387597084045
successfully loaded A from the disk.
total time is:
0.00536680221558
0.00187110900879
time for loading is:
0.00364184379578
successfully loaded A from the disk.
total time is:
0.0062210559845
0.000463962554932
time for loading is:
0.00497102737427
successfully loaded A from the disk.
total time is:
0.00753903388977
0.00197100639343
time for loading is:
0.00359797477722
successfully loaded A from the disk.
total time is:
0.00625014305115
0.00076699256897
time for loading is:
0.00679898262024
successfully loaded A from the disk.
total time is:
0.00931715965271
0.000747919082642
time for loading is:
0.00390410423279
successfully loaded A from the disk.
total time is:
0.00557804107666
0.000736951828003
time for loading is:
0.00710105895996
successfully loaded A from the disk.
total time is:
0.00926113128662
0.000465869903564
time for loading is:
0.00346803665161
successfully loaded A from the disk.
total time is:
0.00475883483887
0.00130701065063
time for loading is:
0.00443696975708
successfully loaded A from the disk.
total time is:
0.0066249370575
0.00078296661377
time for loading is:
0.00438618659973
successfully loaded A from the disk.
total time is:
0.00587296485901
0.000487089157104
time for loading is:
0.00328803062439
successfully loaded A from the disk.
total time is:
0.00483989715576
0.000665187835693
time for loading is:
0.00420689582825
successfully loaded A from the disk.
total time is:
0.00574898719788
0.000693798065186
time for loading is:
0.00814294815063
successfully loaded A from the disk.
total time is:
0.00978183746338
0.00222110748291
time for loading is:
0.00516414642334
successfully loaded A from the disk.
total time is:
0.00909996032715
0.000760078430176
time for loading is:
0.00360894203186
successfully loaded A from the disk.
total time is:
0.00505495071411
0.000532865524292
time for loading is:
0.00383996963501
successfully loaded A from the disk.
total time is:
0.00512385368347
0.000516891479492
time for loading is:
0.00341892242432
successfully loaded A from the disk.
total time is:
0.0049889087677
0.000643968582153
time for loading is:
0.00448298454285
successfully loaded A from the disk.
total time is:
0.00609612464905
0.000743865966797
time for loading is:
0.00766205787659
successfully loaded A from the disk.
total time is:
0.00913906097412
0.000545024871826
time for loading is:
0.00612998008728
successfully loaded A from the disk.
total time is:
0.00793099403381
0.000476837158203
time for loading is:
0.00324892997742
successfully loaded A from the disk.
total time is:
0.00435185432434
0.000477075576782
time for loading is:
0.00361299514771
successfully loaded A from the disk.
total time is:
0.00486707687378
0.000508069992065
time for loading is:
0.00353598594666
successfully loaded A from the disk.
total time is:
0.00473117828369
0.000464916229248
time for loading is:
0.00385904312134
successfully loaded A from the disk.
total time is:
0.00542187690735
0.0024721622467
time for loading is:
0.00945496559143
successfully loaded A from the disk.
total time is:
0.0135350227356
0.00111794471741
time for loading is:
0.00586605072021
successfully loaded A from the disk.
total time is:
0.00775003433228
0.00046706199646
time for loading is:
0.00326800346375
successfully loaded A from the disk.
total time is:
0.00436210632324
0.000582933425903
time for loading is:
0.00386500358582
successfully loaded A from the disk.
total time is:
0.00521492958069
0.000465869903564
time for loading is:
0.00328087806702
successfully loaded A from the disk.
total time is:
0.00450992584229
0.722175324675

In [7]:
execfile ("_CalcEvidence.py")


/Users/LaurencePeanuts/miniconda2/lib/python2.7/site-packages/numpy/linalg/linalg.py:1821: RuntimeWarning: overflow encountered in det
  r = _umath_linalg.det(a, signature=signature)
/Users/LaurencePeanuts/miniconda2/lib/python2.7/site-packages/ipykernel/__main__.py:47: RuntimeWarning: divide by zero encountered in log10
-inf
0.0

In [8]:
print EvidenceVector


[ nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan
  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan]

In [ ]:
noise_realization.shape

In [ ]:
ind = np.where(beatbox.You.all_simulated_universes[0].kfilter>0)
n = beatbox.Universe.n[ind]
n_fit = 5

nvec_long = np.zeros(2*len(ind[1]))
nvec_long[:len(ind[1])] = n
nvec_long[len(ind[1]): ] = n

nvec = np.zeros(len(ind[1]))
nvec[:len(ind[1])/2] = nvec_long[:len(ind[1])/2]
nvec[len(ind[1])/2: ] = nvec_long[len(ind[1]):3*len(ind[1])/2]

ind_fit = np.where(nvec <= n_fit)

TRUEFNFIT = (beatbox.You.all_simulated_universes[0].fn[ind_fit])[ordered_inds_smallnmax]
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/TRUEFNFIT.npy", TRUEFNFIT)

In [ ]:
def KL(mu0,mu1,C0,C1,C1_inv):
    k = C0.shape[0]
    detrat = np.divide(np.det(C1) , np.det(C0))
    D_KL = 0.5 * ( np.trace(C1_inv*C0) + (mu1-mu0).T * C1_inv * (mu1-mu0) - k + np.log(detrat))
    return D_KL

In [ ]:


In [ ]:
R_orig =

In [ ]:


In [ ]:
np.unique(beatbox.You.all_data_universes[0].kfilter)

In [ ]:
# np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data2/err_sig.txt", err_sig)
# np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data2/Cn.txt", beatbox.You.inv_Cyy)
# np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data2/Cp.txt", beatbox.You.inv_Cf)
# np.savetxt( "/Users/yashar/GravIT/Cycle_4_analysis/data2/R.txt", beatbox.You.R_real)

np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/Cn.npy", beatbox.You.inv_Cyy)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/Cp.npy", beatbox.You.inv_Cf)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/R.npy", beatbox.You.R_real)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/inv_A.npy", beatbox.You.inv_A)

# np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/R.npy", beatbox.You.R_real)


np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/noise_realization.npy", noise_realization)

np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/truefnall.npy", true_fn_all)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/truefn.npy", true_fns)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/recfn.npy", rec_fns)
np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/datamap.npy", datamap)

np.save( "/Users/yashar/GravIT/Cycle_4_analysis/data2/err_sig.npy", err_sig)

In [ ]:
# Check calculated k covariance from samples, against prior covariance matrix
numCp = np.zeros(len(beatbox.You.all_simulated_universes[0].fn))
for j in range(len(beatbox.You.all_simulated_universes[0].fn)):
    fns = [beatbox.You.all_simulated_universes[i].fn[j] for i in range(numreal)]
    numCp[j] = np.std(fns) #1./(np.std(fns)**2)

plt.plot(numCp)
plt.plot(1/np.sqrt(np.diag(beatbox.You.inv_Cf)),'--')

In [ ]:
plt.plot(beatbox.You.all_simulated_universes[0].fn[ordered_inds_largenmax],' +')
err_sig = np.sqrt(np.diag(beatbox.You.inv_A)[ordered_inds_smallnmax])
eb2 = plt.errorbar(np.arange(0,len(beatbox.You.all_data_universes[0].fn)).reshape(-1,1) , beatbox.You.all_data_universes[0].fn[ordered_inds_smallnmax].reshape(-1,1) , yerr = err_sig.reshape(-1,1),ls=' ')
plt.axis([1 ,34, -20, 20])

In [ ]:
# test that the noise covariance matrix is correct
datamap = np.zeros((numreal,24))

for i in range(numreal):
    datamap[i,:] = beatbox.You.generate_one_realization_of_noise()

In [ ]:
datamap.shape

In [ ]:
plt.subplot(1,2,1)
plt.imshow(np.cov(datamap.T))
plt.colorbar()

plt.subplot(1,2,2)
plt.imshow(np.linalg.inv(beatbox.You.inv_Cyy))
plt.colorbar()

In [ ]:


In [32]:
import matplotlib.pyplot as plt
plt.plot([2,3,4,5,6], [np.log10(2.87668901799e-15)  , np.log10(1.57315391567e-15)  , np.log10(1.5032425107e-15)  , np.log10(1.41114944731e-15) , np.log10(1.38385018135e-15)], 'r')
plt.plot([2,3,4,5,6], [np.log10(4.215e-34)  , np.log10(2.54236997449e-26)  , np.log10(1.31705376912e-26) , np.log10( 1.18082059763e-26), np.log10(1.01580984301e-26)], 'b')
plt.plot([2,3,4,5,6], [np.log10(3.82470293547e-106)  , np.log10(1.13637818657e-39 )  , np.log10(7.96146014194e-40 ) , np.log10( 5.14900346283e-40), np.log10(4.29121023639e-40)], 'g')
plt.plot([2,3,4,5,6], [-200  , np.log10(1.79234397169e-60  )  , np.log10(3.41007454966e-55 ) , np.log10( 1.6310229369e-55), np.log10(1.16874953693e-55)], 'm')
# plt.plot([2,3,4,5,6], [-200  , np.log10(3.00160414668e-116  )  , np.log10(1.52672624596e-73 ) , np.log10( 1.07692904355e-71), np.log10(3.16842357761e-72)], 'c')

# plt.plot([2,3,4,5,6], [-200  , -200, np.log10(2.00123030482e-121 ) , np.log10( 1.05208835636e-92), -200], 'y')






plt.show()



In [ ]:


In [ ]: