Пример #1
0
def lightcone_xfrac(rsd=''):
    filenames = ["" for x in range(len(redshifts))]
    if rsd!='':
        vel_files=["" for x in range(len(redshifts)/2)]#]'/research/prace/sph_smooth_cubepm_130329_10_4000_244Mpc_ext2_test/global/so/nc250'+'%.3fv_all.dat'%z for z in redshifts]
        dens_files=["" for x in range(len(redshifts)/2)]#]'/research/prace/sph_smooth_cubepm_130329_10_4000_244Mpc_ext2_test/global/so/nc250'+'%.3fv_all.dat'%z for z in redshifts]
#    filenames[0] = len(redshifts)
    mini = -457
    maxi=83
    for i in range(len(filenames)):
        #filenames[i] = setup_dirs.path() + 'lightcone_temp/Temper3D_'+str('%.3f' % redshifts[i]) + '.bin'
        filenames[i] = filename = setup_dirs.path()+'xfrac3d_'+str('%.3f' % redshifts[i]) + '.bin'
        if i%2==0 and rsd!='':
            vel_files[i/2]='/research/prace/sph_smooth_cubepm_130329_10_4000_244Mpc_ext2_test/global/so/nc250/'+str('%.3f' % redshifts[i])+'v_all.dat'
            dens_files[i/2]='/research/prace/sph_smooth_cubepm_130329_10_4000_244Mpc_ext2_test/global/so/nc250/%.3fn_all.dat'%redshifts[i]
    noreds=10
#    redshifts_many = np.zeros(len(redshifts)*noreds)
#    for i in range(len(redshifts)-1):
#        for j in range(noreds):
#            redshifts_many[i+j]=redshifts[i]-(redshifts[i+1]-redshifts[i])*j/noreds
    print filenames
    im,z=c2t.make_lightcone(filenames)#,interpolation='step_cell')
    if rsd!='':
        vel_lightcone, z = c2t.make_velocity_lightcone(vel_files, dens_files)#,redshifts[0], redshifts[len(redshifts)-1])
        rsd_xfrac = c2t.get_distorted_dt(im, vel_lightcone, z, \
                              num_particles=30, los_axis=2, velocity_axis=0, \
                              periodic=False)
        im=np.asarray(rsd_xfrac)
        plot_lightcone(im[125,:,::-1],i,"Ionised Fraction","lightcone_rsd_xfrac",mini,maxi,z,cmap='Blues_r')
    else:
        im=np.asarray(im)
        plot_lightcone(im[125,:,::-1],i,"Ionised Fraction","lightconexfrac",mini,maxi,z,cmap='Blues_r')
Пример #2
0
base_path = '/disk/sn-12/garrelt/Science/Simulations/Reionization/C2Ray_WMAP5/114Mpc_WMAP5' 
density_filename = base_path+'/coarser_densities/halos_removed/30.000n_all.dat'
velocity_filename = base_path+'/coarser_densities/halos_removed/30.000v_all.dat'

#Enable output
c2t.set_verbose(True)

#We are using the 114/h Mpc simulation box, so set all the proper conversion factors
c2t.set_sim_constants(boxsize_cMpc = 114.)

#Read density
dfile = c2t.DensityFile(density_filename)

#Read a velocity data file
vfile = c2t.VelocityFile(velocity_filename)
kms = vfile.get_kms_from_density(dfile)

#Make a distorted box. Assume x_i = 0. We could of course also have calculated dT like in example.py
#and passed that to get_distorted_dt
distorted = c2t.get_distorted_dt(dfile.raw_density.astype('float64'), kms, dfile.z, los_axis=0, num_particles=20)

#Calculate power spectra
ps_dist,k = c2t.power_spectrum_1d(distorted)
ps_nodist,k = c2t.power_spectrum_1d(dfile.raw_density)

