Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document for new Instrument View #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions Design/InstrumentViewUpgrade/InstrumentViewUpgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Instrument View Overhaul

## Summary

For scientists and other users who use Instrument View this is a large overhaul and refactor of the Instrument View that will take advantage of modern technologies/visualisation libraries to re-write Instrument View from scratch to improve stability, add new features, and increase interface responsiveness, unlike leaving it as it is or refactoring existing the Instrument View, which would take longer as it is directly calling low-level OpenGL.

The work will ensure this key instrument visualisation tool can be maintained in the future and new features can be added more easily. In addition the interface will be able to handle larger data files such as those anticipated from Endeavour instruments.

## MVP

Basic functionality required for commissioning:

- Workbench will still be usable when loading data in instrument view (currently hangs on same thread)
- 2D and 3D visualisation of integrated intensities in instrument detectors within x-range (e.g. TOF or d-spacing) on instrument
- Table/read-out displaying nearest detector ID and position (XYZ, L2 two-theta etc.) to cursor
- 1D plot showing TOF (or d-spacing, wavelength etc.) spectrum of a selected pixel

## Full Scope

### Existing Features in Instrument View

- Peak overlay showing detector and HKL (support multiple peak tables)
- Measure angles between peaks or detector IDs
- Add/remove peaks from table
- Select ROI/grouping/masks and save to file
- Visualise mask/grouping to data
- Export curve from 1D plot to workspace, (keeping instrument geometry)
- HKL labels on 1D plots
- Show placement of other instrument components (e.g. sample position) in 3D
- Use of Instrument View in ALFView, Reflectometry, and SANS GUIs

### New Features

- Unit conversion in 1D plot and integration limits

## Nonfunctional Requirements

- Load WISH data set (20GB in RAM) in Instrument View in under 3s on IDAaaS environment with and without GPU
- Can load larger data files (e.g. WISH-II >80GB), and larger peak tables (potentially 1000s of peaks on WISH-II compared to 100s currently)
- New dependencies have to be compatible with mantid conda installation/packaging
- Possible to use Instrument View outside workbench with python binding

## Design

The existing Instrument View will not be changed or removed as part of the work in developing the new version. Only when the new versions has been tested and approved extensively will we consider replacing the current Instrument View.

### Structure

The new Instrument View (IV2) will follow the Model-View-Presenter (MVP) pattern. It will exist as a separate python module, altbeit with the code remaining inside the `mantid` repository to aid testing and integration. Mantid Workbench will then have a dependency on the IV2 module (it won't be called IV2).

A user will be able to import the IV2 module into a Jupyter Notebook and view the 3D view, potentially interactively.

Plotting the spectra for selected pixel(s) will be done using `matplotlib`, which will allow for substantial reuse of 2D plotting code.

The standalone IV2 window will be a Qt widget containing the 3D view, 2D projections and other interface components.

The IV2 interface will be able to be hosted inside C++ Qt widgets for compatibility with other interfaces that use the existing Instrument View.

### Language

IV2 will be developed entirely in Python, and make use of Python 3D plotting modules to handle any 3D drawing. This will aid extensibility, maintainability, and readibility of the code.

### Dependencies

Initial investigations are using `pyvista` for the 3D drawing, along with `pyvistaqt` for the Qt wrapper. This is because `pyvista` is already being used for at least one other `mantid` development, [NeuXtalViz](https://github.com/zjmorgan/NeuXtalViz), so ideally we would not want multiple Python 3D drawing modules as dependencies, one should suffice.

IV2 will depend on `mantid`, or more likely `mantidqt`, depending on requirements.

### Other Requirements

IV2 must be able to perform sufficiently quickly so as to make it usable for the large files that will be generated by WISH II and other future instruments.

As much existing code as possible will be reused, although a lot of the existing C++ drawing code will not be useful since it is OpenGL-specific.