evolve

class cosmic.evolve.Evolve

Bases: object

__dict__ = mappingproxy({'__module__': 'cosmic.evolve', '__init__': <function Evolve.__init__>, 'evolve': <classmethod(<function Evolve.evolve>)>, '__dict__': <attribute '__dict__' of 'Evolve' objects>, '__weakref__': <attribute '__weakref__' of 'Evolve' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__()

initialize Evolve

__module__ = 'cosmic.evolve'
__weakref__

list of weak references to the object (if defined)

classmethod evolve(initialbinarytable, pool=None, **kwargs)

After setting a number of initial conditions we evolve the system.

Parameters
initialbinarytableDataFrame

Initial conditions of the binary

**kwargs:

There are three ways to tell evolve and thus the fortran what you want all the flags and other BSE specific parameters to be. If you pass both a dictionary of flags and/or a inifile and a table with the BSE parameters in the columns, the column values will be overwritten by what is in the dictionary or ini file.

NUMBER 1: PASS A DICTIONARY OF FLAGS

BSEDict

NUMBER 2: PASS A PANDAS DATA FRAME WITH PARAMS DEFINED AS COLUMNS

All you need is the initialbinarytable if the all the BSE parameters are defined as columns

NUMBER 3: PASS PATH TO A INI FILE WITH THE FLAGS DEFINED

params

randomseedint, optional, default let numpy choose for you

If you would like the random seed that the underlying fortran code uses to be the same for all of the initial conditions you passed then you can send this keyword argument in. It is recommended to just let numpy choose a random number as the Fortran random seed and then this number will be returned as a column in the initial binary table so that you can reproduce the results.

nprocint, optional, default: 1

number of CPUs to use to evolve systems in parallel

idxint, optional, default: 0

initial index of the bcm/bpp arrays

dtpfloat, optional: default: tphysf

timestep size in Myr for bcm output where tphysf is total evolution time in Myr

n_per_blockint, optional, default: -1

number of systems to evolve in a block with _evolve_multi_system, to allow larger multiprocessing queues and reduced overhead. If less than 1 use _evolve_single_system

Returns
output_bppDataFrame

Evolutionary history of each binary

output_bcmDataFrame

Final state of each binary

initialbinarytableDataFrame

Initial conditions for each binary

class cosmic.evolve.MultiPool(processes=None, initializer=None, initargs=(), **kwargs)

Bases: Pool

A modified version of multiprocessing.pool.Pool that has better behavior with regard to KeyboardInterrupts in the map() method.

(Original author: Peter K. G. Williams)

Parameters
processesint, optional

The number of worker processes to use; defaults to the number of CPUs.

initializercallable, optional

If specified, a callable that will be invoked by each worker process when it starts.

initargsiterable, optional

Arguments for initializer; it will be called as initializer(*initargs).

kwargs:

Extra arguments passed to the multiprocessing.pool.Pool superclass.

__doc__ = '\n    A modified version of :class:`multiprocessing.pool.Pool` that has better\n    behavior with regard to ``KeyboardInterrupts`` in the :func:`map` method.\n\n    (Original author: `Peter K. G. Williams <peter@newton.cx>`_)\n\n    Parameters\n    ----------\n    processes : int, optional\n        The number of worker processes to use; defaults to the number of CPUs.\n    initializer : callable, optional\n        If specified, a callable that will be invoked by each worker process\n        when it starts.\n    initargs : iterable, optional\n        Arguments for ``initializer``; it will be called as\n        ``initializer(*initargs)``.\n    kwargs:\n        Extra arguments passed to the :class:`multiprocessing.pool.Pool`\n        superclass.\n\n    '
__init__(processes=None, initializer=None, initargs=(), **kwargs)
__module__ = 'schwimmbad.multiprocessing'
static enabled()
map(func, iterable, chunksize=None, callback=None)

Equivalent to the built-in map() function and multiprocessing.pool.Pool.map(), without catching KeyboardInterrupt.

Parameters
workercallable

A function or callable object that is executed on each element of the specified tasks iterable. This object must be picklable (i.e. it can’t be a function scoped within a function or a lambda function). This should accept a single positional argument and return a single object.

tasksiterable

A list or iterable of tasks. Each task can be itself an iterable (e.g., tuple) of values or data to pass in to the worker function.

callbackcallable, optional

An optional callback function (or callable) that is called with the result from each worker run and is executed on the master process. This is useful for, e.g., saving results to a file, since the callback is only called on the master thread.

Returns
resultslist

A list of results from the output of each worker() call.

wait_timeout = 3600
cosmic.evolve._evolve_multi_system(f)
cosmic.evolve._evolve_single_system(f)
cosmic.evolve.set_checkstates(timestep_conditions=[])

A function which will detemine different time resolution for different states

Parameters:
timestep_conditions(list) default empty (no dynamic dtp setting)

a nested list of the many different time resolutions and conditions for which you would like to apply those time resolution, e.g.,

>>> timestep_conditions = [['20.0<mass_1<25.5', '15.5>mass_2>10.0', 'dtp=1.0'],
>>> ['kstar_1=14', 'lum_1>10.0', 'dtp=0.01'],
>>> ['2>=binstate>=1', 'dtp=None']]

The first two sets of conditons would be done in a AND fashion. The last condition would end time resolution for the BCM array and it would skip to only printing the final state