Exemplo n.º 1
0
import grale.cosmology as cosmology
from grale.constants import DIST_MPC
import numpy as np

for i in range(20):
    h = np.random.uniform(0.6, 0.8)
    Wm = np.random.uniform(0.25, 0.35)
    Wr = np.random.uniform(0, 0.1)
    if np.random.random() < 0.5:  # flat
        Wv = 1.0 - Wr - Wm
    else:
        Wv = np.random.uniform(0.6, 0.8)

    w = np.random.uniform(-1.1, -0.9)

    cosm = cosmology.Cosmology(h, Wm, Wr, Wv, w)

    z1 = 0 if np.random.random() < 0.5 else np.random.uniform(0, 1.5)
    z2 = np.random.uniform(0.1, 4.5)
    resultmpc = cosm.getAngularDiameterDistance(z1, z2) / DIST_MPC
    print(f'{{ {{ "h", {h} }}, ', end='')
    print(f'{{ "Wm", {Wm} }}, ', end='')
    print(f'{{ "Wr", {Wr} }}, ', end='')
    print(f'{{ "Wv", {Wv} }}, ', end='')
    print(f'{{ "w", {w} }}, ', end='')
    print(f'{{ "z1", {z1} }}, ', end='')
    print(f'{{ "z2", {z2} }}, ', end='')
    print(f'{{ "resultmpc", {resultmpc} }} }},')
Exemplo n.º 2
0
import grale.lenses as lenses
import grale.multiplane as multiplane
import grale.cosmology as cosmology
from grale.constants import *
import numpy as np

V = lambda x, y: np.array([x, y], dtype=np.double)

cosm = cosmology.Cosmology(0.7, 0.3, 0, 0.7)
D = cosm.getAngularDiameterDistance

cosmology.setDefaultCosmology(cosm)
z1, z2 = 0.5, 1.5

sourceRedshifts = [ 1.25, 2.0 ]
allThetas = [ [ V(10,8)*ANGLE_ARCSEC ] , [ V(-12,2)*ANGLE_ARCSEC ] ]

for factor in [ 0.5, 1.0, 2.0 ]:
    print("Using factor", factor)
    lensesAndRedshifts = [
        (lenses.CompositeLens(D(z1), [
            { "lens": lenses.PlummerLens(D(z1), { "mass": 1e14*MASS_SUN, "width": 5*ANGLE_ARCSEC }),
              "x": 0, "y": 0, "angle": 0, "factor": factor }
            ]), z1),
        (lenses.CompositeLens(D(z2), [
            { "lens": lenses.PlummerLens(D(z2), { "mass": 5e13*MASS_SUN, "width": 3*ANGLE_ARCSEC }),
              "x": 1*ANGLE_ARCSEC, "y": -1*ANGLE_ARCSEC, "angle": 0, "factor": factor }
            ]), z2),
        ]

    lensPlane = multiplane.MultiLensPlane(lensesAndRedshifts, V(-30,-30)*ANGLE_ARCSEC, V(30, 30)*ANGLE_ARCSEC, 511, 511)
Exemplo n.º 3
0
# Write the RNG state, in case we want to reproduce the run exactly
# (note that the GRALE_DEBUG_SEED environment variable will need
# to be restored as well)
import random
print("RNG State:")
print(random.getstate())

renderers.setDefaultLensPlaneRenderer(
    "threads")  # threads, mpi, opencl, None or a Renderer object
renderers.setDefaultMassRenderer(
    "threads")  # threads, mpi, None, or a Renderer object
inversion.setDefaultInverter("threads")  # threads, mpi or an Inverter object

z_lens = 0.4
cosm = cosmology.Cosmology(0.7, 0.27, 0, 0.73)
cosmology.setDefaultCosmology(cosm)

weakSize = 30 * ANGLE_ARCMIN
weakSubDiv = 48
weakThreshold = 0.1  # Threshold for |1-kappa|
sheetType = "nosheet"  # or "genome"

iws = inversion.InversionWorkSpace(
    z_lens, weakSize)  # Now using weakSize for the default grid size
iws.addImageDataToList(images.ImagesData.load("ellipt_48x48_exact_z1.imgdata"),
                       1, "sheardata", {"threshold": weakThreshold})
iws.addImageDataToList(images.ImagesData.load("ellipt_48x48_exact_z2.imgdata"),
                       2, "sheardata", {"threshold": weakThreshold})
iws.addImageDataToList(images.ImagesData.load("ellipt_48x48_exact_z4.imgdata"),
                       4, "sheardata", {"threshold": weakThreshold})