Repository navigation
Interactive Web Viewer
The cmat_webviewer.py server and companion cmat_webviewer.html client provide an ultra-responsive, browser-based GUI for exploring 2D
Run the server script from your terminal, pointing to one or more .cmat files:
# Open a single matrix
python cmat_webviewer.py /path/to/matrix.cmat
# Open multiple matrices
python cmat_webviewer.py run01.cmat run02.cmat run03.cmat
# Load all matrices in a folder
python cmat_webviewer.py ./data/*.cmatThe server binds to http://0.0.0.0:8080 (or the configured host/port) and automatically launches your default web browser.
When running inside WSL on Windows, launching native GUI applications via X11 can cause window-grab issues and slow rendering. cmat_webviewer leverages your host Windows browser directly for full hardware-accelerated WebGL/Canvas rendering.
To enable seamless browser launching from WSL, install wslu and configure BROWSER:
sudo apt update && sudo apt install wslu
echo 'export BROWSER=wslview' >> ~/.bashrc
source ~/.bashrcOnce configured, launching cmat_webviewer.py inside WSL will automatically open your default Windows browser.
When analyzing data stored on a remote Linux workstation or cluster via SSH:
The viewer prints the server's network address in the terminal upon startup (e.g. http://192.168.1.50:8080). Modern terminals (VS Code, Windows Terminal, iTerm2, GNOME Terminal) allow you to Ctrl+Click (or Cmd+Click on macOS) the URL to open the remote session in your local browser immediately.
When running inside an SSH session (detected via $SSH_CLIENT / $SSH_TTY), cmat_webviewer.py automatically suppresses launching headless or remote X11 browsers, keeping the SSH connection fast and lightweight.
If the remote machine is behind a firewall or lacks direct port exposure:
# Forward remote port 8080 to your local machine:
ssh -L 8080:localhost:8080 user@remote-server
# Run the viewer on the remote machine:
python3 cmat_webviewer.py matrix.cmatThen open http://localhost:8080 in your local browser.
- Renders matrices up to
$6144 \times 6144$ channels effortlessly by fetching only as many data points as screen pixels available. - 2D Max-Pooling: When zoomed out over large channel ranges, downsampling uses maximum-intensity pooling rather than naive averaging or nearest-neighbor interpolation. This ensures sharp, narrow gamma photopeaks never disappear at full zoom.
- Direct scale options: Logarithmic, Linear, and Power (
$\sqrt{N}$ ) scaling with real-time colormap mapping (Turbo, Viridis, Plasma, Inferno, Hot, Jet, Gray).
- Det 1 (X Projection): Slices the 2D matrix along the visible Y-window, showing total or gated counts vs. Det 1 energy.
- Det 2 (Y Projection): Slices the 2D matrix along the visible X-window, showing total or gated counts vs. Det 2 energy.
- Synchronized crosshair cursors: Moving the mouse in the 2D matrix updates highlighted crosshairs and channel/energy readouts simultaneously across both 1D panels.
- Stepped staircase rendering with dynamic Y-axis auto-scaling, calibrated keV readouts, and ASCII
.datexport.
- Press
M(or click theMenutoggle) to collapse the left control panel, maximizing matrix visualization space. - An interactive vertical divider bar allows click-and-drag resizing between the 2D matrix canvas and the 1D projection histograms (double-click the divider to reset to equal width).
Keyboard arrow keys automatically route actions based on which panel is under cursor focus:
-
1D Spectrum Focus:
-
←/→pans channels horizontally (Shiftfor 2× speed). -
↑/↓pans and magnifies the vertical counts scale.
-
-
2D Matrix Focus:
-
←/→/↓/↑sets Left, Right, Down, and Up limit markers at the crosshair. -
Shift + Arrowspans the 2D view.
-
Open multiple matrices simultaneously to perform comparative spectroscopy:
-
Instant Switching: Cycle between loaded matrices using the header dropdown or the
[and]bracket keys. -
Analysis State Locking: Switching matrices preserves:
- Viewport coordinates and zoom ranges
- Active coincidence gates (
$W$ ) and background subtractions ($X$ ), which are instantly re-evaluated against the new matrix - Active 1D single-peak and multiplet fits (automatically refitted with updated areas and FWHMs)
- Active 2D coincidence peak fits (refitted at identical coincidence coordinates)
- Visual contrast settings (
$V_{\max}$ ,$V_{\min}$ , colormap, scale mode)
Click 📂 Browse Server Matrices... in the header (or press Ctrl + O) to open the server-side file browser modal. You can navigate the remote directory structure, view file sizes and timestamps, filter files by keyword, and load .cmat matrices directly without typing paths.
Click Print PDF on the 2D matrix footer or either 1D projection header:
- Outputs standalone, vector PDFs rendered with classic publication typography (Times New Roman).
- Embeds energy-calibrated axes, stepped histogram paths, all active continuous fit curves, background baselines, labeled centroid pointers, 2D FWHM confidence ellipses, and unobtrusive 3-line fit summary labels.
python-cmat © 2026. Released under the MIT License. Return to GitHub Repository
Interactive 2D & 3D Matrix Analysis & Spectroscopy
- Home
- Interactive Web Viewer
- 3D Matrix Analysis & Web Viewer
- Keyboard Shortcuts & Controls
- ROOT Files & Live Histograms
- ENSDF Isotope Identification
- Spectroscopy Commands & Macros
- Configuration Guide
- Python API & CLI Tools