mcstasscript.instr_reader.control.InstrumentReader
mcstasscript.instr_reader.control.InstrumentReader¶
- class mcstasscript.instr_reader.control.InstrumentReader(filename)¶
This class controls loading of a McStas file as a McStasScript object.
This is done by reading the McStas file line by line while using the McStasScript API to load the information into the Instr object.
Optionally a Python file with the McStasScript commands required to replicate the McStas instrument can be written to disk.
- __init__(filename)¶
Initializes reading of McStas instrument with given filename
- generate_py_version(product_filename)¶
Generates a file named product_filename.py that recreates instr
- add_to_instr(Instr)¶
Inserts information from instr file into McStasScript Instr instance
- __init__(filename)¶
Initialize the InstrumentReader with a target McStas instrument file. Use generate_py_version method for writing an eqvivalent McStasScript python file or the add_to_instr method to load this instrument file onto a Instr McStasScript object.
Methods
__init__
(filename)Initialize the InstrumentReader with a target McStas instrument file.
add_to_instr
(Instr)Add contents of McStas instrument file selected in initialize to an McStasScript instrument object.
generate_py_version
(product_filename)Generate a McStasScript version of the instrument file used for initialize of the InstrumentReader object.
Updates filename for reader subclasses
- add_to_instr(Instr)¶
Add contents of McStas instrument file selected in initialize to an McStasScript instrument object.
- generate_py_version(product_filename)¶
Generate a McStasScript version of the instrument file used for initialize of the InstrumentReader object. The filename given is for the generated file.
One should use this feature with some caution. Look through the generated McStasScript file and compare some output with the original insturment file to ensure everything was loaded correctly.
- update_file_name()¶
Updates filename for reader subclasses