- class cosmic.output.COSMICOutput(bpp=None, bcm=None, initC=None, kick_info=None, file=None, label=None, file_key_suffix='')[source]¶
Bases:
objectContainer for COSMIC output data components.
Can be initialized either from data components directly or by loading from an HDF5 file.
- Parameters:
- bpppandas.DataFrame, optional
Important evolution timestep table, by default None
- bcmpandas.DataFrame, optional
User-defined timestep table, by default None
- initCpandas.DataFrame, optional
Initial conditions table, by default None
- kick_infopandas.DataFrame, optional
Natal kick information table, by default None
- filestr, optional
Filename/path to HDF5 file to load data from, by default None
- labelstr, optional
Optional label for the output instance, by default None
- file_key_suffixstr, optional
Suffix to append to dataset keys when loading from file, by default ‘’. E.g. if set to ‘_singles’, datasets ‘bpp_singles’, ‘bcm_singles’, etc. will be loaded as bpp, bcm, etc.
- Raises:
- ValueError
If neither file nor all data components are provided.
- property final_bpp[source]¶
Get the final timestep for each binary from the bpp table.
- Returns:
- final_bpppandas.DataFrame
DataFrame containing only the final timestep for each binary.
- plot_detailed_evolution(bin_num, show=True, **kwargs)[source]¶
Plot detailed evolution for a specific binary.
- Parameters:
- bin_numint
Index of the binary to plot.
- **kwargs
Additional keyword arguments passed to the plotting function (plotting.plot_binary_evol).
- plot_distribution(x_col, y_col=None, c_col=None, when='final', fig=None, ax=None, show=True, xlabel='auto', ylabel='auto', clabel='auto', **kwargs)[source]¶
Plot distribution of binaries in specified columns.
Plots can be histograms (if only x_col is given) or scatter plots (if both x_col and y_col are given). Optionally, colour coding can be applied using c_col.
- Parameters:
- x_colstr
Column name for x-axis.
- y_colstr, optional
Column name for y-axis. If None, a histogram will be plotted. By default None.
- c_colstr, optional
Column name for colour coding. By default None.
- whenstr, optional
When to take the values from: ‘initial’ or ‘final’. By default ‘final’.
- figmatplotlib.figure.Figure, optional
Figure to plot on. If None, a new figure is created. By default None.
- axmatplotlib.axes.Axes, optional
Axes to plot on. If None, new axes are created. By default None.
- showbool, optional
If True, display the plot immediately. By default True.
- xlabelstr, optional
Label for x-axis. If ‘auto’, uses the column name. By default ‘auto’.
- ylabelstr, optional
Label for y-axis. If ‘auto’, uses the column name or ‘Count’ for histogram. By default ‘auto’.
- clabelstr, optional
Label for colorbar. If ‘auto’, uses the column name. By default ‘auto
- **kwargs
Additional keyword arguments passed to the plotting function.
- Returns:
- figmatplotlib.figure.Figure
The figure containing the plot.
- axmatplotlib.axes.Axes
The axes containing the plot.
- rerun_with_settings(new_settings, reset_kicks=False, inplace=False)[source]¶
Rerun the simulation with new settings.
- Parameters:
- new_settingsdict
Dictionary of new settings to apply. Any setting not included will retain its original value.
- reset_kicksbool, optional
If True, reset natal kicks to be randomly sampled again. If False, retain original kicks. By default False. (You may want to reset the kicks if changing settings that affect remnant masses or kick distribution.)
- inplacebool, optional
If True, update the current instance. If False, return a new instance. By default False.
- Returns:
- new_outputCOSMICOutput
New COSMICOutput instance with updated simulation results (only if inplace is False).
- cosmic.output.load_initC(filename, key='initC', settings_key='initC_settings')[source]¶
Load an initC table from an HDF5 file.
If settings were saved separately, they are merged back into the main table.
- Parameters:
- filenamestr
Filename/path to the HDF5 file
- keystr, optional
Dataset key to use for main table, by default “initC”
- settings_keystr, optional
Dataset key to use for settings table, by default “initC_settings”
- Returns:
- initCpandas.DataFrame
Initial conditions table
- cosmic.output.save_initC(filename, initC, key='initC', settings_key='initC_settings', force_save_all=False)[source]¶
Save an initC table to an HDF5 file.
Any column where every binary has the same value (setting) is saved separately with only a single copy to save space.
This will take slightly longer (a few seconds instead of 1 second) to run but will save you around a kilobyte per binary, which adds up!
- Parameters:
- filenamestr
Filename/path to the HDF5 file
- initCpandas.DataFrame
Initial conditions table
- keystr, optional
Dataset key to use for main table, by default “initC”
- settings_keystr, optional
Dataset key to use for settings table, by default “initC_settings”
- force_save_allbool, optional
If true, force all settings columns to be saved in the main table, by default False