Example #1
0
def design(cmd_args):

	#Load the design
	design = Design.load(design_points,[r"$\Omega_m$",r"$w$",r"$\sigma_8$"])

	#Create the figure
	fig,ax = plt.subplots(1,2,figsize=(16,8))

	#Visualize the design
	design.visualize(fig,ax[0],parameters=[r"$\Omega_m$",r"$w$"])
	design.visualize(fig,ax[1],parameters=[r"$\Omega_m$",r"$\sigma_8$"])

	#Show also the fiducial point
	ax[0].scatter(0.26,-1.0,color="red")
	ax[1].scatter(0.26,0.8,color="red")

	#Save the figure 
	fig.savefig("design.{0}".format(cmd_args.type))
Example #2
0
def design(cmd_args):

	#Load the design
	design = Design.read(design_points)
	design.columns = [r"$\Omega_m$",r"$w_0$",r"$\sigma_8$"]
	design._labels = [r"$\Omega_m$",r"$w_0$",r"$\sigma_8$"]
	design._pmin = design.values.min(0)
	design._pmax = design.values.max(0)

	#Create the figure
	fig,ax = plt.subplots(1,2,figsize=(16,8))

	#Visualize the design
	design.visualize(fig,ax[0],parameters=[r"$\Omega_m$",r"$w_0$"],color=sns.xkcd_rgb["dark grey"])
	design.visualize(fig,ax[1],parameters=[r"$\Omega_m$",r"$\sigma_8$"],color=sns.xkcd_rgb["dark grey"])

	#Show also the fiducial point
	ax[0].scatter(0.26,-1.0,marker="x",s=100,lw=3,color=sns.xkcd_rgb["pale red"])
	ax[1].scatter(0.26,0.8,marker="x",s=100,lw=3,color=sns.xkcd_rgb["pale red"])

	#Save the figure 
	fig.savefig("{0}/cfht_design.{0}".format(cmd_args.type))
Example #3
0
def test_visualize():

	#This fails if GSL is not installed
	try:
		design = Design()
	except ImportError:
		return

	#Add the dimensions
	design.add_parameter("Omega_m",min=0.1,max=0.9,label=r"$\Omega_m$")
	design.add_parameter("w",min=-2.0,max=-0.1,label=r"$w$")
	design.add_parameter("sigma8",min=0.01,max=1.6,label=r"$\sigma_8$")

	#Lay down 50 points
	design.put_points(50)
	print(design)

	#The cost function should be the diagonal one
	np.testing.assert_approx_equal(design.diagonalCost(Lambda=1.0),design.cost(p=2.0,Lambda=1.0))

	#Visualize the 3d diagonal configuration
	design.visualize(color="blue")
	design.set_title("Cost={0:.2f}".format(design.diagonalCost(Lambda=1.0)))
	design.savefig("design_diagonal_3d.png")

	#Visualize the 2d (Om,si8) projection
	fig,ax = plt.subplots()
	design.visualize(fig=fig,ax=ax,parameters=["Omega_m","sigma8"],color="red",marker=".")
	design.savefig("design_diagonal_2d.png")

	#Now perform the sampling of the parameter space
	deltaPerc = design.sample(Lambda=1.0,p=2.0,seed=1,maxIterations=100000)

	#Visualize the 3d configuration
	design.visualize(color="blue")
	design.set_title("Cost={0:.2f}".format(design.cost(Lambda=1.0,p=2.0)))
	design.savefig("design_3d.png")

	#Visualize the 2d (Om,si8) projection
	fig,ax = plt.subplots()
	design.visualize(fig=fig,ax=ax,parameters=["Omega_m","sigma8"],color="red",marker=".")
	design.savefig("design_2d.png")

	#Visualize the changes in the cost function
	fig,ax = plt.subplots()
	ax.plot(design.cost_values)
	ax.set_xlabel(r"$N$")
	ax.set_ylabel("cost")
	ax.set_title("Last change={0:.1e}%".format(deltaPerc*100))
	ax.set_xscale("log")
	fig.savefig("cost.png")
