Create, evolve and save a binary star population.

class posydon.popsyn.binarypopulation.BinaryGenerator(sampler=<function generate_independent_samples>, RNG=None, **kwargs)[source]

Bases: object

Generate binaries to be included in a BinaryPopulation.

Initialize the BinaryGenerator instance.

draw_initial_binary(**kwargs)[source]

Return a binary for evolution in a population.

Parameters

index (int) – Sets binary index. Defaults to number of generated binaries.

Returns

binary

Return type

BinaryStar

draw_initial_samples(orbital_scheme='separation', **kwargs)[source]

Generate all random varibles.

get_binary_by_iter(n=1, **kwargs)[source]

Get the nth binary as if n calls were made to draw_intial_binary.

get_original_rng()[source]

Return the random-number generator.

reset_rng()[source]

Reset the RNG with the stored entropy.

class posydon.popsyn.binarypopulation.BinaryPopulation(**kwargs)[source]

Bases: object

Handle a binary star population.

Initialize the binary population object.

Parameters
  • number_of_binaries (int) – Size of the population

  • population_properties (SimulationProperties) – Instance of simulationproperties holding steps.

close()[source]

Close loaded h5 files from SimulationProperties.

combine_saved_files(absolute_filepath, file_names, mode='a')[source]

Combine various temporary files in a given folder.

evolve(**kwargs)[source]

Evolve a binary population.

Parameters
  • indices (list, optional) – Custom binary indices to use. Default is range(number_of_binaries).

  • breakdown_to_df (bool, True) – Breakdown a binary after evolution, converting to dataframe and removing the binary instance from memory.

  • tqdm (bool, False) – Show tqdm progress bar during evolution.

Returns

Return type

None

classmethod from_ini(path, verbose=False)[source]

Create a BinaryPopulation instance from an inifile.

Parameters
  • path (str) – Path to an inifile to load in.

  • verbose (bool) – Print useful info.

Returns

A new instance of a BinaryPopulation.

Return type

BinaryPopulation

make_temp_fname()[source]

Get a valid filename for the temporary file.

save(save_path, mode='a', **kwargs)[source]

Save BinaryPopulation to hdf file.

class posydon.popsyn.binarypopulation.PopulationManager(file_name=None, **kwargs)[source]

Bases: object

Manage a population of binaries.

Initialize a PopulationManager instance.

append(binary)[source]

Add a binary instance internaly.

breakdown_to_df(binary, **kwargs)[source]

Breakdown to a pandas DataFrame.

Breakdown a binary into more convenient data type, store it, and remove the BinaryStar instance from self.

clear_dfs()[source]

Remove all dfs.

close()[source]

Close the HDF5 file.

find_failed()[source]

Find any failed binaries in the population.

from_hdf(indices, where=None, restore=False)[source]

Load a BinaryStar instance from an hdf file of a saved population.

Parameters
  • indices (int, list) – Selects the binaries to load.

  • where (str) – Query performed on disk to select history and oneline DataFrames.

  • restore (bool) – Restore binaries back to initial conditions.

generate(**kwargs)[source]

Generate a binary by drawing from the binary_generator.

This can be a callable or a generator.

remove(binary)[source]

Remove a binary instance.

save(fname, mode='a', **kwargs)[source]

Save binaries to an hdf file using pandas HDFStore.

Any object dtype columns not parsed by infer_objects() is converted to a string.

Parameters
  • fname (str) – Name of hdf file saved.

  • **kwargs

Returns

Return type

None

to_df(selection_function=None, **kwargs)[source]

Convert all binaries to dataframe.

to_oneline_df(selection_function=None, **kwargs)[source]

Convert all binaries to oneline dataframe.