Skip to content

Getting started

Install

Requires Python 3.10 or later; 3.14 is recommended, and is what pyRUMP is tested on. Check your version with python3 --version, then install pyRUMP from PyPI:

pip install pyrump

numpy, scipy, and matplotlib are installed automatically, along with the physics data tables pyRUMP needs at runtime.

Quick start

pyrump                         # the interactive shell, from any directory

Data loading

pyRUMP reads RUMP's binary .rbs, RC43 acquisition macros, plain ASCII, and SIMNRA's .xnra files.

Anything ending in .rbs/.RBS might be one of two unrelated things: RUMP's own binary spectrum format, or a plain-text acquisition macro that just happens to share the extension. GET and XEQ load them, respectively — using the wrong one gets you a clear error rather than garbage data. See File formats in the manual for the full specification of both.

Example 1 — RUMP binary format (.rbs)

examples/2A.rbs is a real binary spectrum (Cornell format, mode-2 differential-compressed counts):

Your wish? cd examples
Your wish? get 2A.rbs
active buffer is now 1

GET decodes the file's records directly — calibration, geometry, accelerator settings and the 2048 channel counts all arrive in one call. The spectrum lands in buffer 1: in RUMP, buffer 1 is always "whatever was read most recently," not a fixed slot, and every other data buffer shifts up one to make room (buffer 0 is reserved for the simulation and is never touched by GET). Buffer 1 also becomes the active buffer, so PLOT, COMPARE, INTEGRAL and friends act on it right away:

Your wish? active
Buffer 1:
  File       2A.rbs
  Identifier Binghampton_target_02A.RBS  RBS LT =  905.98 RT  962.42
  ...
Your wish? plot 1

Example 2 — an acquisition macro under a .RBS extension