#Plot ratio
pl.semilogx(k, ps_dist/ps_nodist)
pl.xlabel('$k \; \mathrm{[Mpc^{-1}]}$')
pl.ylabel('$P_k^{\mathrm{PV}}/P_k^{\mathrm{NoPV}}$')
pl.show()
    vfile = c2t.VelocityFile(vel_file)
    kms = vfile.get_kms_from_density(dfile)

    mesh = (xfile.mesh_x, xfile.mesh_y, xfile.mesh_z)
    print 'mesh = ', mesh

    dT_box = c2t.calc_dt(xfile, dfile, xfile.z)
    dT_file = './dT_boxes/dT_%.3f.cbin' % (z_arr[i])
    print 'dT_box file = %s' % dT_file
    
    #rho = dfile.cgs_density
    #print 'rho_crit*OmegaB',c2t.const.rho_crit_0*c2t.const.OmegaB#*(1+z_arr[i])**3
    #print 'rho.mean()',rho.mean()
    c2t.save_cbin(dT_file, dT_box, bits=64, order='F')

    dT_pv_box = c2t.get_distorted_dt(dT_box, kms, xfile.z, num_particles=40)
    dT_pv_file = './dT_pv_boxes/dT_pv_%.3f.cbin' % (z_arr[i])
    print 'dT_pv_box file = %s' % dT_pv_file
    c2t.save_cbin(dT_pv_file, dT_pv_box, bits=64, order='F')

    dT_mean = dT_box.mean()
    dT_rms_box = np.sqrt((dT_box - dT_mean)**2)
    dT_rms = dT_rms_box.mean()
    dT_rms_other = c2t.rootmeansquare(dT_box)
    dT_pv_mean = dT_pv_box.mean()
    dT_pv_rms_box = np.sqrt((dT_pv_box - dT_pv_mean)**2)
    dT_pv_rms = dT_pv_rms_box.mean()

    print 'z, nu, dT_mean, dT_rms %.3f %.3f %.4f %.4f %.4f' % (z_arr[i], nu[i], dT_mean, dT_rms, dT_rms_other)
    out.write('%.3f %.3f %.4f %.4f\n' % (z_arr[i], nu[i], dT_mean, dT_rms))
    out1.write('%.3f %.3f %.4f %.4f\n' % (z_arr[i], nu[i], dT_pv_mean, dT_pv_rms))
xfrac_redshifts = c2t.get_xfrac_redshifts(xfrac_dir, z_low, z_high, bracket=True)

#List all the data files
dens_files = [density_dir + '%.3fn_all.dat' % z for z in density_redshifts]
vel_files = [velocity_dir + '%.3fv_all.dat' % z for z in density_redshifts]
xfrac_files = [xfrac_dir + 'xfrac3d_%.3f.bin' % z for z in xfrac_redshifts]

#Make the ionization fraction lightcone
xfrac_lightcone, z = c2t.make_lightcone(xfrac_files, z_low, z_high)

#Make the density lightcone
dens_lightcone, z = c2t.make_lightcone(dens_files, z_low, z_high)

#Combine ionization fraction and density to make a dT lightcone
dT_lightcone = c2t.calc_dt_lightcone(xfrac_lightcone, dens_lightcone, \
                                     lowest_z=z.min())

#Make a velocity lightcone
vel_lightcone, z = c2t.make_velocity_lightcone(vel_files, dens_files, \
                                               z_low, z_high)

#Apply redshift space distortions. This is done in the same way as for
#coeval data volumes. Just be sure to set periodic to False and 
#to specify the the velocity_axis argument (see the documentation
#of get_distorted_dt for more information) 
rsd_dT = c2t.get_distorted_dt(dT_lightcone, vel_lightcone, z, \
                              num_particles=30, los_axis=2, velocity_axis=0, \
                              periodic=False)

#Save the results
c2t.save_cbin(output_dir + 'lightcone_rsd.cbin', rsd_dT)
Пример #5
0
#Read density
dfile = c2t.DensityFile(density_filename)

