tof.Model#
- class tof.Model(source=None, choppers=None, detectors=None)[source]#
A class that represents a neutron instrument. It is defined by a list of choppers, a list of detectors, and a source.
- Parameters:
Methods
__init__([source, choppers, detectors])add(component)Add a component to the instrument.
as_json()Return the model as a JSON-serializable dictionary.
from_json(filename)Create a model from a JSON file.
remove(name)Remove a component.
run()Run the simulation.
to_json(filename)Save the model to a JSON file.
- add(component)[source]#
Add a component to the instrument. Component names must be unique across choppers and detectors.
- Parameters:
component – A chopper or detector.
- as_json()[source]#
Return the model as a JSON-serializable dictionary. If the source is not from a facility, it is not included in the output.
- Return type:
- classmethod from_json(filename)[source]#
Create a model from a JSON file.
Currently, only sources from facilities are supported when loading from JSON.