# Fixed bias evol. zfns = [6, 7, 8] excl = [2, 4, 5, 9, 10, 11, 12, 13, 14, 15] #6,7,8 ] excl += [i for i in range(len(pnames)) if "pk" in pnames[i]] F2, lbls2 = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=excl) # Invert matrices cov = np.linalg.inv(F) cov2 = np.linalg.inv(F2) # Indices of fns. of z zfns = [1, 3, 4, 5] # Update after other params subtracted pf = rf.indexes_for_sampled_fns(3, zc.size, zfns) pDA = rf.indexes_for_sampled_fns(4, zc.size, zfns) pH = rf.indexes_for_sampled_fns(5, zc.size, zfns) # Indices of fns. of z (bias fixed in z) zfns = [3, 4, 5] # Update after other params subtracted pf2 = rf.indexes_for_sampled_fns(3, zc.size, zfns) pDA2 = rf.indexes_for_sampled_fns(4, zc.size, zfns) pH2 = rf.indexes_for_sampled_fns(5, zc.size, zfns) # SKA marginal errorbars err_f = np.sqrt(np.diag(cov)[pf]) err_f2 = np.sqrt(np.diag(cov2)[pf2]) err_H = np.sqrt(cov[pH, pH]) * 100. err_H2 = np.sqrt(cov2[pH2, pH2]) * 100. err_DA = np.sqrt(cov[pDA, pDA]) * 1e3
# Trim params we don't care about here # A(z), bHI(z), f(z), sig2, dA(z), H(z), [fNL], [omega_k_ng], [omega_DE_ng], pk _F = rf.fisher_with_excluded_params(F_list[i], [6, 7, 8, 9]) # Expand fns. of z one-by-one for the current z bin. (Indices of fns. of z # are given in reverse order, to make figuring out where they are in the # updated matrix from the prev. step easier.) # b_HI(z), f(z), dA(z), H(z) zfns_b = [5, 4, 2, 1] FF = _F for idx in zfns_b: FF = rf.expand_matrix_for_sampled_fn(FF, idx, Nbins, i) F_b += FF # Overlay error ellipses as a fn. of z p1 = rf.indexes_for_sampled_fns(1, zc.size, zfns_b) # y p2 = rf.indexes_for_sampled_fns(2, zc.size, zfns_b) # x x = 1. y = 1. alpha = [1.52, 2.48, 3.44] cmap = matplotlib.cm.get_cmap("spectral") ZMAX = 1.39 print "Max:", np.max(zc) ax = P.subplot(111) Nused = np.where(zc <= ZMAX)[0].size # No. of z bins that are actually used zvals = [] for i in range(len(p1)): #if i % 2 == 0: continue if zc[i] > ZMAX: continue
] #, 'fNL'] pnames += ["pk%d" % i for i in range(kc.size)] zfns = [0, 1, 6, 7, 8] excl = [2, 4, 5, 9, 10, 11, 12, 13, 14, 15] #,16] # Exclude all cosmo params excl += [i for i in range(len(pnames)) if "pk" in pnames[i]] F, lbls = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=excl) cov = np.linalg.inv(F) # Get functions of z zfns = [0, 1, 3, 4, 5] pA = rf.indexes_for_sampled_fns(0, zc.size, zfns) print "A:", [lbls[j] for j in pA], "\n" # Plot errorbars errs = np.sqrt(np.diag(cov)) err = errs[pA] P.plot(zc, err, color=colours[k], lw=1.8, marker='.', label=labels[k], ls=linestyle[k]) P.xlim((0.31, 2.52))
excl = [2, 4, 5, 6, 7, 8, 12, 14, 15] # wa fixed excl += [i for i in range(len(pnames)) if "pk" in pnames[i]] F, lbls = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=excl) # Add Planck prior Fpl = euclid.add_planck_prior(F, lbls, info=False) print "-" * 50 print names[k] print "-" * 50 # Invert matrices pw0 = rf.indexes_for_sampled_fns(5, zc.size, zfns) #4, for omegak=fixed pok = rf.indexes_for_sampled_fns(3, zc.size, zfns) #5 cov_pl = np.linalg.inv(Fpl) print lbls[pw0], lbls[pok] fom = rf.figure_of_merit(pw0, pok, None, cov=cov_pl) print "%s: FOM = %3.2f" % (names[k], fom) y = rf.experiments.cosmo['w0'] x = 0. # Plot contours for w0, omega_k; wa fixed w, h, ang, alpha = rf.ellipse_for_fisher_params(pok, pw0, None,
names=pnames, exclude=excl) # Just do the simplest thing for P(k) and get 1/sqrt(F) cov = [ np.sqrt(1. / np.diag(F)[lbls.index(lbl)]) for lbl in lbls if "pk" in lbl ] cov = np.array(cov) pk = cosmo['pk_nobao'](kc) * (1. + fbao(kc)) # Replace nan/inf values cov[np.where(np.isnan(cov))] = 1e10 cov[np.where(np.isinf(cov))] = 1e10 pw0 = rf.indexes_for_sampled_fns(11, zc.size, zfns) pwa = rf.indexes_for_sampled_fns(12, zc.size, zfns) print "-" * 50 print names[k] #print cov print lbls[pw0], 1. / np.sqrt(F[pw0, pw0]) print lbls[pwa], 1. / np.sqrt(F[pwa, pwa]) """ if k == 0: # Plot shaded region P.fill_between(kc, np.ones(kc.size)*1e-10, cov, facecolor='#e1e1e1', edgecolor='none') else: # Plot errorbars P.plot(kc, cov, color=colours[k], label=labels[k], lw=2.2, ls=linestyle[k]) """
expand=zfns, names=pnames, exclude=excl) # Add Planck prior Fpl = F.copy() for i in range(0, 4): for j in range(0, 4): Fpl[3 + i, 3 + j] += euclid.planck_prior[i, j] print lbls[3 + i], lbls[3 + j] # Invert matrices cov = np.linalg.inv(F) cov_pl = np.linalg.inv(Fpl) # Indices of fns. of z pok = rf.indexes_for_sampled_fns(3, zc.size, zfns) pw0 = rf.indexes_for_sampled_fns(5, zc.size, zfns) # Fiducial point x = rf.experiments.cosmo['omega_k_0'] y = rf.experiments.cosmo['w0'] if k == 0: ax.plot(x, y, 'kx', ms=10) # w0, omega_K w, h, ang, alpha = rf.ellipse_for_fisher_params(pok, pw0, cov, Finv=cov) ellipses = [ matplotlib.patches.Ellipse(xy=(x, y), width=alpha[kk] * w, height=alpha[kk] * h, angle=ang, fc='none',
Nbins = zc.size # EOS FISHER MATRIX pnames = [ 'A', 'b_HI', 'Tb', 'sigma_NL', 'sigma8', 'n_s', 'f', 'aperp', 'apar', 'omegak', 'omegaDE', 'w0', 'wa', 'h', 'gamma' ] zfns = [ 1, ] F_eos, lbls = rf.combined_fisher_matrix(F_eos_list, exclude=[2, 4, 5, 6, 7, 8, 9, 12], expand=zfns, names=pnames) # Overlay error ellipses as a fn. of z p1 = rf.indexes_for_sampled_fns(4, zc.size, zfns) # w0 # y #p2 = rf.indexes_for_sampled_fns(5, zc.size, zfns) # # x p3 = rf.indexes_for_sampled_fns(5, zc.size, zfns) # h p4 = rf.indexes_for_sampled_fns(6, zc.size, zfns) # gamma Finv = np.linalg.inv(F_eos) # Pre-invert, for efficiency i = 0 ################################## # w0 - h ################################## x = rf.experiments.cosmo['w0'] y = rf.experiments.cosmo['h'] w, h, ang, alpha = rf.ellipse_for_fisher_params(p1[i], p3[i], F_eos,
1, ] # Marginalise over omega_k F_eos, lbls = rf.combined_fisher_matrix( F_eos_list, #exclude=[2,4,5,6,7,8,9,12], exclude=[2, 4, 5, 6, 7, 8, 9, 14], expand=zfns, names=pnames) Finv = np.linalg.inv(F_eos) # Pre-invert, for efficiency print "Cond. No.:", np.linalg.cond(F_eos) print "sig(h):", np.sqrt(Finv[6, 6]) px = rf.indexes_for_sampled_fns(4, zc.size, zfns) # x 4 py = rf.indexes_for_sampled_fns(5, zc.size, zfns) # y 5 #rf.plot_corrmat(Finv, lbls) """ # Fix omega_k F_eos2, lbls2 = rf.combined_fisher_matrix( F_eos_list, exclude=[2,4,5,6,7,8, 9,12], expand=zfns, names=pnames) Finv2 = np.linalg.inv(F_eos2) # Pre-invert, for efficiency px2 = rf.indexes_for_sampled_fns(6, zc.size, zfns) # x py2 = rf.indexes_for_sampled_fns(4, zc.size, zfns) # y """ # Fiducial point x = rf.experiments.cosmo['w0']
'omegak', 'omegaDE', 'w0', 'wa', 'h', 'gamma' ] #0:A, 1:b_HI, 2:sigma_NL, [3:omegak,] 4:omegaDE, 5:w0, 6:wa, 7:h, 8:gamma zfns = [ 1, ] # Fix w0,wa F_eos, lbls = rf.combined_fisher_matrix( F_eos_list, #exclude=[2,4,5,6,7,8,9,12], exclude=[2, 4, 5, 6, 7, 8, 11, 12], expand=zfns, names=pnames) Finv = np.linalg.inv(F_eos) # Pre-invert, for efficiency px = rf.indexes_for_sampled_fns(3, zc.size, zfns) # x py = rf.indexes_for_sampled_fns(4, zc.size, zfns) # y #rf.plot_corrmat(F_eos, lbls) # Fix wa F_eos2, lbls2 = rf.combined_fisher_matrix(F_eos_list, exclude=[2, 4, 5, 6, 7, 8, 12], expand=zfns, names=pnames) Finv2 = np.linalg.inv(F_eos2) # Pre-invert, for efficiency px2 = rf.indexes_for_sampled_fns(3, zc.size, zfns) # x py2 = rf.indexes_for_sampled_fns(4, zc.size, zfns) # y print "sigma(h) =", np.sqrt( Finv2[rf.indexes_for_sampled_fns(6, zc.size, zfns),
] F, lbls = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=[2, 4, 5, 6, 7, 8]) # Remove elements with zero diagonal (completely unconstrained) zero_idxs = np.where(np.diag(F) == 0.)[0] print "Zero idxs:", zero_idxs F = rf.fisher_with_excluded_params(F, excl=zero_idxs) lbls = lbls[:-zero_idxs.size] #rf.plot_corrmat(F, lbls) # Overlay error ellipses as a fn. of z p1 = rf.indexes_for_sampled_fns(4, zc.size, zfns) #p2 = rf.indexes_for_sampled_fns(5, zc.size, zfns) # Full covmat cov = np.linalg.inv(F) diags = np.sqrt(np.diag(cov)) # Reduced covmat #F2 = rf.fisher_with_excluded_params(F, excl=[l for l in range(19, 55)]) #cov2 = np.linalg.inv(F2) #diags2 = np.sqrt(np.diag(cov2)) # Print diags. for i in range(diags.size): #if i < diags2.size: # print "%2d %10s %3.4f %3.4f" % (i, lbls[i], diags[i], diags2[i])
'omegak', 'omegaDE', 'w0', 'wa', 'h', 'gamma', 'Mnu' ] #0:A, 1:b_HI, 2:sigma_NL, 3:omegak, 4:omegaDE, 5:w0, [6:wa,] 7:h, 8:gamma, 9:Mnu zfns = [ 1, ] # Marginalise over omega_k F_eos, lbls = rf.combined_fisher_matrix( F_eos_list, #exclude=[2,4,5,6,7,8,9,12], exclude=[2, 4, 5, 6, 7, 8, 12], expand=zfns, names=pnames) Finv = np.linalg.inv(F_eos) # Pre-invert, for efficiency px = rf.indexes_for_sampled_fns(7, zc.size, zfns) # x py = rf.indexes_for_sampled_fns(5, zc.size, zfns) # y """ print "sigma(Mnu) =", np.sqrt( Finv[rf.indexes_for_sampled_fns(8, zc.size, [1,8]),rf.indexes_for_sampled_fns(8, zc.size, [1,8])] ) sigma_mnu = np.sqrt( Finv[rf.indexes_for_sampled_fns(8, zc.size, [1,8]),rf.indexes_for_sampled_fns(8, zc.size, [1,8])] ) P.subplot(111) P.plot(zc, sigma_mnu, 'r-', lw=1.5) P.plot(zc, sigma_mnu, 'r.', lw=1.5) P.axhline(0.04, color='b', ls='dotted', lw=1.5) P.ylabel(r"$\sigma(\Sigma m_\nu)$") P.xlabel("z") P.title(r"$\Sigma m_\nu|_\mathrm{fid.} = 0.1 \mathrm{eV}$") P.show() exit()
print "-" * 50 print names[k] print "-" * 50 cov = np.linalg.inv(F) cov_pl = np.linalg.inv(Fpl) for j in range(len(lbls)): print "%10s %3.4f %3.4f %3.4f" % (lbls[j], np.sqrt( cov[j, j]), np.sqrt(cov_pl[j, j]), 1. / np.sqrt(np.diag(F))[j]) # Invert matrices cov = np.linalg.inv(F) cov_pl = np.linalg.inv(Fpl) # Indices of fns. of z pw0 = rf.indexes_for_sampled_fns(4, zc.size, zfns) pwa = rf.indexes_for_sampled_fns(5, zc.size, zfns) # Fiducial point x = rf.experiments.cosmo['w0'] y = rf.experiments.cosmo['wa'] if k == 0: ax.plot(x, y, 'kx', ms=10) """ # omega_k, gamma fixed w, h, ang, alpha = rf.ellipse_for_fisher_params(pw0, pwa, cov, Finv=cov) ellipses = [matplotlib.patches.Ellipse(xy=(x, y), width=alpha[kk]*w, height=alpha[kk]*h, angle=ang, fc='none', ec=colours[k], lw=2.5, alpha=1.) for kk in range(0, 2)] for e in ellipses: ax.add_patch(e) """
# b_HI(z), f(z), fix w_0, w_a _F = F_eos_list[i] _F = rf.fisher_with_excluded_params(_F, [6, 7]) zfns_fix_w0wa = [ 2, ] FF = _F for idx in zfns_fix_w0wa: FF = rf.expand_matrix_for_sampled_fn(FF, idx, Nbins, i) F_w0wa += FF ax = P.subplot(111) # Overlay error ellipses as a fn. of z p1 = rf.indexes_for_sampled_fns(4, zc.size, zfns_base) # omega_k # y p2 = rf.indexes_for_sampled_fns(5, zc.size, zfns_base) # omega_de # x # 1D marginals cov = np.linalg.inv(F_wa) print "sigma(ok) =", np.sqrt(cov[p1, p1]) print "sigma(oDE) =", np.sqrt(cov[p2, p2]) y = rf.experiments.cosmo['omega_k_0'] x = rf.experiments.cosmo['omega_lambda_0'] Fs = [F_base, F_wa, F_w0wa] for i in range(len(Fs)): FF = Fs[i] a, b, ang = rf.ellipse_for_fisher_params(p1, p2, FF) ellipses = [
F, lbls = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=excl) # Add Planck prior Fpl = F.copy() # Indices of Planck prior Fisher matrix in our Fisher matrix # w0:6, wa:7, omega_DE:5, omega_k:4, w_m, w_b, n_s:3 _names = ['w0', 'wa', 'omegaDE', 'omegak', 'w_m', 'w_b', 'n_s'] idxs_in_f = [6, 7, 5, 4, -1, -1, 3] for i in range(len(idxs_in_f)): if idxs_in_f[i] == -1: continue for j in range(len(idxs_in_f)): if idxs_in_f[j] == -1: continue ii = rf.indexes_for_sampled_fns(idxs_in_f[i], zc.size, zfns) jj = rf.indexes_for_sampled_fns(idxs_in_f[j], zc.size, zfns) Fpl[ii, jj] += euclid.planck_prior_full[i, j] #print ">>>", _names[i], _names[j], lbls[idxs_in_f[i]], lbls[idxs_in_f[j]] cov = np.linalg.inv(F) cov_pl = np.linalg.inv(Fpl) print names[k] for i in range(len(lbls)): print "%2d %10s %3.4f %3.4f" % (i, lbls[i], np.sqrt( cov[i, i]), np.sqrt(cov_pl[i, i])) print "-" * 50 # Indices of fns. of z pmnu = rf.indexes_for_sampled_fns(10, zc.size, zfns)
excl = [2, 4, 6, 7, 8, 9, 11, 12, 14] # Want to see n_s and M_nu excl += [i for i in range(len(pnames)) if "pk" in pnames[i]] F, lbls = rf.combined_fisher_matrix(F_list, expand=zfns, names=pnames, exclude=excl) # Add Planck prior Fpl = euclid.add_planck_prior(F, lbls, info=False) print "-" * 50 print names[k] print "-" * 50 # Invert matrices pns = rf.indexes_for_sampled_fns(3, zc.size, zfns) pmnu = rf.indexes_for_sampled_fns(6, zc.size, zfns) cov_pl = np.linalg.inv(Fpl) print lbls[pns], lbls[pmnu] fom = rf.figure_of_merit(pns, pmnu, None, cov=cov_pl) print "%s: FOM = %3.2f" % (names[k], fom) x = rf.experiments.cosmo['n'] y = 0.1 #rf.experiments.cosmo['wa'] # Plot contours for n_s, Mnu w, h, ang, alpha = rf.ellipse_for_fisher_params(pns, pmnu, None,