コード例 #1
0
def get_all_options_ics(**kwargs):
    user_params, cosmo_params, astro_params, flag_options = get_all_defaults(kwargs)
    user_params.update(DEFAULT_USER_PARAMS)
    out = {
        "user_params": user_params,
        "cosmo_params": cosmo_params,
        "random_seed": SEED,
    }

    for key in kwargs:
        if key.upper() in (k.upper() for k in global_params.keys()):
            out[key] = kwargs[key]
    return out
コード例 #2
0
def produce_perturb_field_data(redshift, **kwargs):
    options = get_all_options(redshift, **kwargs)
    options_ics = get_all_options_ics(**kwargs)

    out = {
        key: kwargs[key]
        for key in kwargs
        if key.upper() in (k.upper() for k in global_params.keys())
    }

    velocity_normalisation = 1e16

    with config.use(regenerate=True, write=False):
        init_box = initial_conditions(**options_ics)
        pt_box = perturb_field(redshift=redshift, init_boxes=init_box, **out)

    p_dens, k_dens = get_power(
        pt_box.density,
        boxlength=options["user_params"]["BOX_LEN"],
    )
    p_vel, k_vel = get_power(
        pt_box.velocity * velocity_normalisation,
        boxlength=options["user_params"]["BOX_LEN"],
    )

    def hist(kind, xmin, xmax, nbins):
        data = getattr(pt_box, kind)
        if kind == "velocity":
            data = velocity_normalisation * data

        bins, edges = np.histogram(
            data,
            bins=np.linspace(xmin, xmax, nbins),
            range=[xmin, xmax],
            density=True,
        )

        left, right = edges[:-1], edges[1:]

        X = np.array([left, right]).T.flatten()
        Y = np.array([bins, bins]).T.flatten()
        return X, Y

    X_dens, Y_dens = hist("density", -0.8, 2.0, 50)
    X_vel, Y_vel = hist("velocity", -2, 2, 50)

    return k_dens, p_dens, k_vel, p_vel, X_dens, Y_dens, X_vel, Y_vel, init_box
コード例 #3
0
def get_all_options(redshift, **kwargs):
    user_params, cosmo_params, astro_params, flag_options = get_all_defaults(kwargs)
    user_params.update(DEFAULT_USER_PARAMS)
    out = {
        "redshift": redshift,
        "user_params": user_params,
        "cosmo_params": cosmo_params,
        "astro_params": astro_params,
        "flag_options": flag_options,
        "use_interp_perturb_field": kwargs.get("use_interp_perturb_field", False),
        "random_seed": SEED,
    }

    for key in kwargs:
        if key.upper() in (k.upper() for k in global_params.keys()):
            out[key] = kwargs[key]
    return out
コード例 #4
0
def test_global_params_keys():
    assert "HII_FILTER" in global_params.keys()