Some acquisition software (NEC's RC43 among them) writes its output as a plain-text EMPTY/SWALLOW command macro named something.RBS, despite the name suggesting real spectrum data. examples/MnPt.RBS is one of these — load it with XEQ, not GET:

Your wish? xeq MnPt.rbs
buffer 1 emptied
  c:\RBS\data\2022\01\MnPt.RBS
  MnPt.RBS  170 Degree RBS LT =  2457.874 RT  2463.078 Gain  2
  ...
2048 points entered into buffer 1

XEQ replays the file line by line through the same command interpreter as the prompt: it sets IDENTIFIER, DATE, CONVERSION, the beam and geometry, then hits SWALLOW, which reads every following line as channel data straight into the buffer — landing in buffer 1 exactly like GET does.

Loading either file with the wrong command fails loudly instead of silently misreading it:

Your wish? get MnPt.rbs
could not read .../MnPt.RBS: .../MnPt.RBS is a text command macro
(RC43's EMPTY/SWALLOW convention), not a binary RUMP spectrum -- use XEQ,
not GET, to load it

Your wish? xeq 2A.rbs
.../2A.rbs is not a text command file (...) -- binary spectrum data belongs
with GET, not XEQ

Example 3 — a SIMNRA file (.xnra)

examples/MnPt.xnra is the same measurement saved by SIMNRA 7.04, with a sample fitted in SIMNRA. GETNRA (GN for short) loads the spectrum into buffer 1 and the sample into SIM:

Your wish? gn MnPt.xnra
  WARNING: SIMNRA stores charge x solid angle together: loaded as OMEGA 1 msr,
  CHARGE 43.2 uC. If you know them separately, set them with OMEGA and CHARGE
  geometry IBM: theta 9, phi 11 (scattering angle 169), psi 20 (exit angle)
  SIM sample from MnPt.xnra: Si [5000/CM2] - Ru [27/CM2] - Mn0.73Pt0.27 [241/CM2] - Ru [26/CM2]
  ...
active buffer is now 1
Your wish? compare

WRITENRA (WN) writes the result back for SIMNRA. See File formats for what carries over and what doesn't.

Plotting

Picking up with buffer 1 already loaded (either example above works), PLOT opens one persistent matplotlib window whose state survives between commands:

Your wish? plot 1               /* erase and plot buffer 1             */
Your wish? region 100 400       /* zoom to a channel range             */
Your wish? sqrt                 /* sqrt yield scale, redraws right away */

See Plotting & display in the manual for the rest — OVERLAY, COMPARE, EXPAND, LOG/LINEAR/SQRT, ENERGY, FIGSAVE and more.

Simulating with SIM

SIM edits the sample description that COMPARE and PERT fit against. examples/MnPt.lcm is a real 5-layer description for the spectrum loaded above — SIM GET/SIM SHOW work as one-shots, with no need to enter the SIM sub-level for a quick look:

Your wish? sim get MnPt.lcm
read MnPt.lcm: 5 layers
Your wish? sim show
 >  1            40 A        Ru 1        [29 /CM2  Ru 29.03]
    2           300 A        Mn 3 Pt 1   [231 /CM2  Mn 173.35 Pt 57.78]
    3            40 A        Ru 1        [29 /CM2  Ru 29.03]
    4           300 SIO2     Si 1 O 2    [198 /CM2  Si 66 O 132]
    5             5 um       Si 1        [24888 /CM2  Si 24888.43]
  maxpth 1000   straggle 0   multiple 0   absorber 0
Your wish? compare              /* data vs. simulation, with residuals */

Buffer 0 is always the simulation and recomputes itself whenever the sample or the active buffer's parameters change — there is no "simulate" command, exactly as in the original.

See SIM in the manual for the full SIM command set — editing layers interactively, depth-profile equations, straggling and more.

Fitting with PERT

PERT picks which sample and instrument parameters may vary and over which channel window, then fits them by least squares. examples/MnPt.pert is a saved selection for the sample above; GET ... GO replays it and runs the fit in one line:

Your wish? pert get MnPt.pert go
  ...
  Fitting MA8408: Si [5um] - SiO2 [300SIO2] - Ru [40A] - Mn3Pt [300A] - Ru [40A]

  fit took 0.45 s

  reduced chi-square 4.2900 on 792 dof   (was 141.5915)
  66 evaluations, converged
  fwhm                              19.2299  +/- 0.1166   (was 15)
  correction                       0.855636  +/- 0.001678   (was 1)
  kev(0)                            47.3853  +/- 0.1454   (was 48)
  layer 1 thickness                    40 A  +/- 0.3326 A   (was 40 A)   [29 /CM2]
  layer 2 thickness                   314 A  +/- 0.7404 A   (was 300 A)   [242 /CM2]
  layer 3 thickness                    41 A  +/- 0.3266 A   (was 40 A)   [30 /CM2]
  layer 2 composition Mn            2.74154  +/- 0.01577   (was 3)
  kev/ch                            1.59761  +/- 0.0001069   (was 1.59)
  layer 4 thickness                325 SIO2  +/- 6.634 SIO2   (was 300 SIO2)   [215 /CM2]

  MA8408: Si [5um] - SiO2 [325SIO2] - Ru [41A] - Mn2.74Pt [314A] - Ru [40A]

Fitted values are written back into the sample description (SIM SHOW reflects them). Type GO again until nothing moves — here four times in all, as the MnPt worked example shows. COMPARE then shows how the result actually matches the data:

Your wish? region 300 1130      /* zoom to the fitted window            */
Your wish? pert highlight off   /* no fit-window shading, for a figure  */
Your wish? compare              /* data vs. simulation, with residuals  */
Your wish? element Pt Ru Mn Si O  /* mark the surface edges            */
Your wish? figsave fit         /* fit_rbs.png                         */

MnPt data vs. the fitted simulation, with residuals

See PERT in the manual for the full PERT command set — bounded fits, WINDOW/NORMALIZE, AUTOSNAP, and the composition-degeneracy caveat worth reading before your first real fit.

For a complete analysis of a measurement with both RBS and PIXE, from loading the data through SIM, PERT and the saved results, see the two worked examples: MnPt, this sample fitted with RBS and checked against its PIXE spectrum, and FeNi, where RBS and PIXE are fitted together.

Picking up later

SNAP saves the session as it stands. That can be straight after the fit, or after you've nudged a thickness or the CORRECTION by hand. The files are named after the sample, which here is MA8408, the first word of the spectrum's IDENTIFIER:

Your wish? snap
  updated MA8408.report
  wrote MA8408.pert
  wrote MA8408.lcm
  wrote MA8408_rbs.png
  wrote MA8408_fit.xeq

MA8408_fit.xeq is a restore macro. Run it, from any folder, and you're back where you were: the spectrum reloaded with every parameter the fit changed, the sample, the PERT setup and the plot:

pyrump MA8408_fit.xeq

MA8408.report keeps a block per snapshot, with the fit's uncertainties when nothing has changed since GO. AUTOSNAP in PERT takes a snapshot after every GO by itself. See SNAPSHOT in the manual.

Command line

You can drive pyRUMP as one-off batch commands, without the interactive shell:

pyrump simulate sample.lcm --energy 2.0 --beam 4He -o out.rbs
pyrump fit sample.lcm measured.rbs --vary thickness:0 --window 190 226
pyrump plot measured.rbs --compare out.rbs -o comparison.png
pyrump convert measured.rbs measured.dat

See CLI reference for every option, or Python API to call the library directly.