base_case_reader.py#

Base class for all CaseReaders.

class openmdao.recorders.base_case_reader.BaseCaseReader(filename, pre_load=False)[source]

Bases: object

Base class of all CaseReader implementations.

Parameters:
filenamestr

The path to the file containing the recorded data.

pre_loadbool

If True, load all the data into memory during initialization.

Attributes:
_format_versionint

The version of the format assumed when loading the file.

_openmdao_versionstr

The version of OpenMDAO used to generate the case recorder file.

problem_metadatadict

Metadata about the problem, including the system hierachy and connections.

solver_metadatadict

The solver options for each solver in the recorded model.

_system_optionsdict

Metadata about each system in the recorded model, including options and scaling factors.

__init__(filename, pre_load=False)[source]

Initialize.

get_case(case_id, recurse=True)[source]

Get case identified by case_id.

Parameters:
case_idstr or int

The unique identifier of the case to return or an index into all cases.

recursebool, optional

If True, will return all successors to the case as well.

Returns:
dict

The case identified by case_id.

get_cases(source, recurse=True, flat=False)[source]

Iterate over the cases.

Parameters:
source‘problem’, ‘driver’, component pathname, solver pathname, case_name

Identifies which cases to return.

recursebool, optional

If True, will enable iterating over all successors in case hierarchy.

flatbool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases identified by source.

list_cases(source=None, recurse=True, flat=True, out_stream=DEFAULT_OUT_STREAM)[source]

Iterate over Driver, Solver and System cases in order.

Parameters:
source‘problem’, ‘driver’, component pathname, solver pathname, case_name

If not None, only cases originating from the specified source or case are returned.

recursebool, optional

If True, will enable iterating over all successors in case hierarchy.

flatbool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
iterator or dict

An iterator or a nested dictionary of identified cases.

list_model_options(run_number=0, system=None, out_stream=DEFAULT_OUT_STREAM)[source]

List model options for the specified run.

Parameters:
run_numberint

Run_driver or run_model iteration to inspect.

systemstr or None

Pathname of system (None for all systems).

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{system: {key: val}}.

list_solver_options(run_number=0, solver=None, out_stream=DEFAULT_OUT_STREAM)[source]

List solver options for the specified run.

Parameters:
run_numberint

Run_driver or run_model iteration to inspect.

solverstr or None

Pathname of solver (None for all solvers).

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{solver: {key: val}}.

list_source_vars(source, out_stream=DEFAULT_OUT_STREAM)[source]

List of all inputs and outputs recorded by the specified source.

Parameters:
source{‘problem’, ‘driver’, <system hierarchy location>, <solver hierarchy location>}

Identifies the source for which to return information.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{‘inputs’:[key list], ‘outputs’:[key list], ‘residuals’:[key list]}. No recurse.

list_sources(out_stream=DEFAULT_OUT_STREAM)[source]

List of all the different recording sources for which there is recorded data.

Parameters:
out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
list
One or more of: problem, driver, <system hierarchy location>,

<solver hierarchy location>

property openmdao_version

Provide the version of OpenMDAO that was used to record this file.

Returns:
str

version of OpenMDAO that was used to record this file.