Skip to main content
When streaming RHEED data, use the polling utilities in atomscale.timeseries to receive analysis updates as they arrive. These helpers always read the RHEED timeseries for data_id, so they work only with RHEED videos. Each poll returns a DataFrame indexed by ["View ID", "Frame Number"], the same shape as get_rheed_timeseries(). Four entry points cover different concurrency needs:

Setup

Synchronous polling

Loop over iter_poll to fetch fresh rows on a fixed cadence. The helper waits interval seconds between polls.

Parameters

Polling errors are never raised. A failed poll is skipped and polling continues on the next tick, so pass an on_error handler to log failures, or re-raise inside it to stop polling.

Background thread polling

Use start_polling_thread when you can’t block the main thread (GUI, acquisition loop):
The function returns a threading.Event that you can set to stop polling gracefully.

Async polling

Two helpers integrate with asyncio:

Async iterator

aiter_poll yields results without blocking the event loop:

Background task

start_polling_task creates a background task that invokes an optional async handler:

Deduplication

The distinct_by parameter accepts a function that extracts a hashable key from each result. Only results with a new key are yielded, so you won’t process the same data twice when polling faster than updates arrive. Key on the newest Frame Number in the index. Frame numbers are absolute and present on every row, so the maximum grows each time new frames are analyzed. Avoid keying on the last row (df.iloc[-1]): rows are grouped by view, so the last row is not necessarily the newest frame in a rotating video. UNIX Timestamp can also be 0 for every row when the recording has no absolute start time.

Drift correction

All polling utilities use drift-corrected scheduling to maintain the requested cadence even if individual polls are slow. Missed ticks are skipped rather than accumulated.

Next steps

Stream RHEED

Set up RHEED streaming from your instrument.

Client Reference

Full Client class documentation.