Esempio n. 1
0
if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("model_name", type=str, help="The model name.")
    parsed_args = parser.parse_args()
    model_name = parsed_args.model_name

    grid = ParameterGrid(model_name)
    image_dir = grid.config["directories"]["images"]

    # Load metrics evaluated from faux observations
    dfms = grid.load_faux_metrics()

    # Get best hyper parameters for each faux sample
    df = []
    for dfm in dfms:
        best_pars = grid.get_best_hyper_parameters(df=dfm, flatten=True, kstest_min=None)
        df.append(best_pars)

    df = pd.DataFrame(df)

    # Plot hist for each parameter
    for parname in df.columns:
        filename = os.path.join(image_dir, f"faux_{parname}_{model_name}.png")

        values = df[parname].values
        plot_par(parname, values, filename=filename)

    plt.show(block=False)
Esempio n. 2
0
    if filename is not None:
        plt.savefig(filename, dpi=150, bbox_inches="tight")

    plt.show(block=False)


if __name__ == "__main__":

    n_samples = 10000
    burnin = 1000

    # Get best fitting hyper parameters
    grid = ParameterGrid(MODEL_NAME)

    # Get best fitting hyper parameters
    hyper_params = grid.get_best_hyper_parameters()

    # Sample the model with no recovery efficiency
    model = create_model(UDG_MODEL_NAME, ignore_recov=True)
    df = model.sample(burnin=burnin,
                      n_samples=n_samples,
                      hyper_params=hyper_params)

    # Identify UDGs
    cond = df["is_udg"].values == 1
    df = df[cond].reset_index(drop=True)

    # Get sizes
    x = df["rec_phys"].values

    # Make histogram