Skip to content

ESRF id31 new detector default and Q plot in all SIXC reference frames - #66

Open
tifuchs wants to merge 11 commits into
masterfrom
esrf_id31_SIXC_Q_version
Open

ESRF id31 new detector default and Q plot in all SIXC reference frames#66
tifuchs wants to merge 11 commits into
masterfrom
esrf_id31_SIXC_Q_version

Conversation

@tifuchs

@tifuchs tifuchs commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Brings the ESRF ID31 beamtime work onto master, together with a reworked
experimental reciprocal-space (Q) display.

master is fully contained in this branch, so it merges without conflicts.

Breaking changes

  • HDF5 file locking is now disabled by default (HDF5_USE_FILE_LOCKING=False),
    so files still open for writing by the acquisition system can be read. A
    manually set environment variable still wins, and --hdflocking / -l
    restores the previous behaviour.
  • ID31-style scan objects are recognized from the configured backend class
    instead of a hardcoded list of beamtime ids. This fixes the id31_default_p4
    backend, which the old list did not cover, and makes new ID31 beamtimes work
    without code changes. Custom backends whose class name does not contain
    BlissScan are no longer treated as ID31-style even if their beamtime id was
    previously listed.

ID31 beamline support

  • BlissScan_EBS_p4 backend for the Pilatus4 detector, an example backend under
    examples/backend/ID31_EBS_p4_backend.py, and the ch8153 beamtime.
  • Default backend is now id31_default_p4; the fallback geometry describes a
    Pilatus4 4M CdTe. The manual backend selector now follows
    backends.default_beamtime instead of a second hardcoded default.
  • HDF5 files that are still being written can be refreshed from the GUI.
  • Maximum/sum images are untoggled when the image number changes, and their
    toolbar icons no longer get out of sync.

Experimental Q-plot

A Q-plot toolbar action displays the image in reciprocal space, with a
drop-down selecting the frame: Q_alpha (default), Q_lab, Q_omega,
Q_chi, Q_phi and Q_cryst. It lives in orgui.app.qconversion
deliberately in the application layer, not in orgui.datautils.xrayutils, so it
is not mistaken for production reciprocal-space code, and it is marked
experimental in the UI, the module and the docs.

Why it does not simply use pyFAI's fiber units. pyFAI's
sample_orientation is the EXIF dihedral group acting on the image array, so it
only spans quarter turns, whereas orGUI's azimuthal reference is continuous. An
implementation based on that flag is correct only at exact multiples of 90
degrees — at an azimuth of 45 degrees it is off by several inverse Angstrom. The
azimuth is therefore passed through tilt_angle, and because pyFAI composes the
incidence and tilt rotations about fixed axes while in orGUI the azimuth rotates
the alpha axis itself, orGUI supplies FiberIntegrator with its own
UnitFiber definitions. pyFAI still performs the rebinning.

Performance. The conversion collapses into a single affine relation and is
evaluated by a new pybind11 extension, _qconversion_cpp. A 6.2 megapixel
Pilatus 6M image converts in ~50 ms instead of ~740 ms, bit-exact against the
numpy reference; a numpy fallback is used when the extension is not built. The
pyFAI integrator is reused while the conversion is unchanged, so stepping
through images no longer resets it per image.

numexpr is deliberately not used: version 2.11.0 returns wrong results for a
small fraction of multi-threaded evaluations of this kind of expression
(reproducible with no orGUI code involved, ~3/200 evaluations).

Other GUI changes

  • The Q-plot stays switched on and is rebuilt when the image, the max/sum
    selection, the frame, the machine angles, the energy or the orientation matrix
    change.
  • The position readout shows HKL as one bracketed triplet and the momentum
    transfer of the selected frame as Q[alpha], Q[lab], … with five decimals.
    Field size hints are matched to their content so the triplets are not elided.
  • Fix: cancelling or resetting the machine parameter or crystal parameter
    dialog now restores the configuration that was active when the dialog opened.
    Both dialogs apply every edit immediately, so restoring the widgets alone left
    the discarded configuration active.

Testing

New tests cover the conversion against QAlpha per pixel for flat and tilted
detectors at azimuths that are deliberately not multiples of 90 degrees, that
Q_phi reproduces anglesToHkl and Q_cryst reproduces B·H, that the
compiled kernel matches the numpy fallback, the integrator cache does not serve
stale coordinates, and the dialog-cancel and readout behaviour.

Notes for reviewers

  • meson.build gains _qconversion_cpp, so a rebuild is needed for the fast
    path. Without it the numpy fallback runs automatically (~135 ms for 6 Mpixel).
  • The Q_omega frame is mathematically indistinguishable from `Q_

Finnjek and others added 11 commits June 29, 2026 16:31
for live data analysis and working with hdf5 files where new data is still added, the hdf5 locking must be turned off
As ESRF fastscans contain two separate hdf5 nodes, the data must be treated separately when loading a segmented scan. Requirement: class name includes 'BlissScan'
the max image or sum image are automatically deactivated when the user changes the image using the slider below the central plot
fix a bug that causes the Qt icon to be deactivated even though the max/sum image is shown in the central plot
this commit allows the refreshing of hdf5 files while new scans in the same dataset are still performed - without causing broken link errors at ESRF beamline id31
The Pilatus 4 4M detector is now set as default, the fallback geometry is more universal and the ch8153 beamtime has been added to the backend selection
using the pyFAI FiberIntegrator package, grazing incidence detector images can now easily be converted from pixel coordinates to their Q values in units of inverse Angstrom
Resolve conflicts in favour of master's formatting with the ID31 beamline changes re-applied. Add QAlpha/FiberIntegrator equivalence tests and document both reciprocal-space routes.
Make the reciprocal-space conversion exact for arbitrary azimuthal
references, use orGUI diffractometer conventions for single crystals
instead of the 2d FiberIntegrator.

- add the Q_alpha, Q_lab, Q_omega, Q_chi, Q_phi and Q_cryst frames with a
  selector next to the Q-plot action, defaulting to Q_alpha
- add the _qconversion_cpp extension, which converts a 6.2 megapixel
  Pilatus 6M image in ~50 ms instead of ~740 ms, with a numpy fallback
- reuse the pyFAI integrator while the conversion is unchanged, keyed on
  the collapsed conversion coefficients, so stepping through images no
  longer resets the integrator for every image
- keep the Q-plot switched on and rebuild it in place when the image, the
  max/sum selection, the frame, the machine angles, the energy or the
  orientation matrix change
- pass a legend rather than an image item to the alpha slider
- take the manual backend selection from backends.default_beamtime
@tifuchs
tifuchs requested a review from Finnjek July 30, 2026 00:36
@tifuchs tifuchs changed the title Esrf id31 sixc q version ESRF id31 new detector default and Q plot in all SIXC reference frames Jul 30, 2026
@tifuchs tifuchs added enhancement New feature or request Physics Issues related to physics labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Physics Issues related to physics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants