In [1]:
%load_ext autoreload
%autoreload 2
%matplotlib inline

MOCK = 1
execfile ("_ImportScript.py")


1

In [2]:
execfile ("_ReconstructionScript.py")


/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/universe.py:553: RuntimeWarning: divide by zero encountered in power
  self.Power_Spectrum = self.PSnorm*10000*np.power((self.k/self.kstar) ,(-3+(self.n_s-1)))
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/universe.py:390: ComplexWarning: Casting complex values to real discards the imaginary part
  ay_real[zero_ind] = value[zero_ind].astype(np.float)
Generated  32  potential Fourier coefficients
 with phases uniformly distributed between 0 and  3.14159265359
Built potential grid, with dimensions  (41, 41, 41)  and mean value  0.0 +/- 0.6204311
Sigma is 0.000000 arcmin (0.000000 rad) 
-> fwhm is 0.000000 arcmin
Sigma is 0.000000 arcmin (0.000000 rad) 
-> fwhm is 0.000000 arcmin
Sigma is 0.000000 arcmin (0.000000 rad) 
-> fwhm is 0.000000 arcmin
Sigma is 0.000000 arcmin (0.000000 rad) 
-> fwhm is 0.000000 arcmin
/Users/LaurencePeanuts/Documents/Travail/Stanford/Music/Music/beatbox/multiverse.py:355: ComplexWarning: Casting complex values to real discards the imaginary part
  R_real[zero_ind,:] = beatbox.Universe.R[zero_ind,:].astype(np.float)

In [8]:
# From those f_n's build the 3d spatial potential:
ind = np.where(We.kfilter>0)
NN = 2*len(ind[1])
k_x, k_y, k_z = We.kx[ind], We.ky[ind], We.kz[ind]


RealPhi = np.zeros(We.x.shape,dtype=np.complex128)
for i in range(len(ind[1])):
    phase = k_x[i] * We.x + k_y[i] * We.y + k_z[i] * We.z
    RealPhi += (We.fn[i] * np.cos(phase)+We.fn[len(ind[1])+i]*np.sin(phase))*We.Deltak_for_iFFT**3
    We.phi = RealPhi.real
    
Weres2 = beatbox.Universe()
Weres2.fn = beatbox.You.all_simulated_universes[-1].fn.reshape(len(We.fn),1)-We.fn
#ind = np.where(Weres2.kfilter>0)
#NN = 2*len(ind[1])
k_x, k_y, k_z = Weres2.kx[ind], Weres2.ky[ind], Weres2.kz[ind]
RealPhi2 = np.zeros(We.x.shape,dtype=np.complex128)
for i in range(len(ind[1])):
    phase2 = k_x[-i] * Weres2.x + k_y[-i] * Weres2.y + k_z[-i] * Weres2.z
    RealPhi2 += (Weres2.fn[-i] * np.cos(phase2)+Weres2.fn[len(ind[1])-i]*np.sin(phase2))*Weres2.Deltak_for_iFFT**3
    Weres2.phi = RealPhi2.real
Weres2.Pdist=1
Weres2.Pmax=2*np.pi

In [3]:
We.rearrange_fn_from_vector_to_grid()
We.evaluate_potential_given_fourier_coefficients()


Built potential grid, with dimensions  (41, 41, 41)  and mean value  0.0 +/- 0.6040781

In [8]:
import matplotlib.pyplot as plt
imgplot = plt.imshow(beatbox.You.all_simulated_universes[-1].phi[:,:,20])



In [55]:
plt.imshow(We.phi[:,:,20])


Out[55]:
<matplotlib.image.AxesImage at 0x11053e510>

In [ ]:
beatbox.You.all_simulated_universes[-1].Tmap=None
beatbox.You.all_simulated_universes[-1].alm=None
beatbox.You.all_simulated_universes[-1].transform_3D_potential_into_alm()
beatbox.You.all_simulated_universes[-1].show_CMB_T_map()
We.show_CMB_T_map()

