posydon.grids

posydon.grids.MODELS

This file contains all core-collapse models we use in our post processing and, as a consequence, what the user will be able to select in the initial/final interpolation. Each model is a dictionary containing the properties of the model used by step_SN.

posydon.grids.downsampling

Module for downsampling accross a path in multi-dimensional space.

Let a d-dimensional parametric curve in of the form:

x_1 = x_1(t) x_2 = x_2(t) … x_d = x_d(t)

sampled at N time steps, t_1, t_2, …, t_N. It is possible to select a subset of the time steps - essentially defining a downsampled version of the curve - so that the original curve can be reconstructed with minimum error.

The provided class TrackDownsampler performs the downsampling. It requires two input arrays. The first is the “independent” variable, t, which does not have to be temporal (e.g., spatial), but must be strictly increasing. The 2nd array is the track, in which the different columns correspond to the different dimensions:

— parameters —>

x_1(t_1) x_2(t_1) … x_d(t_1)
time x_1(t_2) x_2(t_2) … x_d(t_2)

or . . … . any . . … .

. . … .

V x_1(t_N) x_2(t_N) … x_d(t_N)

TD = TrackDownsample(t, X) t_new, X_new = TD.downsample(max_err=0.001)

class posydon.grids.downsampling.TrackDownsampler(independent, dependent, verbose=False)[source]

Bases: object

Class performing downsampling of multi-dimensional paths.

Get, reduce and rescale data.

downsample(max_err=None, scale_back=True, max_interval=None)[source]

Perform the downsampling and return the result.

extract_downsample(scale_back=True)[source]

Extract the downsampled array.

find_downsample(max_err=None, max_interval=None)[source]

Find the rows of the data that constitute the “down-sample”.

Note: if max_interval is negative, it’s value is the relative ratio

between maximum allowed dm and total star mass.

rescale()[source]

Rescale the parameter space from 0 to 1.

say(message)[source]

Speak to the standard output, only if .verbose is False.

posydon.grids.downsampling.rescale_from_0_to_1(array, return_minmax=False)[source]

Rescale a matrix so that all dimensions span from 0 to 1.

posydon.grids.downsampling_report

Provides functions to evaluate the performance of grid downsampling.

posydon.grids.downsampling_report.compare_DS(path, path_DS, runs=None, useonly=None)[source]

Compare the data in original and downsampled grids.

posydon.grids.downsampling_report.report_DS(path, path_DS, max_err_used=None, nmax=None, emax=None, emin=None)[source]

Report on compression ratio and interpolation error statistics.

posydon.grids.io

Provides the functions that handle input/output of Job data.

Example

print(“Example using new script (Simone’s runs)”) path = “/home/konstantinos/pCloudDrive/”

“Shared/POSYDON/BinaryGrids/example_posydon_grid”

grid_reader = GridReader(path, verbose=True)

print(“READING THE PROFILE OF STAR1 IN THE SECOND BINARY OF THE GRID.”) profile = np.genfromtxt(grid_reader.runs[1].final_profile1_path,

skip_header=5, names=True)

print(“Columns:”) print(profile.dtype.names) print(“Array:”) print(profile)

Notes

The input path can be a list of paths or a string. The paths can be given with wildcard characters to incorporate multiple folders. E.g.,

path = [“/home/mygrid_part1”, “/home/mygrid_part2”]

or

path = [“home/mygrid_part*”]

Runs with the same initial parameters (folder name without the _grid_index_* part) are substituted. See psygrid module docstring for more information.

class posydon.grids.io.GridReader(path, fmt='posydon', binary=True, verbose=False, verbose_maxlines=10)[source]

Bases: object

Class for quick reading of MESA grid files.

Initialize object and immediately load the grid file structure.

Parameters:
  • path (str) – Path of the file or folder containing the MESA runs.

  • fmt (str) – Format specifier. Linked to data-types, filename conventions, etc.

  • binary (bool) – Whether the grid(s) are binary.

  • verbose (bool) – If True, it prints reports of performed actions.

  • verbose_maxlines (int) – In case of verbose=True, it sets the maximum number of lines of metadata files to be printed. If None, all lines will be printed. If 0, nothing will be printed.

