RHEEDStreamer class provides high-performance streaming of RHEED frames to the Atomscale platform. It bridges Python to a Rust/PyO3 backend for efficient, concurrent packaging and upload of grayscale frames.
Constructor
API key for authentication.
Root API endpoint. If not provided, uses the default production endpoint or reads from
AS_API_ENDPOINT environment variable.Logging verbosity level. Set to
4 for detailed progress output.initialize()
Start a new streaming session and return a data ID for subsequent operations.Parameters
Frame rate of the capture in frames per second.
Sample rotation speed in rotations per minute. Set to
0.0 for stationary samples.Number of frames per upload chunk. Should cover at least 2 seconds of video for optimal
throughput.
Human-readable name for this stream. Helps identify runs in the UI.
Name of the physical sample to link this stream to. Names are matched case-insensitively. If no
match is found, a new sample record is created.
UUID of the project to associate with this stream. When provided along with
physical_sample,
the project’s tracking is automatically updated.Returns
Unique identifier for this streaming session. Use this ID with
push(), run(), and
finalize().Example
run()
Stream frames using generator/pull mode. The streamer consumes chunks from an iterator and handles pacing and retry logic.Parameters
The data ID returned by
initialize().Iterator yielding frame chunks. Each chunk should be a numpy array of shape
(N, H, W) with dtype
uint8, where N is the chunk size.Returns
None. Frames are uploaded as they are yielded by the iterator.Example
push()
Upload a single chunk of frames in callback/push mode. Use this when frames arrive live from the instrument.Parameters
The data ID returned by
initialize().Zero-based index of this chunk. Chunks must be pushed in order.
Numpy array of frames with shape
(N, H, W) or (H, W) for single frames. Must have dtype
uint8.Returns
None. The chunk is queued for upload.Example
finalize()
Complete the streaming session and signal the server to begin final processing.Parameters
The data ID returned by
initialize().Returns
None. The stream is marked as complete and queued for final analysis.Example
Frame Format Requirements
RHEED frames must meet these requirements:| Property | Requirement |
|---|---|
| Data type | numpy.uint8 (8-bit unsigned integer) |
| Shape | (N, H, W) for chunks or (H, W) for single frames |
| Color | Grayscale only |
| Values | 0-255 intensity range |
Example frame preparation
Best Practices
| Recommendation | Rationale |
|---|---|
| Match the capture cadence | The server expects frames at the declared FPS |
| Use chunk sizes ≥ 2 seconds | Reduces network overhead and improves throughput |
Always call finalize() | Allows graceful cleanup even on failure |
| Use distinct stream names | Makes runs easier to find later |
| Link to physical samples | Enables cross-run analysis and tracking |
Error Handling
The streamer raises exceptions for connection failures and invalid parameters. Wrap streaming code in try/finally to ensurefinalize() is called:
TimeseriesStreamer
TheTimeseriesStreamer class streams scalar instrument data (temperature, pressure, growth rate, etc.) to the Atomscale platform. Like RHEEDStreamer, it uses a Rust/PyO3 backend.
Constructor
API key for authentication.
Root API endpoint. If not provided, uses the default production endpoint or reads from
AS_API_ENDPOINT environment variable.Expected number of data points per chunk. Used for array positioning.
Logging verbosity level. Set to
4 for detailed progress output.initialize()
Start a new timeseries streaming session.Parameters
Human-readable name for this stream.
Growth instrument ID to link. Must belong to your organization.
Name or UUID of a physical sample to associate with the stream. Names are matched
case-insensitively, or a new sample is created if no match is found.
UUID of the project to associate with this stream.
Returns
Unique identifier for this streaming session.
push()
Upload a single chunk of data for one channel. Spawns an async upload task and returns immediately.Parameters
The data ID returned by
initialize().Zero-based index of this chunk. Chunks must be pushed in order.
Name of the data channel (e.g., “temperature”, “pressure”).
Unix epoch timestamps in seconds.
Measured values corresponding to each timestamp.
Optional units for the values (e.g., “C”, “mbar”).
Returns
None. The chunk is queued for upload.push_multi()
Upload data for multiple channels in a single call.Parameters
The data ID returned by
initialize().Zero-based index of this chunk.
Mapping of channel names to channel data. Each value dict should contain
timestamps (list of floats), values (list of floats), and optionally units (string).Returns
None.run()
Stream data from an iterator. Blocks until all uploads complete.Parameters
The data ID returned by
initialize().Name of the data channel.
Iterator yielding
(timestamps, values) tuples for each chunk.Optional units for the values.
Returns
None.finalize()
Complete the streaming session and signal the server to begin processing.Parameters
The data ID returned by
initialize().