import matplotlib.gridspec as gridspec from matplotlib.ticker import MaxNLocator mpl.rcParams['axes.linewidth'] = 1.5 mpl.rcParams['xtick.labelsize'] = 14 mpl.rcParams['ytick.labelsize'] = 14 mpl.rcParams['axes.labelsize'] = 17 #Some path names. Modify these as needed one_filename = '../1244Mpc_f2_0_250_pyt/results/flux_244Mpc_f2_0_250.dat' two_filename = '../1244Mpc_f2_8.2S_250_pyt/results/flux_244Mpc_f2_8.2S_250.dat' three_filename = '../1244Mpc_f2_8.2pS_250_pyt/results/flux_244Mpc_f2_8.2pS_250.dat' four_filename = '../1244Mpc_f2_gS_250_pyt/results/flux_244Mpc_f2_gS_250.dat' #We are using the 24/h Mpc simulation box, so set all the proper conversion factors c2t.set_sim_constants(boxsize_cMpc = 244.) #Read in flux files with zred_now,NumSrc00,NumSrc01,TotSrcFlux0,TotSrcFlux,LargeSrcFlux0,SmallSrcFlux0 # z0, NumSrc1, NumSrc_used2, UnsuppFlux3, UsedFlux4 f1 = np.loadtxt(one_filename) f2 = np.loadtxt(two_filename) f3 = np.loadtxt(three_filename) f4 = np.loadtxt(four_filename) #Record point of z_ov and create vertical line zov = [6.231, 6.354, 7.570, 6.757] print zov[3], f4[:,0] print np.where(f2[:,0] == zov[1])[0] y_pos0 = np.where(f1[:,0] == zov[0])[0] y_pos1 = np.where(f2[:,0] == zov[1])[0] y_pos2 = np.where(f3[:,0] == zov[2])[0]
import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator import numpy as np #import compare import sys import plot_1D sys.path.append('../') import setup_dirs sys.path.append('../../src') import c2raytools as c2t c2t.set_sim_constants(244) plt.rc('xtick', labelsize=24) plt.rc('ytick', labelsize=24) plt.rc('font',family='serif') fontsize=24#3dd0 numberfontsize=24 tickwidth=1.5 size=24#26 lw = 2.5 flag1="wstars"#"wpls" flag2="wpls"#"wquasars"#"wpls"#quasars" redshifts1=setup_dirs.read_redshifts(flag1) redshifts2=setup_dirs.read_redshifts(flag2) if flag1=='wstars'or flag2=='wstars': label1="Stellar" if flag1=='wpls'or flag2=='wpls': if flag1 =='wstars' or flag2=='wstars': label2="X-Ray & Stellar"
import numpy as np import c2raytools as c2t import argparse import sys import os import glob def parse_options(): parser = argparse.ArgumentParser(prog='make_dt_lightcone', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--xfrac', '-x', type=str, default = None, help='The lightcone file containing the ionized fractions.') parser.add_argument('--density', '-d', type=str, default = None, help='The lightcone file containing the density.') parser.add_argument('--output', '-o', type=str, help='The name of the output file.',\ default='dt_lightcone.cbin') parser.add_argument('--min_z', type=float, default = None, help='The lowest_redshift.') parser.add_argument('--boxsize', '-b', type=float, default=425, help='The side of the box in Mpc/h.') args = parser.parse_args() return args if __name__ == '__main__': if len(sys.argv) <= 1: print 'No arguments given. Use -h to print help.' sys.exit(2) args = parse_options() c2t.set_verbose(True) c2t.set_sim_constants(args.boxsize) xfrac, xfile_type = c2t.get_data_and_type(args.xfrac, cbin_bits = 32, cbin_order = 'c') density, dfile_type = c2t.get_data_and_type(args.density, cbin_bits = 32, cbin_order = 'c') dt_lightcone = c2t.calc_dt_lightcone(xfrac, density, args.min_z) c2t.save_cbin(args.output, dt_lightcone)
import numpy as np import c2raytools as c2t import squeezed_bispectrum import matplotlib.pyplot as plt import owntools import os from matplotlib import rcParams rcParams['font.family'] = 'sans-serif' rcParams['font.family'] = 'small-caps' plt.rcParams['text.usetex'] = True rcParams['axes.labelsize'] = 14 rcParams['font.size'] = 14 rcParams['axes.linewidth'] = 1.2 c2t.set_sim_constants(500) parent_dir = '/disk/dawn-1/garrelt/Reionization/C2Ray_WMAP7/500Mpc/' xfrac_dir = '/disk/dawn-1/garrelt/Reionization/C2Ray_WMAP7/500Mpc/500Mpc_f2_0_300/results/' dens_dir = '/disk/dawn-1/garrelt/Reionization/C2Ray_WMAP7/500Mpc/coarser_densities/nc300/' ph_count_info = owntools.photoncount_info(xfrac_dir) zs_sim = ph_count_info[:, 0] xv_sim = ph_count_info[:, -2] xm_sim = ph_count_info[:, -1] def from_excursion_set(zz, xv): command = './Anson/Sambit/src/ESMR.x ' + str(zz) + ' ' + str( xv) + ' info.txt' os.system(command)
''' 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)
import c2raytools as c2t import numpy as np import pylab as pl #Some path names. Modify these as needed base_path = '/disk/sn-12/garrelt/Science/Simulations/Reionization/C2Ray_WMAP5/114Mpc_WMAP5' density_filename = base_path + '/coarser_densities/nc256_halos_removed/8.515n_all.dat' xfrac_filename = base_path + '/114Mpc_f2_10S_256/results_ranger/xfrac3d_8.515.bin' velocity_filename = base_path + '/coarser_densities/nc256_halos_included/8.515v_all.dat' #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 c2t.set_sim_constants(boxsize_cMpc=114.) #Read a density file and print some statistics dfile = c2t.DensityFile(density_filename) print 'The redshift is ', dfile.z print 'The size of the mesh is (', dfile.mesh_x, dfile.mesh_y, dfile.mesh_z, ')' print 'The mean baryon density is ', dfile.cgs_density.mean(), ' g/cm^3' #Read an ionized fractions file xfile = c2t.XfracFile(xfrac_filename) print 'The volume-averaged mean ionized fraction is: ', xfile.xi.mean() print 'The mass-averaged mean ionized fraction is:', c2t.mass_weighted_mean_xi( xfile.xi, dfile.raw_density)
import numpy as np import c2raytools as c2t import squeezed_bispectrum import matplotlib.pyplot as plt import matplotlib import owntools c2t.set_sim_constants(244) def color_plot_lines(X, Y, parameters, cmap='jet', label='$\delta$', norm=None): cmaps = ['jet', 'cool', 'brg', 'hsv'] cm_func = [ matplotlib.cm.jet, matplotlib.cm.cool, matplotlib.cm.brg, matplotlib.cm.hsv ] if not norm: norm = matplotlib.colors.Normalize(vmin=np.min(parameters), vmax=np.max(parameters)) # choose a colormap c_m = cm_func[cmaps.index(cmap)] # create a ScalarMappable and initialize a data structure s_m = matplotlib.cm.ScalarMappable(cmap=c_m, norm=norm) s_m.set_array([]) for i in xrange(len(parameters)): a, b = X[:, i], Y[:, i]