infer_history_columns(BH_cols, H1_cols, H2_cols)[source]

Infer the columns found in the grid’s history data files.

Parameters:
  • BH_cols (array-like) – Which columns to consider from binary_history.

  • H1_cols (array-like) – Which columns to consider from history1.

  • H2_cols (array-like) – Which columns to consider from history1.

Returns:

The names of the columns in history data. Columns in history1 and history2 are prefixed with star1_ and star2_ respectively.

Return type:

list

read_posydon_format()[source]

Read grid structure, expecting the POSYDON collaboration format.

class posydon.grids.io.RunReader(path, fmt='posydon', binary=True, verbose=False, verbose_maxlines=10)[source]

Bases: object

Class for reading MESA output files of an individual run.

Initialize object and immediately read the data.

Parameters:
  • path (str) – Path of the file or folder containing the MESA run output.

  • fmt (str) – Format specifier. Linked to data-types, filename conventions, etc.

  • binary (bool) – Whether the run belongs to a binary grid.

  • verbose (bool) – If True, it prints reports of performed actions.

  • verbose_maxlines (int) – In case of verbose=True, it sets the maximum number of lines of metadata files to be printed. If None, all lines will be printed. If 0, nothing will be printed.

read_posydon_format()[source]

Read run structure, expecting the POSYDON collaboration format.

report()[source]

Report what data or metadata were found.

posydon.grids.io.initial_values_from_dirname(mesa_dir)[source]

Use the name of the directory for inferring the main initial values.

posydon.grids.io.print_meta_contents(path, max_lines=None, max_chars_per_line=80)[source]

Print parts of metadata files for inspection.

Parameters:
  • path (str) – Path of file containing the metadata.

  • max_lines (int or None) – Maximum number of lines to print. If None (default), print all of them.

  • max_chars_per_line (int or "warp") – If integer, it is the maximum number of character to be printed (e.g., useful when printing MESA output). If “warp”, no truncation.

posydon.grids.io.read_initial_values(mesa_dir)[source]

Read grid point values given the MESA run directory.

posydon.grids.post_processing

Module for post-processing POSYDON grids.

posydon.grids.post_processing.add_post_processed_quantities(grid, MESA_dirs_EXTRA_COLUMNS, EXTRA_COLUMNS, verbose=False)[source]

Append post processed quantity to a grid.

This function appends the quantities computed in post_process_grid to any grid. Note that this function ensure you can append the quantities only if the grid follows the order of MESA_dirs_EXTRA_COLUMNS.

Parameters:
  • grid (PSyGrid) – MESA grid in PSyGrid format.

  • MESA_dirs (list) – List containing the path to each run corresponding to the post processed values. This is used to ensure one to one mapping when appending the extra columns back to a grid.

  • EXTRA_COLUMNS (dict) – Dictionary containing all post processe quantities.

  • verbose (bool) – If True print on screen the results of each core collpase.

posydon.grids.post_processing.assign_core_collapse_quantities_none(EXTRA_COLUMNS, star_i, MODEL_NAME=None)[source]

“Assign None values to all core collapse properties.

posydon.grids.post_processing.post_process_grid(grid, index=None, star_2_CO=True, MODELS=MODELS, single_star=False, verbose=False)[source]

Compute post processed quantity of any grid.

This function post process any supported grid and computes: - Core collpase quantities for 5 prescritions given the fiducial POSYDON assumption given in MODEL plus:

A: direct collapse B: Fryer+12-rapid C: Fryer+12-delayed D: Sukhbold+16-engine, N20 E: Patton&Sukhbold20-engine, N20 for each prescrition we store the compact object state (WD/NS/BH), SN type (WD, ECSN, CCSN, PISN, PPISN), fallback mass fraction f_gb, compact object mass and spin.

  • Core masses at he-depletion (used in Patton core collpase)

  • Mass envelopes for common ennvelope step.

