Export simulator object to a JSON file
sim_coesite is a Simulator object.
By default, the attribute values are serialized as physical quantities, represented
as a string with a value and a unit.
Load simulator object from a JSON file
>>> from mrsimulator import Simulator >>> sim_load = Simulator.load('sample.mrsim') >>> sim_coesite == sim_load True
Spin systems objects from Simulator class¶
Export spin systems to a JSON file
Import spin systems from a JSON file
Importing spin systems from URL
>>> from mrsimulator import Simulator >>> sim = Simulator() >>> filename = 'https://raw.githubusercontent.com/DeepanshS/mrsimulator-examples/master/spin_systems.json' >>> sim.load_spin_systems(filename) >>> # The seven spin systems from the file are added to the sim object. >>> len(sim.spin_systems) 7
Method objects from Simulator class¶
Export methods to a JSON file
Import methods from a JSON file
Likewise, to import methods, use
Serialize simulation object from Method class as CSDM compliant file¶
Export simulation to a JSON file
You may serialize the simulation object from the method object to a CSDM compliant JSON file using the save function as follows,
Serialize Simulator, SignalProcessor object to file¶
Export Simulator, SignalProcessor objects to a JSON file
You may serialize the Simulator, a list of SignalProcessor objects to a .mrsim file as follows. The order of SignalProcessor objects is the order of the methods in the Simulator object.
>>> from mrsimulator import save >>> save('coesite.mrsim', sim_coesite, processors)
Load Simulator, SignalProcessor objects from a JSON file
>>> from mrsimulator import load >>> sim_coesite, processors, _ = load('coesite.mrsim')