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.