Parameters:
  • grid (PSyGrid) – MESA gri in PSyGrid format.

  • index (None, touple or int) – If None, loop over all indicies otherwise provide a range, e.g. [10,20] or a index, e.g. 42.

  • star_2_CO (bool) – If ‘False’ star 2 is not a compact object.

  • MODELS (list of dict) – List of supported core collapse model assumptions.

  • single_star (bool) – If True the PSyGrid contains single stars.

  • verbose (bool) – If True print on screen the results of each core collpase.

Returns:

  • MESA_dirs (list) – List containing the path to each run corresponding to the post processed values. This is used to ensure one to one mapping when appending the extra columns back to a grid.

  • EXTRA_COLUMNS (dict) – Dictionary containing all post processe quantities.

posydon.grids.post_processing.print_CC_quantities(EXTRA_COLUMNS, star, MODEL_NAME=None)[source]

posydon.grids.psygrid

Module defining the PSyGrid, the main grid object of POSYDON.

I. CREATING A GRID

  1. One-liner for creating a grid without loading it in memory:

    mygrid = PSyGrid(verbose=True).create(“mysimulations/”, “mygrids/grid1.h5”)

  2. Create a grid and keep it for processing:

    mygrid = PSyGrid() mygrid.create(“MESA_simulations/ZAMS_grid/”, “stored_grids/ZAMS_grid.h5”) print(mygrid)

  3. Store only metadata and initial/final values of runs:

    mygrid = PSyGrid().create(in_dir_path, out_file_path, slim=True)

  4. Various options (see definition of create and GRIDPROPERTIES for more):

    mygrid = PSyGrid().create(in_dir_path, out_file_path,

    overwrite=True, warn=”suppress”, max_number_of_runs=1000, description=”My 1000-run grid.”)

    NOTE: you can use a family of HDF5 files in case of file size restrictions. For example, using mygrid.h5.%d for the path when creating/loading grids, implied that split files will be mygrid.h5.0, mygrid.h5.1, and so on. When overwriting the file, all the family is overwritten (effectively, the files are emptied to avoid remainder split files from previous operations.)

  5. The history/profile data can be downsampled to significantly reduce the size of the grid. There are three downsampling procedures: one combining all data from histories (binary / star 1 / star 2), and two for each star’s profile. The parameters of the downsampling of histories and profiles can be set via the GRIDPROPERTIES dictionary (see below). For example, for history down- sampling, you can set a tolerance level (between 0 and 1) which corresponds to the maximum interpolation error tolerated with respect to the range of the parameters:

    history_DS_error = 0.01.

    Columns to be ignored during the downsampling process are set using the history_DS_exclude parameter. The corresponding parameters for profile

    downsampling are profile_DS_error and profile_DS_exclude.

  6. The input path can be a list of paths to indicate multiple folders with MESA runs. Each of the paths can have wildcard characters to select subfolders or even runs. E.g.: - [“/grid_part1”, “/grid_part2”] - “/grid_part*” - [“/grid/run1”, “/grid/run2*”]

    Note that all provided paths are searched recursively, allowing for hierar- chical organizations of the MESA runs. For example, the parent folder could look like this:

    part_A/

    run1/ run2/

    part_B/

    run3/ run4/

    extra_run1/ extra_run2/

  7. Only one run can be included for a specific set of initial parameters, being identified by the folder name (excluding the _grid_index* part). E.g.,

    reruns/m1_28_m2_11_initial_z_1.42e-02_initial_period_in_days_2_grid_index_0

    will be preferred over

    main/m1_28_m2_11_initial_z_1.42e-02_initial_period_in_days_2_grid_index_102

    if the PSyGrid is created with the appropriate order of input paths:

    mygrid = PSyGrid([“mygrid/main”, “mygrid/reruns”])

    The user is notified through warnings about such substitutions.

  8. To include specific columns from MESA data files, set the grid properties of the form *_saved_columns. For example,

    grid.create(“mygrid/”, “mygrid.h5”,

    star1_history_saved_columns=[“star_mass”])

    By default, the provided columns will be added to the default list. In order to select the exact set of columns, provide them in a tuple instead of list.

