Skip to content

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

pip install niess

Two ways in

In sixty seconds

from niess.bifrost import Primary, Tank
from niess.bifrost.parameters import primary_parameters, tank_parameters
from niess.instrument import Instrument, Mount
from niess.nexus import to_nexus_structure
from niess.nexus.bifrost import BIFROST_REGISTRY

bifrost = Instrument(name='bifrost', origin='sample_origin', parts=(
    Mount(name='primary', content=Primary.from_calibration(primary_parameters())),
    Mount(name='tank', content=Tank.from_calibration(tank_parameters()),
          relative_to='sample_origin'),
))

structure = to_nexus_structure(bifrost, 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