def mean_xfrac(): redshifts = rs.read_redshifts("../red_ori2.dat") redshifts2 = rs.read_redshifts("../red_ori.dat") meanxfrac = np.zeros(len(redshifts)) file = open('data/xfrac_stars.dat', 'w') file.write("Stars only: Mean Xfrac") file_pls = open('data/xfrac_pls.dat','w') file_pls.write("Power laws: Mean xfrac") file_quasars = open('data/xfrac_quasars.dat', 'w') file_quasars.write("Quasars: Mean Xfrac") file_quasars_pls = open('data/xfrac_quasars_pls.dat', 'w') file_quasars_pls.write("Power laws and Quasars: Mean Xfrac") for i in range(len(redshifts)): #Some path and file names. Modify these as needed. base_path = '/lustre/scratch/astro/hr203/RESULTS/' #for i in range(noRedshifts): density_filename = '/lustre/scratch/astro/hr203/244Mpc_f2_8.2S_H250_wstars/coarser_densities/' xfrac_filename = base_path + '/244Mpc_f2_8.2S_H250_wstars/xfrac3d_'+str('%.3f' % redshifts[i]) + '.bin' qxfrac_filename = base_path + '/244Mpc_f2_8.2S_H250_wquasars/xfrac3d_'+str('%.3f' % redshifts[i]) + '.bin' if (i%2 ==0): pxfrac_filename = base_path + '/244Mpc_f2_8.2S_H250_wpls/xfrac3d_'+str('%.3f' % redshifts[i/2]) + '.bin' qpxfrac_filename = base_path + '/244Mpc_f2_8.2S_H250_wquasars_wpls/xfrac3d_'+str('%.3f' % redshifts[i]) + '.bin' #Enable the printing of various messages c2t.set_verbose(True) #We are using the 114/h Mpc simulation box, so set all the proper conversion factors. #Be sure to always set this before loading anything. Otherwise, c2raytools will #not know how to convert densities and velocities to physical units! #c2t.set_sim_constants(boxsize_cMpc = 50) #Read an ionized fractions file and store it as an XfracFile object xfile = c2t.XfracFile(xfrac_filename) if (i%2==0): xfile_pls = c2t.XfracFile(pxfrac_filename) xfile_qs = c2t.XfracFile(pxfrac_filename) xfile_qs_pls = c2t.XfracFile(qpxfrac_filename) #The most important property of an XfracFile object is xi, which #is a numpy array containing the ionized fraction #print 'The ionized fraction in point (10,223,45) is: ', xfile.xi[10,223,45] #print 'The volume-averaged mean ionized fraction is: ', xfile.xi.mean() file.write(xfile.xi.mean()) if (i%2): file_pls.write(xfile_pls.xi.mean()) file.write(xfilei_qs.xi.mean()) file.write(xfile_qs_pls.xi.mean()) return "Complete"
kwargs["histtype"] = "step" if not "color" in kwargs.keys(): kwargs["color"] = "k" pl.hist(plot_data.flatten(), log=logscale, **kwargs) # Labels if datatype == "xfrac": pl.xlabel("$x_i$") elif datatype == "density": pl.xlabel("$\\rho \; \mathrm{[g \; cm^{-3}]}$") if __name__ == "__main__": import c2raytools as c2t import pylab as pl c2t.set_verbose(True) pl.figure() dfilename = "/disk/sn-12/garrelt/Science/Simulations/Reionization/C2Ray_WMAP5/114Mpc_WMAP5/coarser_densities/nc256_halos_removed/6.905n_all.dat" xfilename = "/disk/sn-12/garrelt/Science/Simulations/Reionization/C2Ray_WMAP5/114Mpc_WMAP5/114Mpc_f2_10S_256/results_ranger/xfrac3d_8.958.bin" dfile = c2t.DensityFile(dfilename) # plot_slice(dfile, los_axis=1, logscale=True, cmap=pl.cm.hot) # ax2 = pl.subplot(1,2,2) # plot_slice(xfilename) plot_slice(c2t.XfracFile(xfilename)) pl.show()
''' This file demonstrates how to make a redshift-space lightcone volume from many coeval volumes. To do this, we first make separate light cones for ionized fraction, density, brightness tempearture and velocity. Note that this script is fairly memory-hungry, so run it on a machine with plenty of RAM. ''' import c2raytools as c2t import numpy as np import glob c2t.set_verbose(True) c2t.set_sim_constants(425) #Paths to data files. Modify these as needed xfrac_dir = '/disk/dawn-1/garrelt/Reionization/C2Ray_WMAP5/425Mpc_WMAP5/f2_10S_504/results/' density_dir = '/disk/dawn-1/garrelt/Reionization/C2Ray_WMAP5/425Mpc_WMAP5/coarser_densities/' velocity_dir = density_dir #The place to save the results. Modify to something you have write access to output_dir = '/home/hjens/links/local/slask/' #Redshift limits for the light cone z_low = 7.5 z_high = 12. #List all the redhifts for which we have data files density_redshifts = c2t.get_dens_redshifts(density_dir, z_low, z_high, bracket=True) xfrac_redshifts = c2t.get_xfrac_redshifts(xfrac_dir, z_low, z_high, bracket=True)