MesaProfileIndex

MesaProfileIndex is a class that gives rudimentary access to the relationship between profiles and model numbers typically stored in profiles.index. This is mostly used on the backend of MesaLogDir to easily find profiles, but it can also be used on its own.

class mesa_reader.MesaProfileIndex(file_name='./LOGS/profiles.index')[source]

Structure containing data from the profile index from MESA output.

Reads in data from profile index file from MESA, allowing a mapping from profile number to model number and vice versa. Mostly accessed via the MesaLogDir class.

Parameters:file_name (str, optional) – Path to the profile index file to be read in. Default is ‘LOGS/profiles.index’, which should work when the working directory is a standard work directory and the logs directory is of the default name.
file_name

str – path to the profile index file

index_data

dict – dictionary containing all index data in numpy arrays.

model_number_string

str – header name of the model number column in file_name

profile_number_string

str – header name of the profile number column in file_name

profile_numbers

numpy.ndarray – List of all available profile numbers in order of their corresponding model numbers (i.e. time-order).

model_numbers

numpy.ndarray – Sorted list of all available model numbers.

data(key)[source]

Access index data and return array of column corresponding to key.

Parameters:key (str) – Name of column to be returned. Likely choices are ‘model_numbers’, ‘profile_numbers’, or ‘priorities’.
Returns:Array containing the data requested.
Return type:numpy.ndarray
Raises:KeyError – If input key is not a valid column header name.
have_profile_with_model_number(model_number)[source]

Determines if given model_number has a matching profile number.

model_number

int – model number to be checked for available profile number

Returns:True if model_number has a corresponding profile number. False otherwise.
Return type:bool
have_profile_with_profile_number(profile_number)[source]

Determines if given profile_number is a valid profile number.

profile_number

int – profile number to be verified

Returns:True if profile_number has a corresponding entry in the index. False otherwise.
Return type:bool
model_with_profile_number(profile_number)[source]

Converts a profile number to a profile number if possible.

If profile_number has a corresponding model number in the index, returns it. Otherwise throws an error.

profile_number

int – profile number to be converted into a model number

Returns:model number corresponding to profile_number
Return type:int
Raises:ProfileError – If no model number can be found that corresponds to profile_number
profile_with_model_number(model_number)[source]

Converts a model number to a profile number if possible.

If model_number has a corresponding profile number in the index, returns it. Otherwise throws an error.

model_number

int – model number to be converted into a profile number

Returns:profile number corresponding to model_number
Return type:int
Raises:ProfileError – If no profile number can be found that corresponds to model_number
read_index()[source]

Read (or re-read) data from self.file_name.

Read the file into an numpy array, sorting the table in order of increasing model numbers and establishes the profile_numbers and model_numbers attributes. Converts data and names into a dictionary. Called automatically at instantiation, but may be called again to refresh data.

Returns:
Return type:None