def test_emulator(): #Unpickle the emulator emulator = Emulator.load("analysis.p") emulator.train() #Set the model emulator.set_to_model(np.array([ 0.26,-2.66,1.31,0.96])) ell = emulator.feature_label Pell = emulator._current_predicted_feature #Select the new multipoles l = np.arange(900.0,3000.0,200.0) #Emulate the power spectrum Pl = emulator.emulate(l) #Plot fig,ax = plt.subplots() ax.plot(ell,ell*(ell+1)*Pell/(2*np.pi),label="Fully emulated") ax.plot(l,l*(l+1)*Pl/(2.0*np.pi),label="New multipoles",color="yellow") ax.set_xlabel(r"$l$") ax.set_ylabel(r"$l(l+1)P_l/2\pi$") ax.set_yscale("log") ax.legend(loc="upper left") fig.savefig("emulated_power.png")
def test_emulator(): #Unpickle the emulator emulator = Emulator.load("analysis.p") emulator.train() #Set the model emulator.set_to_model(np.array([0.26, -2.66, 1.31, 0.96])) ell = emulator.feature_label Pell = emulator._current_predicted_feature #Select the new multipoles l = np.arange(900.0, 3000.0, 200.0) #Emulate the power spectrum Pl = emulator.emulate(l) #Plot fig, ax = plt.subplots() ax.plot(ell, ell * (ell + 1) * Pell / (2 * np.pi), label="Fully emulated") ax.plot(l, l * (l + 1) * Pl / (2.0 * np.pi), label="New multipoles", color="yellow") ax.set_xlabel(r"$l$") ax.set_ylabel(r"$l(l+1)P_l/2\pi$") ax.set_yscale("log") ax.legend(loc="upper left") fig.savefig("emulated_power.png")
def test_reparametrize(): #Unpickle the emulator emulator = Emulator.load("analysis.p") #Get the old parametrizations Om = emulator.parameter_set[:,0] w = emulator.parameter_set[:,1] si8 = emulator.parameter_set[:,2] #Define the reparametrizer ( (Om,si8) -> (si8 x Om^0.5)) def formatter(data,n): print("Omega_m exponent={0:.1f}".format(n)) return np.array([data[:,1],data[:,2]*(data[:,0]**n)]).transpose() #Reparametrize the parameter space emulator.reparametrize(formatter,0.5) #Check that everything worked assert (emulator.parameter_set[:,0]==w).all() assert (emulator.parameter_set[:,1]==(si8*(Om**0.5))).all()
def test_reparametrize(): #Unpickle the emulator emulator = Emulator.load("analysis.p") #Get the old parametrizations Om = emulator.parameter_set[:, 0] w = emulator.parameter_set[:, 1] si8 = emulator.parameter_set[:, 2] #Define the reparametrizer ( (Om,si8) -> (si8 x Om^0.5)) def formatter(data, n): print("Omega_m exponent={0:.1f}".format(n)) return np.array([data[:, 1], data[:, 2] * (data[:, 0]**n)]).transpose() #Reparametrize the parameter space emulator.reparametrize(formatter, 0.5) #Check that everything worked assert (emulator.parameter_set[:, 0] == w).all() assert (emulator.parameter_set[:, 1] == (si8 * (Om**0.5))).all()