ScanControl#

Connect to a detector and scan controller, set the detector up, run scans and manage the detector’s files from one panel. The widget starts the steps of an acquisition runner and shows its status; every hardware call stays in the runner, so the widget holds no addresses.

import scan_runner                      # the site's runner: DCU + scan-controller steps
from quantem.widget import ScanControl

runner = scan_runner.Runner(detector_address, scan_controller_address)
panel = ScanControl(runner, size=512, binned=True, folder="downloads")
panel

Go moves the electron beam. Press it only when the operator says go, with the beam on.

Control

What it does

Size, Binning, Output, Save HDF5

The scan settings; a change while Ready sets the detector up again

Connect

Connects and sets the detector up for the settings

Scans, Run forever

Scans per Go

Go

Runs the scans (runner.start("run", settings, n))

Stop

Ends the run after the scan in progress

Files

Refresh, download to the folder, delete (asks first)

The same steps work from Python: panel.connect(), panel.go(), panel.stop(), panel.download(names), panel.delete(names). panel.close() stops polling and disconnects the scan controller.

A runner provides start(step, *args) (steps connect, configure, run, list_files, download, delete; returns False while a step is running), status() (a namedtuple with state, message, dcu_ok, revolon_ok, high_voltage, done, total, dropped, files, free_bytes), stop() and close().

Reference#

class quantem.widget.scan_control.ScanControl(*args: t.Any, **kwargs: t.Any)#

Bases: AnyWidget

Connect, set up and run scans, with the detector’s files, in one panel.

Parameters:
  • runner (scan_runner.Runner or compatible) – Owns every detector and scan-controller call; the widget only starts its steps (start("connect" | "configure" | "run" | "list_files" | "download" | "delete", ...)), reads status() and calls stop().

  • size (int, default 512) – Square scan side; one of sizes.

  • binned (bool, default True) – 2x2 binning (120 kHz) or unbinned (30 kHz).

  • output ({"rdma", "stream"}, default "rdma") – RDMA to the processing PC, or the normal stream.

  • save (bool, default False) – The detector also writes HDF5 files.

  • count (int, default 1) – Scans per Go.

  • folder (str, default "") – Download folder for the detector’s files.

  • sizes (tuple of int) – The scan sizes offered.

  • title (str, default "Scan control")

  • auto_insert (bool, default True) – Go (and Calibrate with the ARINA) first inserts the ARINA if it is out.

  • auto_clear (bool, default True) – Go (and Calibrate with the ARINA) first retracts the Ceta, the fluorescent screen and the HAADF.

  • relative (bool, default True) – MAPED tilts are changes on top of the deflectors at Go (the on-axis scan is the operator alignment), and Calibrate steps around the current values; False: absolute.

  • rotation_pair (bool, default False) – The 0-90 pair: every scan (Go and Go MAPED) twice, at the scan rotation at Go and 90 degrees from it (AutoScript), put back after; names end in _rot0 / _rot90.

  • auto_blank (bool, default True) – Unblank the beam only while it is needed (each scan; the whole calibration) and blank it again right after, also after a failure.

  • restore_after (bool, default True) – After the run (also after a failure or Stop), put back what auto_clear and auto_insert moved: the ARINA out, then the Ceta, the screen and the HAADF back in.

  • maped – MAPED series: Go runs one scan at each of tilt_count image tilts around a circle of tilt_mrad, plus one on axis, with the deflectors set from the calibration file (the runner’s calibration_files()). Calibrate makes one (cal_options). Value calibration: the beam disk (2 alpha across) is the angular ruler, so a calibrated file turns MAPED tilts into true mrad. cal_options["alpha_mrad"] 0 takes alpha from AutoScript; alpha_factor corrects it after a reference calibration.

  • tilt_mrad – MAPED series: Go runs one scan at each of tilt_count image tilts around a circle of tilt_mrad, plus one on axis, with the deflectors set from the calibration file (the runner’s calibration_files()). Calibrate makes one (cal_options). Value calibration: the beam disk (2 alpha across) is the angular ruler, so a calibrated file turns MAPED tilts into true mrad. cal_options["alpha_mrad"] 0 takes alpha from AutoScript; alpha_factor corrects it after a reference calibration.

  • tilt_count – MAPED series: Go runs one scan at each of tilt_count image tilts around a circle of tilt_mrad, plus one on axis, with the deflectors set from the calibration file (the runner’s calibration_files()). Calibrate makes one (cal_options). Value calibration: the beam disk (2 alpha across) is the angular ruler, so a calibrated file turns MAPED tilts into true mrad. cal_options["alpha_mrad"] 0 takes alpha from AutoScript; alpha_factor corrects it after a reference calibration.

  • calibration – MAPED series: Go runs one scan at each of tilt_count image tilts around a circle of tilt_mrad, plus one on axis, with the deflectors set from the calibration file (the runner’s calibration_files()). Calibrate makes one (cal_options). Value calibration: the beam disk (2 alpha across) is the angular ruler, so a calibrated file turns MAPED tilts into true mrad. cal_options["alpha_mrad"] 0 takes alpha from AutoScript; alpha_factor corrects it after a reference calibration.

  • heartbeat (float, default 5.0) – Seconds between read-only checks of HV, detector position and the microscope detectors (runner.read_hardware()); 0 turns it off.

Notes

Go moves the electron beam: press it only when the operator says go, with the beam on. Changing a setting while Ready sets the detector up again. Stop ends the run after the scan in progress. Deleting files asks for confirmation in the panel.

Public constructor

property settings: ScanSettings#

The scan settings the panel shows now.

property scans: int#

count, or the “run forever” count.

Type:

Scans per Go

connect() → bool#

Connect to the detector and scan controller and set the detector up.

go() → bool#

* Moves the beam. * Run scans scans with the panel’s settings, or with maped on, one scan per MAPED tilt with the chosen calibration.

load_calibrations() → None#

The runner’s calibration files (newest first); keeps the chosen one, else the newest.

calibrate() → bool#

* Moves the deflectors, the screen and the HAADF. * The automatic calibration, with its points at the MAPED tilts.

stop() → None#

End the run after the scan in progress.

set_high_voltage(on: bool) → bool#

Detector high voltage on or off.

insert_sensor() → bool#

Move the detector in.

check_microscope() → bool#

Read the microscope detectors (Ceta, STEM) through the runner, read only.

files_of(scans) → list#

The detector files of these scans (a master and its data files).

download(scans, format: str = 'h5') → bool#

Download whole scans. “h5”: the detector’s files as they are. “qem”: download, then re-save ANS-encoded with quantem.gpu (one .qem per scan) and remove the downloaded .h5.

refresh() → None#

Copy the runner’s status into the panel.

close() → None#

Stop polling, stop after the scan in progress, and disconnect the scan controller.