Skip to main content

SmartMCA Python Library

High-level Python client library to control Nuclear Instruments Smart Digital MCA firmware (e.g. DT5771) over an HTTP/REST interface.

It provides typed configuration objects, parameter validation, and convenience helpers for:

  • Analog front-end configuration
  • Digital I/O and trigger routing
  • MCA processing (trigger, energy, baseline, pile-up rejection)
  • Acquisition presets, MCS and statistics
  • Oscilloscope readout and histogram retrieval

The full user documentation is available here


Features

  • Simple connection handling (login/logout, cookies, error reporting)
  • Pythonic configuration objects mirroring firmware registers
  • Enumerations for all categorical parameters (trigger modes, energy algorithms, etc.)
  • High-level acquisition control (start/stop/reset, presets, auto-save)
  • Readout of MCA statistics, MCS data, oscilloscope traces, histograms
  • Can be used both from a remote PC and from the embedded Jupyter environment on the instrument

Installation

From PyPI

pip install smartmca

From source (this repository)

git clonehttps://gitlab.nuclearinstruments.eu/public-repo/dt5771/smart-mca-python-library.git
cd smart-mca-python-library

# (optional) create a virtualenv
python -m venv .venv
source .venv/bin/activate  # on Windows: .venv\\Scripts\\activate

pip install -e .

Quick start

Minimal example showing how to connect to a board, configure a couple of parameters and acquire an energy spectrum.

from smartmca import (
    connect,
    disconnect,
    get_mca_configuration,
    set_mca_configuration,
    acquisition_start,
    acquisition_stop,
    histogram_get,
    ConfigAcquisition,
)

# 1. Connect to the instrument
url = "http://192.168.0.10"  # or "http://127.0.0.1" when running on-board
username = "user"
password = "password"  # change if you modified the default password on the device

if not connect(url, username, password):
    raise RuntimeError("Could not connect to SmartMCA server")

try:
    # 2. Read and adjust MCA configuration
    mca_cfg = get_mca_configuration()

    # Example: change some processing parameters
    # (see the MkDocs pages for the full list of fields)
    # mca_cfg.trigger_mode = TriggerMode.INTERNAL
    # mca_cfg.energy_mode = EnergyMode.TRAPEZOIDAL
    # mca_cfg.trap_shaping = 2000  # [ns]

    set_mca_configuration(mca_cfg)

    # 3. Start an acquisition
    result = acquisition_start()
    if result != "ok":
        raise RuntimeError(f"Acquisition start failed: {result}")

    # ... wait for statistics / preset condition using your own logic ...

    # 4. Read an energy histogram (rebin to 4096 channels)
    spectrum, status = histogram_get(
        ConfigAcquisition.SpectrumType.ENERGY,
        rebin=4096,
    )

    if status != "ok":
        raise RuntimeError(f"Histogram read failed: {status}")

    # `spectrum` is a list of counts per bin
    print(f"Number of channels: {len(spectrum)}")

finally:
    # 5. Stop acquisition and disconnect
    acquisition_stop()
    disconnect()

This is intentionally minimal. Refer to the configuration pages for the full list of parameters (analog, digital I/O, MCA processing, acquisition, oscilloscope).


Documentation

The full user guide is generated with MkDocs and published as GitLab Pages.

To build the documentation locally:

pip install -r requirements-mkdocs.txt

# From the repository root
mkdocs serve

Then open http://127.0.0.1:8000/ in your browser.

The documentation is organized as:

  • Home – overview and installation
  • Connection and System – connection helpers and system information
  • Configuration – analog and digital I/O, MCA processing, acquisition, oscilloscope
  • Data Acquisition & Readout – statistics, MCS, oscilloscope and histogram APIs

Versioning

Follow Semantic Versioning for library releases:

  • MAJOR – incompatible API changes
  • MINOR – new functionality in a backwards compatible manner
  • PATCH – backwards compatible bug fixes

Tag releases in Git and publish the same version on PyPI and GitLab pages when appropriate.


Contact / Support

This gives external users and colleagues a single place to start when using the library.

Release files for smartmca 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartmca 0.1.12
File Size Uploaded
smartmca-0.1.12.tar.gz 68.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smartmca 0.1.12
File Interpreter ABI Platform
smartmca-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 93.6 kB

Release files / smartmca-0.1.12.tar.gz

Download URL smartmca-0.1.12.tar.gz
Size 68.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cad2253a0a152292224e84610e487188e58849502cd8eb9f8c470c7c20948faa
BLAKE2b-256 checksum
How to use checksums
dc2a6cd296b70f7afeb514c5fd0f9570d73693d982a5c5276f8b81a01395a451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / smartmca-0.1.12-py3-none-any.whl

Download URL smartmca-0.1.12-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aeb81270d0ac38993fb6a57e9f76ed65d9d10a31fe4027480cc3df66e180e379
BLAKE2b-256 checksum
How to use checksums
e67bef43ef40adf1efcc964a5c4b0ae2734bd428e6471a1c2b7f0bb654391868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.12 This release

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page