II. READING DATA FROM GRID

mygrid = PSyGrid(“thegrid.h5”) # opens a stored grid

# Indexing… t1 = mygrid[0][“binary_history”][“age”] t3 = mygrid[0].binary_history[“age”]

tenth_run = mygrid[10] if tenth_run[“binary_history”] is None:

print(“No binary history in 10th run.”)

Use .close() method to close the HDF5 file, or delete the grid variable. E.g.

mygrid.close()

or

del mygrid

III. OTHER FUNCTIONS

  1. Printing / logging summary:

    print(mygrid)

    with open(“grid_summary.txt”, “w”) as f:

    f.write(str(mygrid))

  2. In for loop (iter and next are supported too):

    for run in mygrid:

    print(run)

  3. Getting number of runs:

    n_runs = len(psygrid)

  4. Checking if run index is defined in grid:

    if (13 in grid):

    print(“My good luck lasted for”, grid[13].binary_history.age[-1], “yr”)

  5. Getting list or set of runs (i.e., PSyGridView objects):

    run_lst = list(psygrid) run_set = set(psygrid)

  6. Printing parameters used during the creation of the grid

    print(psygrid.config)

WARNING: reducing reading times when accessing a PSyGrid

When accessing a table in a specific run, e.g.,

mygrid[0].history1

or

for run in mygrid:

do_something_with(run.history1)

the table is loaded from the HDF5 file temporarily. This means that:

myrun.history1.star_mass + myrun.history1.star_mass

loads the table two times! To reduce reading times, store in local variables all the tables that are going to be needed more than once:

myhistory1 = myrun.history1 myhistory1.star_mass + myhistory1.star_mass

class posydon.grids.psygrid.PSyGrid(filepath=None, verbose=False)[source]

Bases: object

Class handling a grid of MESA runs encoded in HDF5 format.

Initialize the PSyGrid, and if filename is provided, open it.

Parameters:
  • verbose (bool) – If True, the objects reports by printing to standard output.

  • path (str or None) – If not None, it is the path of the HDF5 file to be loaded.

HR(idx, history='history1', states=False, verbose=False, **kwargs)[source]

Plot the HR diagram of one or more runs.

Parameters:
  • idx (int or list of int) – Index or indices of runs to plot.

  • history (str) – Which history is going to be used. The options are: “binary_history”, “history1”, or “history2”.

  • states (bool) – If true the HR diagram shows the stellar state with a color map.

  • verbose (bool) – If True, the object reports by printing to standard output.

  • **kwargs (dict) – Dictionary containing extra visualisation options (cf. PLOT_PROPERTIES in plot_defaults.py).

add_column(colname, array, where='final_values', overwrite=True)[source]

Add a new numerical column in the final values array.

close()[source]

Close the HDF5 file if open.

create(MESA_grid_path, psygrid_path=None, overwrite=False, slim=False, warn='end', fmt='posydon', **grid_kwargs)[source]

Create a new PSyGrid object from a MESA grid and save it on disk.

Parameters:
  • MESA_grid_path (str) – The path of the top directory where the input grid is located.

  • psygrid_path (str) – The path of the HDF5 file to be created (or overwritten). If not provided, it is assumed that it was defined during initialization.

  • overwrite (bool) – Whether to overwrite the HDF5 file if it already exists.

  • slim (bool) – If True, only the metadata and initial/final values are stored.

  • warn (str) – How warnings are handled. If “normal”, then warnings are shown when they occur. If “end”, they are collected and shown at the end. If “suppress”, then warnings are not shown at all.

  • **grid_kwargs (dict) – Configuration of the new grid, passed as ddditional arguments.

generate_config(**grid_kwargs)[source]

Store the grid’s configuration in a ConfigFile object.

get_pandas_initial_final()[source]

Convert the initial/final values into a single Pandas dataframe.

load(filepath=None)[source]

Load up a previously created PSyGrid object from an HDF5 file.

Parameters:

filepath (str) – Location of the HDF5 file to be loaded. If not provided, assume it was defined during the initialization (argument: filepath).

plot(idx, x_var_str, y_var_str, z_var_str=None, history='binary_history', verbose=False, **kwargs)[source]

Plot a 1D track of x_var_str vs y_var_str.

Parameters:
  • idx (int or list of int) – Index or indices of runs to plot.

  • x_var_str (str) – String of values to plot on the x axis. Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • y_var_str (str or list of str) – String or list of stringvalues to plot on the y axis. Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • z_var_str (str) – String of values to plot on the z axis (displayed with a color). Allowed strings are the one in psygrid.history.dtype.names where “history” needs to be chosen accordingly.

  • history (str) – The x, y, z variables are read from either: “binary_history”, “history1”, “history2”.

  • verbose (bool) – If True, the object reports by printing to standard output.

  • **kwargs (dict) – Dictionary containing extra visualisation options (cf. PLOT_PROPERTIES in plot_defaults.py).

plot2D(x_var_str, y_var_str, z_var_str=None, termination_flag='termination_flag_1', grid_3D=None, slice_3D_var_str=None, slice_3D_var_range=None, grid_4D=None, slice_4D_var_str=None, slice_4D_var_range=None, extra_grid=None, slice_at_RLO=False, MARKERS_COLORS_LEGENDS=None, max_cols=3, legend_pos=(3, 3), verbose=False, **kwargs)[source]

Plot a 2D slice of x_var_str vs y_var_str of one or more runs.

