niess¶
Neutron instruments of the European Spallation Source, described once as calibrated Python objects, and emitted as whatever a downstream tool needs.
A McStas .instr file is a flat list of numbers. It says a guide is 2 metres long and
sits 1.5 metres from the moderator, but not that the 1.5 came from a survey, nor how to
move the guide without editing three other lines. It also says nothing a NeXus file
needs. niess keeps the calibration — measured quantities with units, positions
chained rather than repeated — and derives the rest:
flowchart LR
C[calibration<br/>scipp Variables] --> N[niess objects]
N --> M[McStas .instr]
N --> X[ESS NeXus<br/>Structure JSON]
N --> S[CAD / STEP]
Install¶
Two ways in¶
-
I have an instrument to describe
Turn a McStas model into a calibration-friendly submodule, or start a new one.
-
I have an instrument and need NeXus
Convert a niess instrument — or any
.instrfile — to ESS NeXus Structure JSON.
In sixty seconds¶
from mccode_antlr import Flavor
from mccode_antlr.assembler import Assembler
from niess.bifrost import Primary, Tank
from niess.bifrost.parameters import primary_parameters, tank_parameters
from niess.nexus import to_nexus_structure
from niess.nexus.bifrost import BIFROST_REGISTRY
assembler = Assembler('bifrost', flavor=Flavor.MCSTAS)
Primary.from_calibration(primary_parameters()).to_mccode(assembler)
Tank.from_calibration(tank_parameters()).to_mccode(assembler, 'sample_origin')
structure = to_nexus_structure(
assembler.instrument, origin='sample_origin', registry=BIFROST_REGISTRY,
)
BIFROST is the instrument that exists today; niess.teaching is a small worked example
written to be read, and is the subject of the guides.
Where to go next¶
- Install and first instrument — build and convert something end to end.
- Core concepts — components, sections, calibration and provenance, in one read.
- Components — every class, and the McStas component it emits.