pysep.io.trk package

Submodules

pysep.io.trk.read module

Author: Thomas M. Boudreaux

Created: February 2021

Last Modified: July 2021

Module for reading one or many track files

Functions

get_trk_metadata(str) -> dict

Use regular expressions to parse all of the metadata about a dsep evolutionary run out a line in a track file. That information inclues the mass, mixing lenght, EOS, ATM, and low temperature opacities. These are indexed as ‘Mass’, ‘Mixing Length’, ‘EOS’, ‘Atm’, and ‘Low T Opacities’.

libdsepio_read(str) -> np.ndarray

Call the function in the shared library libdsepio.so to read the entire track file. This is signifigantly faster than the parser I had written in python.

read_trk(str) -> Tuple[pandas.DataFrame, dict]

Read a dsep track file into a pandas dataframe and extract the meta data from the header of that track file.

load_trk_models(str) -> Tuple[List[pandas.DataFrame], list[dict]]

Read all track files in a directory and load their dataframes and metadata into two lists

pysep.io.trk.read.get_trk_metadata(line: str) dict

Parse metadata from line in dsep track file using regular expressions.

Parameters

line (str) – line from track file with approporate meta data in line

Returns

meta – dictionary with meta data extracted from line. This is mass, mixing length, EOS, Atm, and low temperature opacities. These are indexed as ‘Mass’, ‘Mixing Length’, ‘EOS’, ‘Atm’, and ‘Low T Opacities’ respectivly.

Return type

dict

pysep.io.trk.read.libdsepio_read(fnames: list, totalEntries: int) list

Call the trk_read function from libdsepio to quickly load in track file.

Parameters
  • fnames (list of strings) – File paths to load in.

  • totalEntries (int) – The total number of float entried per record.

Returns

trks – list of Array in the proper shape (s, totalEntries) where s is the number of time steps dsep evolved over.

Return type

list of ndarrays

pysep.io.trk.read.load_trk_models(path: str) Tuple[list, list]

Sometimes you have a path with many track files and it would just be helpful to quickly read in all of them. Thats what load_track_models does. Given some path with a minimum of 1 track file this function wll load all track files contents and meta data into two lists of length n where n is the number of track files total.

Parameters

path (str) – path to directory which contains track files

Returns

  • trks (list of pandas.DataFrames) – list of dataframes, one data frame for every track file in path

  • metadatas (list of dicts) – List of dictionaries with meta data extracted from track file. This is mass, mixing length, EOS, Atm, and low temperature opacities. These are indexed as ‘Mass’, ‘Mixing Length’, ‘EOS’, ‘Atm’, and ‘Low T Opacities’ respectivly.

pysep.io.trk.utils module

Author: Martin Ying

Created: October 2021

Last Modified: October 2021

Convert a DSEP Track File to a MESA History file for use with Aaron Dotters isochrone code

TMB 10/21: Modifications made from original code to fit within pysep style guides and and data structures.

pysep.io.trk.utils.eformat(f, prec: int, exp_digits: int) str
pysep.io.trk.utils.trk_to_hist(trk_df: pandas.core.frame.DataFrame, outputPath: str = 'out.data') bool

Given some DSEP trk file convert it to a MESA history file. This allows DSEP models to me feed into Aarons Dotters isochrone code.

Parameters
  • trk_file (pandas.DataFrame) – trk file pandas dataframe generated by dsep and parsed using pysep

  • outputPath (str) – Path to save resultant file too

Returns

True if file is created okay, False otherwise

Return type

bool

Module contents

Submodule for handeling dsep track modules. This includes reading a single track file and reading a directory full of track files