Parameters:
  • x_var_str (str) – String of the initial value to plot on the x axis. Allowed strings are psygrid.initial_values.dtype.names.

  • y_var_str (str) – String of the initial value to plot on the y axis. Allowed strings are psygrid.initial_values.dtype.names.

  • z_var_str (str) – String of the initial value to plot on the z axis (displayed as a color). Allowed strings are psygrid.final_values.dtype.names, psygrid.history1.dtype.names, psygrid.binary_history.dtype.names.

  • termination_flag (str) – Termination flag to display, allowed values are: “termination_flag_1”, “termination_flag_2”, “termination_flag_3”, “termination_flag_4”, “all”.

  • grid_3D (bool) – If True, the psygrid object is a 3D grid and needs to be sliced.

  • slice_3D_var_str (str) – Variable along which the 3D space will be sliced. Allowed values are psygrid.initial_values.dtype.names.

  • slice_3D_var_range (tuple or a list of tuples) – Range between which you want to slice the variable slice_3D_var_str e.g., (2.5,3.). In case of a list of tuples, one will get a large plot with one subplot for each tuple in the list.

  • grid_4D (bool) – If True, the psygrid object is a 4D grid and needs to be sliced.

  • slice_4D_var_str (str) – Variable along which the 4D space will be sliced. Allowed values are psygrid.initial_values.dtype.names.

  • slice_4D_var_range (tuple or a list of tuples) – Range between which you want to slice the variable slice_4D_var_str e.g., (2.5,3.). In case of a list of tuples, one will get a large plot with one subplot for each tuple in the list.

  • extra_grid (object or array of objects) – If subset of the grid was rerun a or an extention was added, one can overlay the new psygrid by passing it here.

  • slice_at_RLO (bool) – If True, the object plots the tracks until onset of Roche Lobe overflow.

  • MARKERS_COLORS_LEGENDS (dict) – Each termination flag is associated with a marker shape, size, color and label (cf. MARKERS_COLORS_LEGENDS in plot_defaults.py).

  • max_cols (int) – Defines the maximum number of columns of subplots. Default: 3

  • legend_pos (SubplotSpec (int or tuple)) – Defines which subplots won’t contain an axis but are used to display the legend there. Default: (3, 3)

  • verbose (bool) – If True, the object reports by printing to standard output.

  • **kwargs (dict) – Dictionary containing extra visualisation options (cf. PLOT_PROPERTIES in plot_defaults.py.

rerun(path_to_file='./', runs_to_rerun=None, termination_flags=None, new_mesa_flag=None, flags_to_check=None)[source]

Create a CSV file with the PSyGrid initial values to rerun.

This methods allows you to create a CSV file with the psygrid initial values you want to rerun.

Parameters:
  • path_to_file (str) – The path to the directory where the new grid.csv file will be saved. If the directory does not exist it will be created.

  • runs_to_rerun (list of integers) – Array containing the indecies of the psygrid runs you want to rerun e.g., runs_to_rerun = [2,3]

  • termination_flags (str or list of str) – The runs with this termination flag will be rerun. e.g. termination_flags=’max_number_retries’

  • new_mesa_flag (dict) – Dictionary of flags with their value to add as extra columns to the grid.csv. The user can specify any arbitrary amount of flags. e.g. new_mesa_flag = {‘varcontrol_target’: 0.01}

  • flags_to_check (str or list of str) – The key(s) of flags to check the termination_flags against. e.g. check_flags = ‘termination_flag_1’

update_final_values()[source]

Update the final values in the HDF5 file.

class posydon.grids.psygrid.PSyGridIterator(grid)[source]

Bases: object

Class for iterating runs (i.e., PSyRunView instances) in a PSyGrid.

Initialize by pointing to the PSyGrid object.

class posydon.grids.psygrid.PSyRunView(psygrid, run_index)[source]

Bases: object

Access runs in HDF5 grid without opening all data.

Example

mygrid = PSyGrid(“thegrid.h5”) # opens a stored grid myrun = mygrid[0] # get a “view” of the first run in the grid print(mygrid[1].history1.star_age)

t1 = myrun[“binary_history”][“age”] t2 = myrun[“binary_history”].age t3 = myrun.binary_history[“age”] t4 = myrun.binary_history.age

print(mygrid[1].history1.star_age)

Initialize by linking to a PSyGrid object and setting run index.

posydon.grids.psygrid.downsample_history(bh, h1, h2, params)[source]

Downsample history data of a run.

Parameters:
  • bh (record array) – The binary history table.

  • h1 (record array) – The history of star 1.

  • h2 (record array) – The history of star 2.

  • params (ConfigFile) – A ConfigFile instance holding the downsampling parameters.

Returns:

The three record arrays corresponding to the downsample binary, star 1, and star2 histories.

Return type:

tuple of record arrays

posydon.grids.psygrid.downsample_profile(profile, params)[source]

Downsample a profile table.

Parameters:
  • profile (record array) – The profile data with column names defined.

  • params (ConfigFile) – A ConfigFile instance holding the downsampling parameters.

Returns:

The downsampled profile.

Return type:

record array

posydon.grids.psygrid.join_grids(input_paths, output_path, compression='gzip9', description='joined', verbose=True)[source]

Join two or more PSyGrid HDF5 files into one.

posydon.grids.scrubbing

Methods for scrubbing MESA histories from backsteps etc.

posydon.grids.scrubbing.keep_after_RLO(bh, h1, h2)[source]

Scrub histories from the initial steps without RLO mass transfer.

Parameters:
  • bh (array) – The binary_history array.

  • h1 (array) – The history1 array.

  • h2 (array) – The history2 array.

Returns:

The binary, history1 and history2 arrays after removing the leading steps without RLO overflow mass transfer from star1 or star2. If an RLO phase is not detected, a warning is raised, and returns None.

Return type:

tuple or arrays, or None

posydon.grids.scrubbing.keep_till_central_abundance_He_C(bh, h1, h2, Ystop=1.0e-5, XCstop=1.0)[source]

Scrub histories to stop when central helium and carbon abundance are below the stopping criteria.

Parameters:
  • bh (array) – The binary_history array.

  • h1 (array) – The history1 array.

  • h2 (array) – The history2 array.

  • Ystop (float) – The He abundance threshold for stopping

  • XCstop (float) – The C abundance threshold for stopping

Returns:

The binary, history1 and history2 arrays after removing the final steps after He depletion. If the stopping criteria are not reached the histories will be returned unchanged.

Return type:

tuple

posydon.grids.scrubbing.scrub(tables, models, ages)[source]

Scrub binary and star histories of a MESA run in one go.

Parameters:
  • tables (list) – All history tables to be returned scrubbed.

  • models (list) – Model number columns corresponding to each table in tables.

  • ages (list) – Age columns corresponding to each table in tables.

Returns:

The list of scrubbed tables, ensuring monotonicity in age, and overlap in model numbers.

Return type:

list

posydon.grids.termination_flags

Module for computing termination flags of MESA runs.

There are four flags:

Flag 1: Indicates why the run terminated. Flag 2: Denotes the mass transfer phase(s) the system has gone through. Flag 3: Marks the evolutionary stage of the primary star. Flag 4: Marks the evolutionary stage of the seconary star.

The funtion get_flags_from_MESA_run is responsible for getting all flags for a run, using the more specialized functions defined in the module.

posydon.grids.termination_flags.check_state_from_history(history, mass, model_index=-1)[source]

Return the final state of the star from the star history data.

Parameters:
  • history (np.array) – MESA history of the star

  • model_index (int) – Index of the model in history for which the state will be computed. By default it is the end of the evolution (last model).

Returns:

state – The state of the star.

Return type:

str

posydon.grids.termination_flags.get_detected_initial_RLO(grid)[source]

Generates a list of already detected initial RLO

Parameters:
  • grid (a PSyGrid) – The grid to check.

  • Retruns

  • -------

  • list – A list containing systems already detected to be initial_MT based on termination_flag_1. For each system there is a dictionary with the impartant data, e.g. initial masses, periods, termination_flags

posydon.grids.termination_flags.get_flag_from_MESA_output(MESA_log_path)[source]

Return a flag about evolutionary outcome based on MESA output file.

Parameters:

MESA_log_path (string) – The output file of MESA.

Returns:

The termination flag inferred from the last line containing the strings min_timestep_limit, or termination code:, or Terminate:.

Return type:

str

posydon.grids.termination_flags.get_flags_from_MESA_run(MESA_log_path, binary_history=None, history1=None, history2=None, start_at_RLO=False, newTF1='')[source]

Return the four termination flags.

Parameters:
  • MESA_log_path (str) – path to the MESA terminal output

  • binary_history (np.array) – MESA output histories.

  • history1 (np.array) – MESA output histories.

  • history2 (np.array) – MESA output histories.

  • newTF1 (str) – replacement for the termination flag from the MESA output

Returns:

flag_MESAout, flag_mass_transfer, final_state_1, final_state_2 – flag_MESAout: actual line of MESA terminal output_path flag_mass_transfer: describes the mass transfer (e.g., case A, case B). final_state_1, final_state_2: describe the final evolutionary

state of the two stars. None if history star is not provided.

Return type:

str

posydon.grids.termination_flags.get_mass_transfer_flag(binary_history, history1, history2, start_at_RLO=False, mesa_flag=None)[source]

Read flag from MESA history.

In case of contact during MS, RLOF1, RLOF2 or no_RLOF.

Parameters:
  • binary_history (np.array) – The binary history file of MESA. Can also be the history of star 1 or 2 if binary history columns.

  • history1 (np.array) – The history file of MESA for star1.

  • history2 (np.array) – The history file of MESA for star2.

Returns:

flag_system_evolution_history – Possible flags are: “None”, “initial_RLOF”, “contact_during_MS”, “no_RLOF”, a cumulative MT flag, e.g, “case_A1/B1/A2” where the index indicates the donor star.

Return type:

string

posydon.grids.termination_flags.get_nearest_known_initial_RLO(mass1, mass2, known_initial_RLO)[source]
posydon.grids.termination_flags.infer_interpolation_class(tf1, tf2)[source]

Use the first two termination flags to infer the interpolation class.