Analytic chopper timing: use the experiment and pulse delays, not the total delay

Aperta
#803 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Start in ess.reduce.nexus.workflow.to_disk_choppers, where each chopper goes to scippneutron.chopper.DiskChopper.from_nexus, and see how delay becomes the phase. Read the issue's open points first, since the timing reference (event14 vs NiSync) and the meaning of mechanical_delay are unresolved. Done would mean the timing uses experiment_delay and pulse_delay when present, is checked against the three geometries in both rotation directions, and files without experiment_delay are unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Now

ess.reduce.nexus.workflow.to_disk_choppers passes each chopper to scippneutron.chopper.DiskChopper.from_nexus. That uses phase if present, and otherwise φ = 2π·f·delay, and applies φ to slit_edges measured from TDC. top_dead_center is not used.

What ESS choppers write

ECDC's BIFROST NeXus template (0.3.0, nexus-json-templates MR !314, now merged) logs four delays for each chopper. The definitions are from ECDC's Confluence page "Choppers":

NeXus field PV units definition
delay TotDly ns the total, computed from the three below; the timing event that the drive phase-locks its TDC to
experiment_delay ChopDly-S ns "Phase of the disc, used to configure the mode (which wavelengths get through)"; set by the instrument team through NICOS, and the only one changed during an experiment
mechanical_delay MechDly-S deg "Angle between the TDC and the centre of the reference opening of the disc"; measured by the chopper group with a park scan or laser, otherwise with neutrons during hot commissioning. The IOC fills it per speed from a lookup table keyed on |speed|, because the drive lag grows with speed
pulse_delay BeamPosDly-S ns "Shifts the cascade relative to T0 (proton on target) to match the neutron pulse", e.g. 10 000 ns on every disc so they share one t0; set by the instrument team; fixed during an experiment

The total, in ns, is TotDly = MechDly/360/|Spd_S|·1e9 + BeamPosDly + ChopDly. That is,

delay = mechanical_delay/(360°·|f_set|) + pulse_delay + experiment_delay.

The intent, in the page's words: "with MechDly set correctly and BeamPosDly = ChopDly = 0, every disc in the cascade has the centre of its reference opening on the beam at the same moment". pulse_delay then moves them together to match the neutron pulse, and experiment_delay selects the wavelengths. So each disc's reference opening has its centre on the beam at ref + pulse_delay + experiment_delay, where ref is the timing event the choppers count from (see Open points).

The problem

The mechanical delay has two parts. The geometric part is the angle from the TDC to the reference opening, which follows from the TDC resolver position, the angle at which the disc parks with the opening centred on the guide, and the direction the resolver counts. The lag, a few degrees (5–8° on the drives measured so far), grows with speed and depends on the direction of rotation. Both are measured per chopper, and they change after maintenance.

from_nexus applies the full delay, mechanical part included, to slit_edges and beam_position. The page defines beam_position = c + k·(tdc − park_open) (mod 360), with c the centre of the reference opening, so the geometric part is meant to be in the file. The computed timing is then right only if:

  • beam_position was filled from the same park scan that set mechanical_delay, and updated with it after maintenance. If it is missing, reduction assumes 0, and a 14 Hz disc "can then come out several milliseconds off";
  • the lag is negligible. It is in mechanical_delay but in no geometric field: 6° is 1.2 ms at 14 Hz.

Proposal

When experiment_delay is present, define the timing by the centre of the disc's reference opening instead of by TDC. This is the point mechanical_delay is measured to. The reference opening is the one that starts at slit_edges[0]: NeXus requires the first edge to be an opening edge, and ESS's NeXus configuration puts it at 0.

  • θ_c = (slit_edges[0] + slit_edges[1])/2.
  • t_ref = pulse_delay + experiment_delay is when θ_c is on the beam.
  • Set φ = 2π·f·t_ref + θ_c − θ̃ (mod 2π), where θ̃ is beam_position and f is the NeXus-signed rotation_speed (SpdNexus-R).

Every other edge then follows from its angle to θ_c: an edge at θ is on the beam at t_ref + (θ_c − θ)/(2π·f), modulo the rotation period. Neither the position of TDC on the disc, nor beam_position, nor the drive lag enters the timing. Only the slit edges relative to each other and the two delays do. A geometry with beam_position 180° and edges centred on it gives the same timing as one with edges starting at 0° and beam_position 0°, as long as both describe the same slit.

The reference opening's centre is on the beam at t_ref whichever way the disc turns, and the opening spans t_ref ± w/(2·2π|f|) for an opening w wide. Files without experiment_delay keep today's behaviour.

I checked the formula with scippneutron 26.9.1's DiskChopper. The cases were four geometries (one with three slits), both directions of rotation, discs at half, once and twice the pulse frequency, and several values of t_ref. In every case the midpoint of time_offset_open and time_offset_close for the reference opening is t_ref, modulo the rotation period.

This could live in to_disk_choppers, or in from_nexus, or be selectable by a workflow parameter if other facilities combine their delays differently.

Open points

  • The timing reference. ESS has two 14 Hz timing events with a fixed relationship. event14 is the site-wide reference. event16, also called NiSync, is proton-on-target, 6503 µs after event14. ESS-5914805 says "the current plan is to use NiSync for timing NSS choppers and detectors instead of event14". BIFROST requires NiSync for both, which is to be verified during hot commissioning. event_time_offset and the chopper delays are then both measured from proton-on-target, so:
    • the default SourceBounds (pulse at 0–5 ms) is right;
    • pulse_delay is the small t0 adjustment it is documented as, and belongs in t_ref. If commissioning finds that either side uses event14 instead, the 6503 µs would have to be added to the source or to the chopper phase.
  • A measured alternative. The top_dead_center timestamps record when the real sensor fires. EPICS publishes them relative to the latest reference event, and the forwarder adds a reference time back, ideally the same one. The drive locks the sensor to ref + delay, so ((TDC − ref) mod T) − mechanical_delay/(360°·|f|) is the realised t_ref. Here T is the rotation period, which divides the 71.43 ms reference period, so taking it modulo T works whichever reference time the forwarder added. If a chopper were timed from event14 instead of NiSync, this would show it as a constant 6503 µs shift. Its median over a run checks the set points, or replaces them when a chopper is off its set point. Its spread is the phase jitter.
  • The reference opening on a disc with several slits. The Confluence page measures mechanical_delay to "the reference opening" without saying which one it is. This proposal takes the opening that starts at slit_edges[0]. That is worth confirming with the chopper group for each multi-slit disc, since a different choice shifts the timing by the angle between the two openings' centres.
Lingua principale
Python
Stelle
3
Fork
6
Merge medio
2g 13h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scipp/ess

Tutte le issue di scipp/ess

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.