def make_corr_plots(filename): corrobj = corr21cm.Corr21cm() T_b_sim = corrobj.T_b(1420. / 800. - 1) print T_b_sim master = shelve.open(filename, "r") nlag = 15 nmode = 11 nsim = 9 # load the autocorr simulations -------------------------------------------- #splt.process_batch_correlations(autocorr_sim_param, cross_power=False, # multiplier=1.) autocorr_sim_data = splt.batch_correlations_statistics( autocorr_sim_param, randtoken="rand", include_signal=False) lagl = autocorr_sim_data[0] lagc = autocorr_sim_data[1] lagr = autocorr_sim_data[2] autocorr_sim = autocorr_sim_data[3] autocorr_sim_err = autocorr_sim_data[4] autocorr_sim_cov = autocorr_sim_data[5] # now convert from the 1e-3 Omega_HI in simulations to 0.5e-3 #autocorr_sim /= 2. #autocorr_sim_err /= 2. # calibrate to xcorr: 0.56126646473 0.229801269703 autocorr_sim_low = autocorr_sim * (0.56 - 0.23) autocorr_sim_high = autocorr_sim * (0.56 + 0.23) autocorr_sim_center = autocorr_sim * 0.56 for correntry in zip(lagl, lagc, lagr, autocorr_sim_low, autocorr_sim_center, autocorr_sim_high): print "%5.3g %5.3g %5.3g %5.3g %5.3g %5.3g" % correntry # treat the autocorr and loss simulations---------------------------------- lags = np.zeros((3, nlag)) autocorr = np.zeros((nmode, nlag)) autocorr_err = np.zeros((nmode, nlag)) autocorr_sim = np.zeros((nsim, nmode, nlag)) autocorr_sim_avg = np.zeros((nmode, nlag)) compensated_autocorr = np.zeros((nmode, nlag)) compensated_autocorr_err = np.zeros((nmode, nlag)) mode_compensation = np.zeros((nmode, nlag)) for mode_index in range(0, nmode): mode_num = mode_index * 5 autocorr_name = "autocorr" + repr(mode_num) + "_mode" entry = master[autocorr_name] autocorr[mode_index, :] = entry["corr1D"] autocorr_err[mode_index, :] = entry["corr1D_std"] lags[0, :] = entry["x_axis"][0] lags[1, :] = entry["x_axis"][1] lags[2, :] = entry["x_axis"][2] for sim_index in range(0, nsim): sim_name = "sim" + repr(sim_index + 1) + "_mode" + repr(mode_num) entry = master[sim_name] autocorr_sim[sim_index, mode_index, :] = entry["corr1D"] autocorr_sim_avg = np.mean(autocorr_sim, axis=0) / 1000. zero_modes = autocorr_sim_avg[0, :] mode_compensation = autocorr_sim_avg / zero_modes[None, :] compensated_autocorr = autocorr / mode_compensation compensated_autocorr_err = autocorr_err / mode_compensation print "-" * 80 for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:, lagind], "%5.2g") modes = splt.fancy_vector(autocorr[:, lagind], "%5.2g") modes_err = splt.fancy_vector(autocorr_err[:, lagind], "%5.2g") print lag_bounds + modes + modes_err print "-" * 80 for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:, lagind], "%5.2g") modes = splt.fancy_vector(mode_compensation[:, lagind], "%5.2g") print lag_bounds + modes print "-" * 80 for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:, lagind], "%5.2g") modes = splt.fancy_vector(autocorr_sim_avg[:, lagind], "%5.2g") print lag_bounds + modes print "-" * 80 for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:, lagind], "%5.2g") modes = splt.fancy_vector(compensated_autocorr[:, lagind], "%5.2g") modes_err = splt.fancy_vector(compensated_autocorr_err[:, lagind], "%5.2g") print lag_bounds + modes + modes_err master.close()
def make_corr_plots(filename): corrobj = corr21cm.Corr21cm() T_b_sim = corrobj.T_b(1420./800.-1) print T_b_sim master = shelve.open(filename, "r") nlag = 15 nmode = 11 nsim = 9 # load the autocorr simulations -------------------------------------------- #splt.process_batch_correlations(autocorr_sim_param, cross_power=False, # multiplier=1.) autocorr_sim_data = splt.batch_correlations_statistics(autocorr_sim_param, randtoken="rand", include_signal=False) lagl = autocorr_sim_data[0] lagc = autocorr_sim_data[1] lagr = autocorr_sim_data[2] autocorr_sim = autocorr_sim_data[3] autocorr_sim_err = autocorr_sim_data[4] autocorr_sim_cov = autocorr_sim_data[5] # now convert from the 1e-3 Omega_HI in simulations to 0.5e-3 #autocorr_sim /= 2. #autocorr_sim_err /= 2. # calibrate to xcorr: 0.56126646473 0.229801269703 autocorr_sim_low = autocorr_sim*(0.56-0.23) autocorr_sim_high = autocorr_sim*(0.56+0.23) autocorr_sim_center = autocorr_sim*0.56 for correntry in zip(lagl, lagc, lagr, autocorr_sim_low, autocorr_sim_center, autocorr_sim_high): print "%5.3g %5.3g %5.3g %5.3g %5.3g %5.3g" % correntry sys.exit() # treat the autocorr and loss simulations---------------------------------- lags = np.zeros((3, nlag)) autocorr = np.zeros((nmode, nlag)) autocorr_err = np.zeros((nmode, nlag)) autocorr_sim = np.zeros((nsim, nmode, nlag)) autocorr_sim_avg = np.zeros((nmode, nlag)) compensated_autocorr = np.zeros((nmode, nlag)) compensated_autocorr_err = np.zeros((nmode, nlag)) mode_compensation = np.zeros((nmode, nlag)) for mode_index in range(0, nmode): mode_num = mode_index*5 autocorr_name = "autocorr" + repr(mode_num) + "_mode" entry = master[autocorr_name] autocorr[mode_index, :] = entry["corr1D"] autocorr_err[mode_index, :] = entry["corr1D_std"] lags[0, :] = entry["x_axis"][0] lags[1, :] = entry["x_axis"][1] lags[2, :] = entry["x_axis"][2] for sim_index in range(0, nsim): sim_name = "sim" + repr(sim_index+1) + "_mode" + repr(mode_num) entry = master[sim_name] autocorr_sim[sim_index, mode_index, :] = entry["corr1D"] autocorr_sim_avg = np.mean(autocorr_sim, axis=0)/1000. zero_modes = autocorr_sim_avg[0,:] mode_compensation = autocorr_sim_avg/zero_modes[None, :] compensated_autocorr = autocorr/mode_compensation compensated_autocorr_err = autocorr_err/mode_compensation print mode_compensation for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:,lagind], "%5.2g") modes = splt.fancy_vector(autocorr[:,lagind], "%5.2g") modes_err = splt.fancy_vector(autocorr_err[:,lagind], "%5.2g") print lag_bounds + modes + modes_err for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:,lagind], "%5.2g") modes = splt.fancy_vector(autocorr_sim_avg[:,lagind], "%5.2g") print lag_bounds + modes for lagind in range(0, nlag): lag_bounds = splt.fancy_vector(lags[:,lagind], "%5.2g") modes = splt.fancy_vector(compensated_autocorr[:,lagind], "%5.2g") modes_err = splt.fancy_vector(compensated_autocorr_err[:,lagind], "%5.2g") print lag_bounds + modes + modes_err master.close()
def make_xcorr_plotdata(): # find the mean brightness used in simulations corrobj = corr21cm.Corr21cm() T_b_sim = corrobj.T_b(1420. / 800. - 1) print T_b_sim #splt.process_batch_correlations(xcorr_real_param, # multiplier=1., cross_power=True) ##splt.process_batch_correlations(xcorr_sim_param, cross_power=True, ## multiplier=1./(T_b_sim/1.e3)) #splt.process_batch_correlations(xcorr_sim_param, cross_power=True, # multiplier=1./(T_b_sim)) #splt.process_batch_correlations(xcorr_loss_sim_param, # multiplier=1./T_b_sim*1.e-3, cross_power=True) #splt.process_batch_correlations(xcorr_variants_param, # multiplier=1., cross_power=True) #splt.plot_batch_correlations(xcorr_real_param, # dir_prefix="plots/xcorr_real/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_sim_param, # dir_prefix="plots/xcorr_sim/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_loss_param, # dir_prefix="plots/xcorr_loss/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_loss_sim_param, # dir_prefix="plots/xcorr_loss_sim/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_variants_param, # dir_prefix="plots/xcorr_variants/", # color_range=[-0.04, 0.04], cross_power=True) # find the real xcorr signal with errors xcorr_data = splt.batch_correlations_statistics(xcorr_real_param, randtoken="rand", include_signal=True) # find the simulated xcorr signal with errors xcorr_sim_data = splt.batch_correlations_statistics(xcorr_sim_param, randtoken="rand", include_signal=False) # find the compensation function from simulations compmode = splt.batch_compensation_function(xcorr_loss_sim_param) lagl = xcorr_data[0] lagc = xcorr_data[1] lagr = xcorr_data[2] xcorr_null = xcorr_data[3] xcorr_signal = xcorr_data[6] xcorr_cov = xcorr_data[5] xcorr_err = xcorr_data[4] xcorr_sim = xcorr_sim_data[3] xcorr_sim_err = xcorr_sim_data[4] xcorr_sim_cov = xcorr_sim_data[5] # 0=0, 5=1, 10=2, 15=3, etc. compensation = compmode[3, :] (amp, amp_err) = utils.ampfit(xcorr_signal, xcorr_cov + xcorr_sim_cov, xcorr_sim) print amp, amp_err # now convert from the 1e-3 Omega_HI in simulations to 0.5e-3 #xcorr_sim /= 2. #xcorr_sim_err /= 2. xcorr_sim *= amp xcorr_sim_err *= amp for correntry in zip(lagl, lagc, lagr, xcorr_signal, xcorr_null, xcorr_err, xcorr_sim, xcorr_sim_err, compensation): print "%5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g" % correntry
def make_xcorr_plotdata(): # find the mean brightness used in simulations corrobj = corr21cm.Corr21cm() T_b_sim = corrobj.T_b(1420./800.-1) print T_b_sim #splt.process_batch_correlations(xcorr_real_param, # multiplier=1., cross_power=True) ##splt.process_batch_correlations(xcorr_sim_param, cross_power=True, ## multiplier=1./(T_b_sim/1.e3)) #splt.process_batch_correlations(xcorr_sim_param, cross_power=True, # multiplier=1./(T_b_sim)) #splt.process_batch_correlations(xcorr_loss_sim_param, # multiplier=1./T_b_sim*1.e-3, cross_power=True) #splt.process_batch_correlations(xcorr_variants_param, # multiplier=1., cross_power=True) #splt.plot_batch_correlations(xcorr_real_param, # dir_prefix="plots/xcorr_real/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_sim_param, # dir_prefix="plots/xcorr_sim/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_loss_param, # dir_prefix="plots/xcorr_loss/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_loss_sim_param, # dir_prefix="plots/xcorr_loss_sim/", # color_range=[-0.04, 0.04], cross_power=True) #splt.plot_batch_correlations(xcorr_variants_param, # dir_prefix="plots/xcorr_variants/", # color_range=[-0.04, 0.04], cross_power=True) # find the real xcorr signal with errors xcorr_data = splt.batch_correlations_statistics(xcorr_real_param, randtoken="rand", include_signal=True) # find the simulated xcorr signal with errors xcorr_sim_data = splt.batch_correlations_statistics(xcorr_sim_param, randtoken="rand", include_signal=False) # find the compensation function from simulations compmode = splt.batch_compensation_function(xcorr_loss_sim_param) lagl = xcorr_data[0] lagc = xcorr_data[1] lagr = xcorr_data[2] xcorr_null = xcorr_data[3] xcorr_signal = xcorr_data[6] xcorr_cov = xcorr_data[5] xcorr_err = xcorr_data[4] xcorr_sim = xcorr_sim_data[3] xcorr_sim_err = xcorr_sim_data[4] xcorr_sim_cov = xcorr_sim_data[5] # 0=0, 5=1, 10=2, 15=3, etc. compensation = compmode[3 ,:] (amp, amp_err) = utils.ampfit(xcorr_signal, xcorr_cov + xcorr_sim_cov, xcorr_sim) print amp, amp_err # now convert from the 1e-3 Omega_HI in simulations to 0.5e-3 #xcorr_sim /= 2. #xcorr_sim_err /= 2. xcorr_sim *= amp xcorr_sim_err *= amp for correntry in zip(lagl, lagc, lagr, xcorr_signal, xcorr_null, xcorr_err, xcorr_sim, xcorr_sim_err, compensation): print "%5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g %5.3g" % correntry