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

path to the profile index file

Type:

str

index_data

dictionary containing all index data in numpy arrays.

Type:

dict

model_number_string

header name of the model number column in file_name

Type:

str

profile_number_string

header name of the profile number column in file_name

Type:

str

profile_numbers

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

Type:

numpy.ndarray

model_numbers

Sorted list of all available model numbers.

Type:

numpy.ndarray

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

model number to be checked for available profile number

Type:

int

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

profile number to be verified

Type:

int

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

profile number to be converted into a model number

Type:

int

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

model number to be converted into a profile number

Type:

int

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.

Reads the index file into per-column numpy arrays, keyed by MesaProfileIndex.index_names, sorted in order of increasing model number, and establishes the profile_numbers and model_numbers attributes. Called automatically at instantiation, but may be called again to refresh data.

Return type:

None