Helpers¶
InstrumentResolver ¶
Resolve instrument aliases and ids to their InstrumentInfo.
Maintains a cache of the instruments known to a client, keyed both by
resource id and by short alias (the part of an alias after the unit
prefix). Call refresh() to populate the cache from a client before
resolving.
Source code in quelware-client/src/quelware_client/client/helpers/instrument_resolver/__init__.py
find_inst_info_by_alias ¶
Return the cached info for an instrument alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Short alias of the instrument (without the unit prefix). |
required |
unit
|
str | None
|
Unit label to disambiguate when the alias exists on more than one unit. |
None
|
Returns:
| Type | Description |
|---|---|
InstrumentInfo
|
The instrument's information. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the alias is unknown, is missing on |
Source code in quelware-client/src/quelware_client/client/helpers/instrument_resolver/__init__.py
find_inst_info_by_id ¶
Return the cached info for an instrument id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument_id
|
ResourceId
|
Full resource id of the instrument. |
required |
Returns:
| Type | Description |
|---|---|
InstrumentInfo
|
The instrument's information. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the id is not in the cache. |
Source code in quelware-client/src/quelware_client/client/helpers/instrument_resolver/__init__.py
refresh
async
¶
Rebuild the instrument cache from a client.
Fetches information for every instrument resource the client exposes and indexes it by id and by short alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
QuelwareClient
|
An initialized client to query. |
required |
Source code in quelware-client/src/quelware_client/client/helpers/instrument_resolver/__init__.py
resolve ¶
Resolve several instrument aliases to their resource ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aliases
|
list[str]
|
Short aliases to resolve. |
required |
unit
|
str | None
|
Unit label to disambiguate aliases present on multiple units. |
None
|
Returns:
| Type | Description |
|---|---|
list[ResourceId]
|
The resource ids, in the same order as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any alias is unknown or ambiguous. |
Source code in quelware-client/src/quelware_client/client/helpers/instrument_resolver/__init__.py
Sequencer ¶
Build fixed timelines of waveform events and capture windows.
Waveforms are registered by name and then scheduled on instruments at
nanosecond offsets, alongside capture windows. Each instrument alias is
bound to its hardware sampling period so offsets and lengths can be
validated against the sample grid and converted to samples. The assembled
timeline for an instrument is exported as a SetFixedTimeline directive.
Create a sequencer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_sampling_period_ns
|
float
|
Sampling period, in nanoseconds, used for waveforms registered without an explicit period. |
required |
enforce_sample_grid
|
bool
|
When True, offsets and lengths that do not
land on the sample grid raise |
True
|
Source code in quelware-client/src/quelware_client/client/helpers/sequencer/__init__.py
aligned_length_fs
property
¶
Timeline length in femtoseconds, aligned to bound step sizes.
The raw length is rounded up to a multiple of the least common
multiple of each bound alias's sampling_period_fs * step_samples.
add_capture_window ¶
Schedule a capture window on an instrument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument_alias
|
str
|
Alias of the (bound) target instrument. |
required |
window_name
|
str
|
Name of the capture window. |
required |
start_offset_ns
|
float
|
Start time of the window, in nanoseconds. |
required |
length_ns
|
float
|
Length of the window, in nanoseconds. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the offset or length is off the sample grid while grid enforcement is on. |
Source code in quelware-client/src/quelware_client/client/helpers/sequencer/__init__.py
add_event ¶
Schedule a registered waveform on an instrument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument_alias
|
str
|
Alias of the (bound) target instrument. |
required |
waveform_name
|
str
|
Name of a registered waveform. |
required |
start_offset_ns
|
float
|
Start time of the event, in nanoseconds. |
required |
gain
|
float
|
Linear gain applied to the waveform. |
1.0
|
phase_offset_deg
|
float
|
Phase offset applied to the waveform, in degrees. |
0.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the waveform is not registered, or the offset is off the sample grid while grid enforcement is on. |
Source code in quelware-client/src/quelware_client/client/helpers/sequencer/__init__.py
bind ¶
Bind an instrument alias to its hardware timing.
Must be called before adding events or capture windows for the alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Instrument alias to bind. |
required |
sampling_period_fs
|
int
|
Sampling period of the instrument, in femtoseconds. |
required |
step_samples
|
int
|
Granularity, in samples, that the timeline length is aligned to for this alias. |
required |
Source code in quelware-client/src/quelware_client/client/helpers/sequencer/__init__.py
export_set_fixed_timeline_directive ¶
Build the timeline directive for one instrument.
Collects the events and capture windows scheduled for the alias, converts their nanosecond offsets to samples, and packages them with the aligned length and iteration count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument_alias
|
str
|
Alias of the (bound) instrument to export. |
required |
Returns:
| Type | Description |
|---|---|
SetFixedTimeline
|
The assembled |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the alias is not bound. |
Source code in quelware-client/src/quelware_client/client/helpers/sequencer/__init__.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
extend_length_ns ¶
Extend the overall timeline by additional_ns nanoseconds.
register_waveform ¶
Register a named IQ waveform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name used to reference the waveform in |
required |
waveform
|
ArrayLike
|
Complex IQ samples; every amplitude must lie within
|
required |
sampling_period_ns
|
float | None
|
Sampling period of the waveform, in nanoseconds. Defaults to the sequencer's default period. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any sample amplitude exceeds 1 in magnitude. |