In [ ]:
import glob
from PIL import Image as PIL_Image
from images2gif import writeGif
images = [PIL_Image.open(framefile) for framefile in glob.glob('../frames/*.png')]


writeGif('l.gif', images, duration=0.2)

In [ ]:
import yt

In [52]:
We.Pdist=1
We.Pmax=2*np.pi
We.show_potential_with_yt(angle=np.pi/8,  N_layer=7, cmap='coolwarm', show3D=1, Slice=1)


yt : [INFO     ] 2016-04-06 15:34:25,603 Parameters: current_time              = 0.0
yt : [INFO     ] 2016-04-06 15:34:25,603 Parameters: domain_dimensions         = [41 41 41]
yt : [INFO     ] 2016-04-06 15:34:25,605 Parameters: domain_left_edge          = [-1.95121951 -1.95121951 -1.95121951]
yt : [INFO     ] 2016-04-06 15:34:25,606 Parameters: domain_right_edge         = [ 1.95121951  1.95121951  1.95121951]
yt : [INFO     ] 2016-04-06 15:34:25,607 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2016-04-06 15:34:25,642 Loading field plugins.
yt : [INFO     ] 2016-04-06 15:34:25,643 Loaded angular_momentum (8 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,644 Loaded astro (15 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,646 Loaded cosmology (22 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,647 Loaded fluid (64 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,649 Loaded fluid_vector (96 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,651 Loaded geometric (112 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,652 Loaded local (112 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,653 Loaded magnetic_field (120 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,656 Loaded my_plugins (120 new fields)
yt : [INFO     ] 2016-04-06 15:34:25,657 Loaded species (122 new fields)
1
-2.07889507667 1.4266009367
yt : [INFO     ] 2016-04-06 15:34:31,528 xlim = -1.951220 1.951220
yt : [INFO     ] 2016-04-06 15:34:31,529 ylim = -1.951220 1.951220
yt : [INFO     ] 2016-04-06 15:34:31,532 xlim = -1.951220 1.951220
yt : [INFO     ] 2016-04-06 15:34:31,533 ylim = -1.951220 1.951220
yt : [INFO     ] 2016-04-06 15:34:31,535 Making a fixed resolution buffer of (('gas', 'density')) 800 by 800

yt : [INFO     ] 2016-04-06 15:34:32,213 Saving plot phi_Slice_z_density.png

In [53]:
#A.evaluate_potential_given_fourier_coefficients(printout=0)
beatbox.You.all_simulated_universes[-1].show_potential_with_yt(angle=np.pi/8,  N_layer=7, cmap='coolwarm', show3D=1, Slice=1)


yt : [INFO     ] 2016-04-06 15:34:44,989 Parameters: current_time              = 0.0
yt : [INFO     ] 2016-04-06 15:34:44,989 Parameters: domain_dimensions         = [41 41 41]
yt : [INFO     ] 2016-04-06 15:34:44,990 Parameters: domain_left_edge          = [-1.95121951 -1.95121951 -1.95121951]
yt : [INFO     ] 2016-04-06 15:34:44,991 Parameters: domain_right_edge         = [ 1.95121951  1.95121951  1.95121951]
yt : [INFO     ] 2016-04-06 15:34:44,992 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2016-04-06 15:34:45,017 Loading field plugins.
yt : [INFO     ] 2016-04-06 15:34:45,018 Loaded angular_momentum (8 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,018 Loaded astro (15 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,019 Loaded cosmology (22 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,020 Loaded fluid (64 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,022 Loaded fluid_vector (96 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,022 Loaded geometric (112 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,023 Loaded local (112 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,023 Loaded magnetic_field (120 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,024 Loaded my_plugins (120 new fields)
yt : [INFO     ] 2016-04-06 15:34:45,024 Loaded species (122 new fields)
-1.93310454434 1.67674105547