pysep.io.mod package¶
Submodules¶
pysep.io.mod.read module¶
Author: Thomas M. Boudreaux
Created: February 2022
Last Modified: February 2022
Module for reading binary model output
Functions¶
- get_card(FortranFile) -> Tuple[np.array, np.array]
Generator to yield the next model card from the binary model output of DSEP
- read_model_bin(str, bool[False]) -> Tuple[np.array, np.array]
Read in radial binary model output from wrtbinmod. Function trys to read next model card until teh scipy FortranEOFError exception is thrown at which point it assumes the end of file has been reached.
File must be the binary writen by wrtbinmod which is formated as a header followed by 6 arrays. All data in of type real*8. Booleans have been cast to either 0.0 (False) or 1.0 (True) with Fotran’s merge and int’s have been cast as real*8. A card is defined as a header followed by teh six arrays. Each card representats one model saved to the file.
The header is expected to be a 4 element real array containing JSON, DAGE, M, MODEL. The order of the 6 arrays is density, luminosity, pressure, radius, temperature, convective mask. Each of these arrays should be JSON long.
- pysep.io.mod.read.get_card(ff: scipy.io._fortran.FortranFile) Tuple[numpy.ndarray, numpy.ndarray] ¶
Generator to yield the next model card from the binary model output of DSEP
- Parameters
ff (FortranFile) – Fortran file (scipy) formated by DSEP wrtbinmod subroutine. File must be formated to include a header array, a density array, a luminosity array, a pressure array, a radius array, a temperature array, and a convective mask array
- Yields
header (np.array) – header which is meant to include model JSON, DAGE, M, MODEL)
rrun (np.array) – 6xJSON array with columns in order of density, luminosity, pressure, radius, temperature, convective mask
- pysep.io.mod.read.read_bin_mod(filename: str, verbose: bool = False) Tuple[numpy.ndarray, numpy.ndarray] ¶
Read in radial binary model output from wrtbinmod. Function trys to read next model card until teh scipy FortranEOFError exception is thrown at which point it assumes the end of file has been reached.
File must be the binary writen by wrtbinmod which is formated as a header followed by 6 arrays. All data in of type real*8. Booleans have been cast to either 0.0 (False) or 1.0 (True) with Fotran’s merge and int’s have been cast as real*8. A card is defined as a header followed by teh six arrays. Each card representats one model saved to the file.
The header is expected to be a 4 element real array containing JSON, DAGE, M, MODEL. The order of the 6 arrays is density, luminosity, pressure, radius, temperature, convective mask. Each of these arrays should be JSON long.
- Parameters
filename (str) – Path to binmod file (unit 31 in DSEP)
verbose (bool, default = False) – Flag to control verbose output. If true EOF statement will be written to standard output when end of file is reached.
- Returns
headers (np.array) – header array. One header for every card (which will be every NBN models (this is in the control namelist)) written out by DSEP
cards (np.array) – d,l,p,r,t,c array of length 6xJSON. Each parameter runs the radius of the star with the 0th index be the inmost and the -1st index being the outermost
Examples
Given some file called “m100OPALZsolarPhx.binmod” that file can be read as
>>> headers, cards = read_model_bin("m100OPALZsolarPhx.binmod")
You could then extract the run of age from the header by
>>> cardAges = headers[:, 1]
Or you could get the convective mask, for use in a Kippenham diagram, for the star (boolean describing if a shell is convective over radius and age) with
>>> convectiveMask = cards[:, 5, :]