Converting instrument files#
The .instr suffix is shared by McStas and McXtrace, so select the
appropriate conversion function explicitly. For McStas, use the
mcstas-pygen command supplied with McStas:
import mcstasscript as ms
instrument = ms.mcstas_pygen("my_instrument.instr")
For McXtrace, use the corresponding mcxtrace-pygen command:
instrument = ms.mcxtrace_pygen("my_instrument.instr")
The generated file is written next to the input file as
my_instrument_generated.py. Use destination to choose a generated
Python file or an existing destination directory:
instrument = ms.mcstas_pygen(
"my_instrument.instr",
destination="generated/my_instrument.py",
)
The optional input_path is passed to the generated make function and
sets the work directory used by the returned instrument:
instrument = ms.mcstas_pygen(
"my_instrument.instr",
input_path="path/to/components",
)
The input directory must exist, as must the parent directory of a custom
destination. The selected McStas or McXtrace installation must provide its
corresponding *-pygen executable on the system PATH.
- mcstasscript.mcstas_pygen(filename: str | PathLike, destination: str | PathLike | None = None, input_path: str | PathLike | None = None) Any#
Generate and return a McStas instrument from a
.instrfile.This uses the
mcstas-pygenexecutable and returns the McStas instrument generated by that command.destinationselects the generated Python file, or an existing directory in which<instrument>_generated.pyis written.input_pathis passed to the generatedmakefunction and must name an existing directory.
- mcstasscript.mcxtrace_pygen(filename: str | PathLike, destination: str | PathLike | None = None, input_path: str | PathLike | None = None) Any#
Generate and return a McXtrace instrument from a
.instrfile.This uses the
mcxtrace-pygenexecutable and returns the McXtrace instrument generated by that command.destinationselects the generated Python file, or an existing directory in which<instrument>_generated.pyis written.input_pathis passed to the generatedmakefunction and must name an existing directory.