#Read velocity data file and get the actual velocity 
vfile = c2t.VelocityFile(velocity_filename)
kms = vfile.get_kms_from_density(dfile)

#To speed things up, we will assume that the IGM is completely neutral, so instead
#of reading an ionization fraction file, we will just make an array of zeros
xi = np.zeros_like(dfile.cgs_density)

#Calculate the dT
dT_realspace = c2t.calc_dt(xi, dfile, z=dfile.z)

#Make the redshift-space volume
dT_redshiftspace = c2t.get_distorted_dt(dT_realspace, kms, \
                                 dfile.z, los_axis=0, num_particles=20)

#Calculate spherically-averaged power spectra, 
#using 20 logarithmically spaced k bins, from 1e-1 to 10
kbins = 10**np.linspace(-1, 1, 20)
ps_dist, k = c2t.power_spectrum_1d(dT_redshiftspace, kbins)
ps_nodist, k = c2t.power_spectrum_1d(dT_realspace, kbins)

#Plot ratio. On large scales, this should be close to 1.83
pl.semilogx(k, ps_dist/ps_nodist)
pl.xlabel('$k \; \mathrm{[Mpc^{-1}]}$')
pl.ylabel('$P_k^{\mathrm{PV}}/P_k^{\mathrm{NoPV}}$')
pl.show()
Пример #6
0
#Enable output
c2t.set_verbose(True)

#We are using the 114/h Mpc simulation box, so set all the proper conversion factors
c2t.set_sim_constants(boxsize_cMpc=114.)

#Read density
dfile = c2t.DensityFile(density_filename)

#Read a velocity data file
vfile = c2t.VelocityFile(velocity_filename)
kms = vfile.get_kms_from_density(dfile)

#Make a distorted box. Assume x_i = 0. We could of course also have calculated dT like in example.py
#and passed that to get_distorted_dt
distorted = c2t.get_distorted_dt(dfile.raw_density.astype('float64'),
                                 kms,
                                 dfile.z,
                                 los_axis=0,
                                 num_particles=20)

#Calculate power spectra
ps_dist, k = c2t.power_spectrum_1d(distorted)
ps_nodist, k = c2t.power_spectrum_1d(dfile.raw_density)

#Plot ratio
pl.semilogx(k, ps_dist / ps_nodist)
pl.xlabel('$k \; \mathrm{[Mpc^{-1}]}$')
pl.ylabel('$P_k^{\mathrm{PV}}/P_k^{\mathrm{NoPV}}$')
pl.show()
Пример #7
0
#Read density
dfile = c2t.DensityFile(density_filename)

#Read velocity data file and get the actual velocity
vfile = c2t.VelocityFile(velocity_filename)
kms = vfile.get_kms_from_density(dfile)

#To speed things up, we will assume that the IGM is completely neutral, so instead
#of reading an ionization fraction file, we will just make an array of zeros
xi = np.zeros_like(dfile.cgs_density)

#Calculate the dT
dT_realspace = c2t.calc_dt(xi, dfile, z=dfile.z)

#Make the redshift-space volume
dT_redshiftspace = c2t.get_distorted_dt(dT_realspace, kms, \
                                 dfile.z, los_axis=0, num_particles=20)

#Calculate spherically-averaged power spectra,
#using 20 logarithmically spaced k bins, from 1e-1 to 10
kbins = 10**np.linspace(-1, 1, 20)
ps_dist, k = c2t.power_spectrum_1d(dT_redshiftspace, kbins)
ps_nodist, k = c2t.power_spectrum_1d(dT_realspace, kbins)

#Plot ratio. On large scales, this should be close to 1.83
pl.semilogx(k, ps_dist / ps_nodist)
pl.xlabel('$k \; \mathrm{[Mpc^{-1}]}$')
pl.ylabel('$P_k^{\mathrm{PV}}/P_k^{\mathrm{NoPV}}$')
pl.show()