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')
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)
out2_pv_box = './lc_boxes/dT_pv_lc2_244Mpc_8.2S_250.cbin' file_z = './lc_boxes/out0_z.dat' file1_z = './lc_boxes/out1_z.dat' file2_z = './lc_boxes/out2_z.dat' c2t.set_verbose(True) c2t.set_sim_constants(boxsize_cMpc = 244.) z_low = 6.0 z_high = 22. # Read in dT boxes, get filenames, and make lightcones dT_files = glob.glob(dT_path+'dT_*.cbin') dens_files = glob.glob(density_path+'*n_all.dat') vel_files = glob.glob(density_path+'*v_all.dat') vel_lightcone, z = c2t.make_velocity_lightcone(vel_files, dens_files, z_low, z_high, los_axis=0) dT_lightcone,out_z = c2t.make_lightcone(dT_files, z_low , z_high, cbin_bits=64, cbin_order='F', los_axis=0) rsd_dT = c2t.get_distorted_dt(dT_lightcone, vel_lightcone, z, num_particles=40, los_axis=2, velocity_axis=0, periodic=False) c2t.save_cbin(out_box, dT_lightcone) c2t.save_cbin(out_pv_box, rsd_dT) np.savetxt(file_z,out_z,fmt="%f") vel_lightcone, z = c2t.make_velocity_lightcone(vel_files, dens_files, z_low, z_high, los_axis=1) dT_lightcone,out_z = c2t.make_lightcone(dT_files, z_low , z_high, cbin_bits=64, cbin_order='F', los_axis=1) rsd_dT = c2t.get_distorted_dt(dT_lightcone, vel_lightcone, z, num_particles=40, los_axis=2, velocity_axis=1, periodic=False) c2t.save_cbin(out1_box, dT_lightcone) c2t.save_cbin(out1_pv_box, rsd_dT) np.savetxt(file1_z,out_z,fmt="%f")