Mrsimulator IO¶
- mrsimulator.save(filename: str, simulator: mrsimulator.simulator.Simulator, signal_processors: Optional[List] = None, application: Optional[Dict] = None, with_units: bool = True)¶
Serialize the Simulator, list of SignalProcessor, and an application dict to a file. Creates a Mrsimulator object and calls save.
- Parameters
filename (str) – The data is serialized to this file.
sim – Simulator object.
signal_processors – A list of PostSimulator objects corresponding to the methods in the Simulator object. Default is None.
application – Dictionary holding metadata to serialize in the file. The dictionary will be held in the application key.
with_units (bool) – If true, physical quantities are represented as string with units. The default is True.
- mrsimulator.dict(simulator: mrsimulator.simulator.Simulator, signal_processors: Optional[List] = None, application: Optional[Dict] = None, with_units: bool = True)¶
Export the Simulator, list of SignalProcessor, and an application dict to a python dictionary. Creates a Mrsimulator object with given arguments and calls json from the Mrsimulator object.
- Parameters
sim – Simulator object.
signal_processors – A list of PostSimulator objects corresponding to the methods in the Simulator object. Default is None.
application – Dictionary holding metadata to serialize in the dict. The dictionary will be held under the application key.
with_units (bool) – If true, physical quantities are represented as string with units. The default is True.
- Returns
Python dictionary
- mrsimulator.load(filename: str, parse_units: bool = True)¶
Load Simulator object, list of SignalProcessor objects and metadata from a JSON serialized file of a
Mrsimulator
object.- Parameters
filename (str) – The location to the .mrsim file.
parse_units (bool) – If true, parse the dictionary for units. The default is True.
- Returns
Simulator, List[SignalProcessor], Dict.
- Return type
Ordered List
- mrsimulator.parse(py_dict, parse_units: bool = True)¶
Parse a dictionary object to the respective Simulator object, list of SignalProcessor objects, and the metadata dictionary. If no signal processors are provided a list of default SignalProcessor objects with length equal to number of methods will be returned.
- Parameters
py_dict (Dict) – Python dictionary representation of a
Mrsimulator
object.parse_units (bool) – If true, parse the dictionary for units. Default is True.
- Returns
Simulator, List[SignalProcessor], Dict.
- Return type
Ordered List