Example #4
0
def test_visualize():

    #This fails if GSL is not installed
    try:
        design = Design()
    except ImportError:
        return

    #Add the dimensions
    design.add_parameter("Omega_m", min=0.1, max=0.9, label=r"$\Omega_m$")
    design.add_parameter("w", min=-2.0, max=-0.1, label=r"$w$")
    design.add_parameter("sigma8", min=0.01, max=1.6, label=r"$\sigma_8$")

    #Lay down 50 points
    design.put_points(50)
    print(design)

    #The cost function should be the diagonal one
    np.testing.assert_approx_equal(design.diagonalCost(Lambda=1.0),
                                   design.cost(p=2.0, Lambda=1.0))

    #Visualize the 3d diagonal configuration
    design.visualize(color="blue")
    design.set_title("Cost={0:.2f}".format(design.diagonalCost(Lambda=1.0)))
    design.savefig("design_diagonal_3d.png")

    #Visualize the 2d (Om,si8) projection
    fig, ax = plt.subplots()
    design.visualize(fig=fig,
                     ax=ax,
                     parameters=["Omega_m", "sigma8"],
                     color="red",
                     marker=".")
    design.savefig("design_diagonal_2d.png")

    #Now perform the sampling of the parameter space
    deltaPerc = design.sample(Lambda=1.0, p=2.0, seed=1, maxIterations=100000)

    #Visualize the 3d configuration
    design.visualize(color="blue")
    design.set_title("Cost={0:.2f}".format(design.cost(Lambda=1.0, p=2.0)))
    design.savefig("design_3d.png")

    #Visualize the 2d (Om,si8) projection
    fig, ax = plt.subplots()
    design.visualize(fig=fig,
                     ax=ax,
                     parameters=["Omega_m", "sigma8"],
                     color="red",
                     marker=".")
    design.savefig("design_2d.png")

    #Visualize the changes in the cost function
    fig, ax = plt.subplots()
    ax.plot(design.cost_values)
    ax.set_xlabel(r"$N$")
    ax.set_ylabel("cost")
    ax.set_title("Last change={0:.1e}%".format(deltaPerc * 100))
    ax.set_xscale("log")
    fig.savefig("cost.png")
#!/usr/bin/env python

from lenstools.simulations import Design
import numpy as np

#Create design
d = Design()

#Add parameters
d.add_parameter("Om",0.2,0.5,"Om")
d.add_parameter("w",-1.5,-0.5,"w")
d.add_parameter("si8",0.5,1.2,"si8")

#Lay down points
d.put_points(100)

#Sample
d.sample(Lambda=1.0,p=2.0,seed=123,maxIterations=1000000)
p = d.points

#Save in increasing sigma8 order
np.save("../data/design.npy",p[p[:,2].argsort()])
Example #6
0
from __future__ import print_function

import sys

from lenstools.simulations import Design

import numpy as np
import matplotlib.pyplot as plt

#This fails if GSL is not installed
try:
	design = Design.from_specs(npoints=50,parameters=[("Om",r"$\Omega_m$",0.1,0.9),("w",r"$w$",-2.0,-1.0),("si8",r"$\sigma_8$",0.01,1.6)])
except ImportError:
	sys.exit(1)

print(design)

#The cost function should be the diagonal one
np.testing.assert_approx_equal(design.diagonalCost(Lambda=1.0),design.cost(p=2.0,Lambda=1.0))

#Visualize the 3d diagonal configuration
design.visualize(color="blue")
design.set_title("Cost={0:.2f}".format(design.diagonalCost(Lambda=1.0)))
design.savefig("design_diagonal_3d.png")

#Visualize the 2d (Om,si8) projection
fig,ax = plt.subplots()
design.visualize(fig=fig,ax=ax,parameters=["Om","si8"],color="red",marker=".")
design.savefig("design_diagonal_2d.png")

#Now perform the sampling of the parameter space
Example #7
0
from __future__ import print_function

import sys

from lenstools.simulations import Design

import numpy as np
import matplotlib.pyplot as plt

#This fails if GSL is not installed
try:
    design = Design()
except ImportError:
    sys.exit(1)

#Add the dimensions
design.add_parameter("Omega_m", min=0.1, max=0.9, label=r"$\Omega_m$")
design.add_parameter("w", min=-2.0, max=-0.1, label=r"$w$")
design.add_parameter("sigma8", min=0.01, max=1.6, label=r"$\sigma_8$")

#Lay down 50 points
design.put_points(50)
print(design)

#The cost function should be the diagonal one
np.testing.assert_approx_equal(design.diagonalCost(Lambda=1.0),
                               design.cost(p=2.0, Lambda=1.0))

#Visualize the 3d diagonal configuration
design.visualize(color="blue")
design.set_title("Cost={0:.2f}".format(design.diagonalCost(Lambda=1.0)))
Example #8
0
from __future__ import print_function

import sys

from lenstools.simulations import Design

import numpy as np
import matplotlib.pyplot as plt

#This fails if GSL is not installed
try:
	design = Design()
except ImportError:
	sys.exit(1)

#Add the dimensions
design.add_parameter("Omega_m",min=0.1,max=0.9,label=r"$\Omega_m$")
design.add_parameter("w",min=-2.0,max=-0.1,label=r"$w$")
design.add_parameter("sigma8",min=0.01,max=1.6,label=r"$\sigma_8$")

#Lay down 50 points
design.put_points(50)
print(design)

#The cost function should be the diagonal one
np.testing.assert_approx_equal(design.diagonalCost(Lambda=1.0),design.cost(p=2.0,Lambda=1.0))

#Visualize the 3d diagonal configuration
design.visualize(color="blue")
design.set_title("Cost={0:.2f}".format(design.diagonalCost(Lambda=1.0)))
design.savefig("design_diagonal_3d.png")