bioverse.generator module
This module defines the Generator class and demonstrates how to create new Generators.
- class bioverse.generator.Generator(label=None)
Bases:
Object
This class executes a series of functions to generate a set of nearby systems.
- Parameters:
label (str, optional) – Name of the Generator. Leave as None to create a new Generator.
- copy()
Returns a deep copy of the Generator.
- initialize(filename)
Creates a new program from a CSV file containing the function names and descriptions.
- Parameters:
filename (str) – Name of the CSV file from which to initialize the Generator.
- update_steps(reload=False)
Loads or re-loads the keyword arguments and description of each step in the Generator.
- Parameters:
reload (bool) – Whether or not to reload the default values for the arguments.
- insert_step(function, idx=None, filename=None)
Inserts a step into the program sequence at the specified index.
- Parameters:
function (str or function) – Name of the function to be run by this step or the function itself.
idx (int, optional) – Position in the program at which to insert the step. Default is -1 i.e. at the end.
filename (str, optional) – Filename containing the function.
- replace_step(new_function, idx, new_filename=None)
Replaces a step into the program sequence at the specified index.
- Parameters:
new_function (str or function) – Name of the function to be run by this step or the function itself.
idx (int) – Position in the program at which to replace the step.
new_filename (str, optional) – Filename containing the function.
- get_arg(key)
Gets the default value of a keyword argument, and warns if there are multiple values.
- set_arg(key, value)
Sets the default value of a keyword argument for every step it applies to.
- generate(d=None, timed=False, idx_start=0, idx_stop=None, **kwargs)
Runs the generator with the current program and returns a simulated set of stars and planets.
- Parameters:
d (Table, optional) – Pre-existing table of simulated planets to be passed as input. If not specified, an empty table is created.
timed (bool, optional) – If True, times each step in the program and prints the results.
idx_start (int, optional) – Specifies at which step in the program the Generator should start.
idx_stop (int, optional) – Specifies at which step in the program the Generator should stop.
**kwargs – Keyword argument(s) to be passed to the individual steps, e.g. d_max=20. Can have unintended consequences if the keyword argument appears in more than one step.
- Returns:
d – Table of simulated planets (plus host star parameters).
- Return type:
- class bioverse.generator.Step(function, filename=None)
Bases:
object
This class runs one function for a Generator and saves its keyword argument values.
- Parameters:
function (str or function) – Name of the function to be run or the function itself.
filename (str, optional) – Name of the file containing the function for this step. If None, looks in custom.py and functions.py.
- description
Docstring for this step’s function.
- Type:
str
- run(d, **kwargs)
Runs the function described by this step.
- get_arg(key)
Returns the value of a keyword argument.
- set_arg(key, value)
Sets the value of a keyword argument.
- Parameters:
key (str) – Name of the argument whose value will be set.
val – New value of the argument.
- find_filename()
If the filename is not specified, look in custom.py followed by functions.py.
- load_function(reload=False)
Loads or re-loads the function’s description and keyword arguments.
- Parameters:
reload (bool, optional) – Whether or not to reload the default values for the arguments.
- bioverse.generator.reset_imaging_generator()
Re-creates the default Generator for imaging surveys.
- bioverse.generator.reset_transit_generator()
Re-creates the default Generator for transit surveys.