Skip to content

mcdisplay-webgl(-classic): --simdir shows monitor data on the monitors - #3155

Merged
willend merged 8 commits into
mainfrom
mcdisplay-monitor-data
Nov 21, 2026
Merged

willend merged 8 commits into
mainfrom
mcdisplay-monitor-data

Conversation

@willend

@willend willend commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Free-form text area

Please describe what your PR is adding in terms of features or bugfixes:

Adds --simdir DIR to mcdisplay-webgl and mcdisplay-webgl-classic (McStas and McXtrace): the 1D/2D monitor data of a finished simulation is shown on the monitors in the 3D view. Also: monitor data and rays in the mctest displays, a cap on -n with room for SPLIT rays, a wrapping webgl top bar, and updated tool pages.

Monitor data (--simdir)

  • Read with the existing mccodelib.mcplotloader: mccode.sim, else NeXus mccode.h5 (first entry = first scan point); matched to components by name. Neither file: message and exit(-1).
  • Flat monitors: 2D data as a colour map on the drawn xy rectangle (first row at ymin, as in mcplot); 1D data as a curve, readable when looking along the beam.
  • Curved monitors: on a cylinder or sphere (PSDcyl_monitor, Monitor_nD banana/sphere, PSD_monitor_4PI): 2D data as a colour map, 1D data (e.g. a theta banana) as a curve along the angle. Radius from the monitor's drawing; recognised by the axis labels (Longitude / radial position / Latitude).
  • 1D curves are turned upright on monitors the instrument turns upside down (e.g. PSI_DMC's Detector, ROTATED (0, 0, 180)); 2D maps stay as placed.
  • Translucent like the other surfaces (classic: the Opacity slider; webgl: the component transparency); Surfaces/Lines do not hide the data.
  • Toggles 1D, 2D, curved (any curved monitor) and log, each shown only when there is such data. Log recolours in the browser (log10, zero/negative bins at a tenth of the smallest positive one, as mcplot --log).
  • Large monitors are shrunk for display to at most 256x256 (1D: 1024) bins by averaging neighbouring bins; output files are untouched. ~13-16 bytes/bin in the display, so at most ~1 MB per monitor (e.g. SOLEIL_PX1's 18M-bin Eiger).
  • Existing displays: a display directory from an earlier run can be given in place of the instrument; the data is added and the display shown, with no simulation (--nobrowse: only add). A display from the other webgl viewer gives a warning.

mctest

  • Adds the monitor data of test 1 (first scan point for a scan) to each instrument's display/, which the mctest report already links to. Only test 1, whose parameters the display was made with; errors are logged and do not affect the test result. Loader messages only with --verbose.
  • Runs mcdisplay with -n1e3, so the displays include rays (-n0 with --openacc).

Rays

  • mcdisplay lowers -n above 1000 particles to 1000, with a message. The trace reader keeps up to 1e5 rays (was 1000), room for SPLIT giving several rays per particle (the SPLIT trace change in cogen.c.in is not in this PR).

mcdisplay-webgl top bar

  • With all controls (e.g. rays shown) it no longer fits one line: it now wraps, and the 3D view starts below two lines (75 px, was 50). The dist/ bundle is rebuilt.

Docs

  • Tool pages mcdisplay.md and mctest.md brought in sync: -n cap, --campath, --simdir and display directories, monitor data, -t for pyqtgraph; mctest display with rays and monitor data, -j/--jobs, --nohtml, --verbose.

Example:

mcrun PSI_DMC.instr -n 1e7 -d sim -y
mcdisplay-webgl PSI_DMC.instr --simdir sim -y
mcdisplay-webgl-classic PSI_DMC_20261121_181652 --simdir sim

Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Further, please describe how / where and for what the tools were used: Claude Code (Claude Opus 5.5) wrote the code and ran the tests below, under my direction and review.
  • AI-assisted commits must carry a Co-Authored-By line naming the tool, see CONTRIBUTING.md

Development OS / boundary conditions

Please describe what OS you developed and tested your additions on, and if any special dependencies are required:

macOS (arm64), mccode-dev conda env. No new dependencies. Tested with 1e6–1e7 runs:

Monitor data

  • BNL_H8 (9 PSD monitors) and PSI_DMC (11 flat monitors + banana detector) in both viewers, compared side by side from the same tour camera position: same placement and pattern (webgl paler on its white background).
  • Orientation: an off-centre slit lights the +x/+y corner of a PSD monitor, as in mcplot.
  • A test instrument with PSDcyl_monitor, Monitor_nD banana (2D and 1D), PSD_monitor_4PI and Monitor_nD sphere and a beam at +40°, +10 cm: rays from the origin hit the maximum on each map at +40° and the minimum at −40° / −10 cm (PSDcyl one bin off, from its own (nr-1) binning).
  • PSI_DMC banana curve: peak positions match mcplot of detector.dat; strongest bin (71.8°) lands at 71.6° on the banana; upright from the sample in both viewers.
  • 1D/2D/curved toggles in both viewers on PSI_DMC (incl. an mctest display): each hides only its kind. Log: maps recoloured, identical linear pictures when switched off. No console errors.
  • A 2000x1500 PSD + 5000-bin L_monitor: shrunk to 250x250 / 1000, display 0.5 MB, orientation kept.
  • Existing display + --simdir on BNL_H8, classic and webgl (--nobrowse): 0 → 9 monitors with data; a display from the other viewer: warning, data added; no --simdir, or a directory that is not a display: message and exit -1; an instrument run with --simdir unchanged.

mctest

  • PSI_DMC, BNL_H8 and TAS1_Diff_Powder, text output and --nexus: all tests pass, displays get the monitor data, no loader messages without --verbose. BNL_H8 again after the later changes: display has 1000 rays and the monitor data.

Rays and top bar

  • -n5000 on BNL_H8: lowered to 1000 with the message. PSI_DMC with the coming SPLIT trace change: -n1000 gives 25 564 rays, all kept and played in the classic viewer (16.5 MB).
  • webgl top bar with rays shown at 800, 1280 and 1920 px: no button off screen; at 1280/1920 the bar is 70 px, above the view. Below ~1000 px it takes three lines and still covers the top of the view.

Not tested on Linux or Windows. Not tested: mctest with a scan as test 1, --verbose output, mctest -j > 1 with this step, --openacc displays, opening/serving an existing display (browser launch, webgl server).


PR Checklist for contributing to McStas/McXtrace

  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist

🤖 Generated with Claude Code

willend and others added 5 commits November 21, 2026 11:11
Reads the 1D/2D monitor data of a simulation output directory and paints
it on the monitors: a colour map (or a 1D curve) on flat monitors, a
colour map on cylinder, banana and sphere monitors. Translucent like the
other surfaces, with "Monitor data" and "curved" toggles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- log toggle in both viewers, recolouring in the browser
- maps shrunk to at most 256x256 (1D: 1024) bins, to keep displays small
- NeXus output (mccode.h5) read too
- mctest adds the monitor data of test 1 to the instrument display;
  loader messages only with --verbose

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test displays

- mcdisplay-webgl(-classic): show/hide 1D and 2D monitor data separately
- 1D data on curved monitors as a curve along the angle, not a colour band
- 1D curves upright on monitors turned upside down in the instrument
- mctest: mcdisplay with -n1e3 (-n0 with --openacc)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The controls no longer fit one line, e.g. with rays shown: the bar
wraps onto more lines and the 3D view starts below two of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-n above 1000 is lowered to 1000, with a message. The trace reader
keeps up to 1e5 rays (was 1000), room for SPLIT giving several rays
per particle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend

willend commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-11-21 at 19 39 29 Test video

The above are done with a patched cogen with a fix for the SPLIT-'return-artefac', see incoming PR

willend and others added 3 commits November 21, 2026 20:25
A display directory from an earlier run in place of the instrument:
the --simdir monitor data is added to it and it is shown, with no
simulation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mcdisplay: -n cap, --campath, --simdir and display directories, monitor
data, -t for pyqtgraph. mctest: display with rays and monitor data,
-j/--jobs, --nohtml, --verbose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend
willend merged commit b2ca213 into main Nov 21, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant