spectre.Visualization.ReadInputFile¶
Tools for parsing YAML input files
To simply read an input file as a dictionary, use a standard YAML parser like PyYAML or ruaml.yaml:
import yaml
with open(input_file_path) as open_input_file:
metadata, input_file = yaml.safe_load_all(open_input_file)
It’s also possible to load just the metadata without the overhead of parsing the full input file:
with open(input_file_path) as open_input_file:
metadata = next(yaml.safe_load_all(open_input_file))
The functions in this module provide additional functionality to work with input files.
Functions
|
Find a particular event in the given list of events of the input file. |
|
Find a particular phase change in the "PhaseChangeAndTriggers" |
- spectre.Visualization.ReadInputFile.find_event(event_name: str, events_and_triggers_name: str, input_file: dict) dict ¶
Find a particular event in the given list of events of the input file.
- Parameters:
event_name – The name of an event like “ObserveTimeSteps”.
events_and_triggers_name – The name of a list of events.
input_file – The input file read in as a dictionary.
Returns: The event as a dictionary, or None if the event wasn’t found.
- spectre.Visualization.ReadInputFile.find_phase_change(phase_change_name: str, input_file: dict) dict ¶
Find a particular phase change in the “PhaseChangeAndTriggers”
- Parameters:
phase_change_name – The name of a phase change like “CheckpointAndExitAfterWallclock”.
input_file – The input file read in as a dictionary.
- Returns: The phase change as a dictionary, or None if the phase change
wasn’t found.