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 # Load best sample grid = ParameterGrid(model_name) # Make directory for output directory = os.path.join(grid.directory, "faux") os.makedirs(directory, exist_ok=True) # Calculate metrics for i in range(NITERS): filename = os.path.join(directory, f"metrics_{i}.csv") if os.path.isfile(filename): continue grid.logger.debug(f"Iteration {i+1} of {NITERS}.") dff = grid.make_faux_observations() grid.evaluate(dfo=dff, filename=filename, nproc=NPROC, metrics_ignore=METRICS_IGNORE)
""" Code to evaluate a grid, replacing whatever metrics have already been calculated """ from udgsizes.fitting.grid import ParameterGrid if __name__ == "__main__": pop_name = "blue" metrics_ignore = ["kstest_2d"] # Skip because it takes ages nproc = 4 p = ParameterGrid(pop_name) p.evaluate(metrics_ignore=metrics_ignore, nproc=nproc)
model_name = "blue_sedgwick_shen_highkink" model_type = "udgsizes.model.sm_size.Model" config = get_config() config["grid"][model_type]["parameters"]["rec_phys_offset"]["alpha"][ "max"] = 0.6 config["grid"][model_type]["parameters"]["rec_phys_offset"]["alpha"][ "step"] = 0.05 config["grid"][model_type]["parameters"]["logmstar"]["a"]["min"] = -1.50 config["grid"][model_type]["parameters"]["logmstar"]["a"]["max"] = -1.45 config["grid"][model_type]["parameters"]["logmstar"]["a"]["step"] = 0.05 metrics_ignore = ["kstest_2d"] # Takes too long for whole grid n_samples = 500 burnin = 250 grid = ParameterGrid(model_name, config=config) if CHECK_INITIAL_VALUES: grid.check_initial_values() if SAMPLE: grid.sample(overwrite=True, n_samples=n_samples, burnin=burnin) grid.evaluate(metrics_ignore=metrics_ignore) dfm = grid.load_metrics() if MAKEPLOTS: grid.summary_plot() plt.show(block=False)