Gamma-ray spectroscopy
Smooth a spectrum, count peaks, and estimate activity from a known gamma line.
Gamma-ray pulse-height spectra arrive as counts per channel. Answering “how many counts sit under this peak” needs a small pipeline: smooth the spectrum, delimit the peak window , and subtract the background. The demo below runs the verified crate passes over caller-supplied counts:
- E1 — rectangular smoothing with window width (odd, ):
smooth[i] = (1/m) * sum(counts[i-ext..=i+ext]) for ext <= i < N - ext,
with ext = (m - 1) / 2; edge channels are copied unchanged.
- E2 — five-point smoothing:
smooth[i] = (c[i-2] + c[i+2] + 2*c[i+1] + 2*c[i-1] + 3*c[i]) / 9
for 2 <= i < N - 2; the first and last two channels are copied.
- E3 — background under the peak (
m == 1only):
low = sum(counts[c1-2..c1]), high = sum(counts[c2..c2+2]), and
bg = (low + high) * (c2 - c1 + 1) / 6.
- E4 — gross counts:
gc = sum(counts[c1..c2]), half-open (channelc2is excluded). - E5 — net counts:
nc = gc - bg.
Smoothing and counting
Pick a smoother, set the peak window, then press Smooth spectrum.
The Oracle counts default replays
fixtures/spectroscopy/smooth_oracle.json ([2, 5, 1, 6, 3, 8, 4],
, — the worked example in the theory page), and
Synthetic peak loads hand-picked small numbers with one bump.
Channels are labelled positionally (0..N-1); counts must be finite and
non-negative.
Loading the live demo…
Gamma-line activity
Enter the signed net counts for a known full-energy peak, the standard uncertainty in those counts, and the acquisition live time. The absolute peak efficiency corresponds to your measurement geometry. Enter both the efficiency and emission probability as fractions.
Press Estimate activity to run the Rust calculation in the browser. The defaults use 120 net counts with a standard uncertainty of 12 counts, a live time of 60 s, an efficiency of 0.10, and an emission probability of 0.50. The estimate is 40 ± 4 Bq. A negative net count gives a signed estimate with the same nonnegative uncertainty. The displayed uncertainty comes from the supplied counts uncertainty alone.
TSV, calibration, and SPE readers
The sample tools below the activity form use built-in data. Parse TSV shows the decay-line energies and relative intensities. Calibrate shows the calibrated energy for each sample channel and the detector efficiency at 1 MeV. The SPE buttons show the spectrum name, detector ID, channel count, live time, and real time for the chosen format.
See also
- Tutorial: Run spectroscopy
- Theory: Gamma-ray spectroscopy
- Crate docs:
crates/spectroscopy/src/lib.rs