Skip to content
Snippets Groups Projects
Commit bc2e9379 authored by David Hendriks's avatar David Hendriks
Browse files

added population example script

parent 562ce0c5
No related branches found
No related tags found
No related merge requests found
import os
# import json
# import time
# import sys
from binarycpython.utils.grid import Population
from binarycpython.utils.functions import get_help_all, get_help
#########################################################
# This file serves as an example for running a population.
# The use of help(<function>) is a good way to inspect what parameters are there to use
#########################################################
# Create population object
example_pop = Population()
# If you want verbosity, set this before other things
example_pop.set(verbose=0)
# Setting values can be done via .set(<parameter_name>=<value>)
# Values that are known to be binary_c_parameters are loaded into bse_options.
# Those that are present in the default grid_options are set in grid_options
# All other values that you set are put in a custom_options dict
example_pop.set(
#
M_1=10, # bse_options
separation=0, # bse_options
orbital_period=4580, # bse_options
max_evolution_time=15000, # bse_options
eccentricity=0.02, # bse_options
#
amt_cores=1, # grid_options
#
data_dir=os.path.join(
os.environ["BINARYC_DATA_ROOT"], "example_python"
), # custom_options
base_filename="example_pop.dat", # custom_options
)
# Custom logging
# TODO: show different ways
example_pop.set(
C_auto_logging={
"MY_HEADER_LINE": ["star[0].mass", "star[1].mass", "model.probability"]
}
)
example_pop.set(
C_logging_code='Printf("MY_STELLAR_DATA time=%g mass=%g radius=%g\\n", stardata->model.time, stardata->star[0].mass, stardata->star[0].radius);'
)
example_pop.set_custom_logging()
# Exporting of all the settings can be done with .export_all_info()
# on default it exports everything, but can be supressed by turning it off:
# population settings (bse_options, grid_options, custom_options), turn off with include_population_settings=False
# binary_c_defaults (all the commandline arguments that binary c accepts, and their defaults). turn off with include_binary_c_defaults=False
# include_binary_c_version_info (all the compilation info, and information about the compiled parameters), turn off with include_binary_c_version_info=False
# include_binary_c_help_all (all the help information for all the binary_c parameters), turn off with include_binary_c_help_all=Fase
# On default it will write this to the custom_options['data_dir'], but that can be overriden by setting use_datadir=False and providing an outfile=<>
example_pop.export_all_info()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment