Result Stream¶
qm.qua._dsl._ResultStream¶
qm.qua._dsl._ResultStream
¶
add
¶
Allows addition between streams. The addition is done element-wise. Can also be performed on buffers and other operators, but they must have the same dimensions.
Example
i = declare(int)
j = declare(int)
k = declare(int, value=5)
stream = declare_stream()
stream2 = declare_stream()
stream3 = declare_stream()
with for_(j, 0, j < 30, j + 1):
with for_(i, 0, i < 10, i + 1):
save(i, stream)
save(j, stream2)
save(k, stream3)
with stream_processing():
(stream1 + stream2 + stream3).save_all("example1")
(stream1.buffer(10) + stream2.buffer(10) + stream3.buffer(10)).save_all("example2")
(stream1 + stream2 + stream3).buffer(10).average().save("example3")
average
¶
Perform a running average on a stream item. The Output of this operation is the running average of the values in the stream starting from the beginning of the QUA program.
boolean_to_int
¶
converts boolean to an integer number - 1 for true and 0 for false
buffer
¶
Gather items into vectors - creates an array of input stream items and outputs the array as one item. only outputs full buffers.
Note
The order of resulting dimensions is different when using a buffer with multiple inputs compared to using multiple buffers. The following two lines are equivalent:
PARAMETER | DESCRIPTION |
---|---|
*args |
number of items to gather, can either be a single number, which gives the results as a 1d array or multiple numbers for a multidimensional array.
DEFAULT:
|
buffer_and_skip
¶
Gather items into vectors - creates an array of input stream items and outputs
the array as one item.
Skips the number of given elements. Note that length and skip start from the
same index, so the buffer(n)
command is equivalent to buffer_and_skip(n, n)
.
Only outputs full buffers.
Example
# The stream input is [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
with stream_processing():
stream.buffer(3).save_all("example1")
stream.buffer_and_skip(3, 3).save_all("example2")
stream.buffer_and_skip(3, 2).save_all("example3")
stream.buffer_and_skip(3, 5).save_all("example4")
# example1 -> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# example2 -> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# example3 -> [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]]
# example4 -> [[1, 2, 3], [6, 7, 8]]
PARAMETER | DESCRIPTION |
---|---|
length |
number of items to gather
TYPE:
|
skip |
number of items to skip for each buffer, starting from the same index as length
TYPE:
|
convolution
¶
Computes discrete, linear convolution of one-dimensional constant vector and one-dimensional vector item of the input stream.
PARAMETER | DESCRIPTION |
---|---|
constant_vector |
vector of numbers
TYPE:
|
mode |
"full", "same" or "valid"
TYPE:
|
divide
¶
Allows division between streams. The division is done element-wise. Can also be performed on buffers and other operators, but they must have the same dimensions.
Example
i = declare(int)
j = declare(int)
k = declare(int, value=5)
stream = declare_stream()
stream2 = declare_stream()
stream3 = declare_stream()
with for_(j, 0, j < 30, j + 1):
with for_(i, 0, i < 10, i + 1):
save(i, stream)
save(j, stream2)
save(k, stream3)
with stream_processing():
(stream1 / stream2 / stream3).save_all("example1")
(stream1.buffer(10) / stream2.buffer(10) / stream3.buffer(10)).save_all("example2")
(stream1 / stream2 / stream3).buffer(10).average().save("example3")
dot_product
¶
Computes dot product of the given vector and each item of the input stream
PARAMETER | DESCRIPTION |
---|---|
vector |
constant vector of numbers
TYPE:
|
fft
¶
Computes one-dimensional discrete fourier transform for every item in the stream. Item can be a vector of numbers, in this case fft will assume all imaginary numbers are 0. Item can also be a vector of number pairs - in this case for each pair - the first will be real and second imaginary.
PARAMETER | DESCRIPTION |
---|---|
output |
supported from QOP 1.30 and QOP 2.0, options are "normal", "abs" and "angle":
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
_ResultStream
|
stream object |
flatten
¶
Deconstruct an array item - and send its elements one by one as items
histogram
¶
Compute the histogram of all items in stream
PARAMETER | DESCRIPTION |
---|---|
bins |
vector or pairs. each pair indicates the edge of each bin. example: [[1,10],[11,20]] - two bins, one between 1 and 10, second between 11 and 20
TYPE:
|
map
¶
Transform the item by applying a function to it
PARAMETER | DESCRIPTION |
---|---|
function |
a function to transform each item to a different item. For example, to compute an average between elements in a buffer you should write ".buffer(len).map(FUNCTIONS.average())"
TYPE:
|
multiply
¶
Allows multiplication between streams. The multiplication is done element-wise. Can also be performed on buffers and other operators, but they must have the same dimensions.
Example
i = declare(int)
j = declare(int)
k = declare(int, value=5)
stream = declare_stream()
stream2 = declare_stream()
stream3 = declare_stream()
with for_(j, 0, j < 30, j + 1):
with for_(i, 0, i < 10, i + 1):
save(i, stream)
save(j, stream2)
save(k, stream3)
with stream_processing():
(stream1 * stream2 * stream3).save_all("example1")
(stream1.buffer(10) * stream2.buffer(10) * stream3.buffer(10)).save_all("example2")
(stream1 * stream2 * stream3).buffer(10).average().save("example3")
multiply_by
¶
Multiply the input stream item by a constant scalar or vector. The input item can be either scalar or vector.
PARAMETER | DESCRIPTION |
---|---|
scalar_or_vector |
either a scalar number, or a vector of scalars.
TYPE:
|
save
¶
Save only the last item received in stream This will add to qm._results.JobResults a qm._results.MultipleNamedJobResult object.
PARAMETER | DESCRIPTION |
---|---|
tag |
result name
TYPE:
|
save_all
¶
Save all items received in stream. This will add to qm._results.JobResults a qm._results.SingleNamedJobResult object.
PARAMETER | DESCRIPTION |
---|---|
tag |
result name
TYPE:
|
skip
¶
Suppress the first n items of the stream
PARAMETER | DESCRIPTION |
---|---|
length |
number of items to skip
TYPE:
|
skip_last
¶
Suppress the last n items of the stream
PARAMETER | DESCRIPTION |
---|---|
length |
number of items to skip
TYPE:
|
subtract
¶
Allows subtraction between streams. The subtraction is done element-wise. Can also be performed on buffers and other operators, but they must have the same dimensions.
Example
i = declare(int)
j = declare(int)
k = declare(int, value=5)
stream = declare_stream()
stream2 = declare_stream()
stream3 = declare_stream()
with for_(j, 0, j < 30, j + 1):
with for_(i, 0, i < 10, i + 1):
save(i, stream)
save(j, stream2)
save(k, stream3)
with stream_processing():
(stream1 - stream2 - stream3).save_all("example1")
(stream1.buffer(10) - stream2.buffer(10) - stream3.buffer(10)).save_all("example2")
(stream1 - stream2 - stream3).buffer(10).average().save("example3")
take
¶
Outputs only the first n items of the stream
PARAMETER | DESCRIPTION |
---|---|
length |
number of items to take
TYPE:
|
tuple_convolution
¶
Computes discrete, linear convolution of two one-dimensional vectors that received as the one item from the input stream
PARAMETER | DESCRIPTION |
---|---|
mode |
"full", "same" or "valid"
TYPE:
|
tuple_dot_product
¶
Computes dot product of the given item of the input stream - that should include two vectors
tuple_multiply
¶
Computes multiplication of the given item of the input stream - that can be any combination of scalar and vectors.
zip
¶
Combine the emissions of two streams to one item that is a tuple of items of input streams
PARAMETER | DESCRIPTION |
---|---|
other |
second stream to combine with self
TYPE:
|
qm.qua._dsl._Functions¶
qm.qua._dsl._Functions
¶
average
staticmethod
¶
Perform a running average on a stream item. The Output of this operation is the running average of the values in the stream starting from the beginning of the QUA program.
PARAMETER | DESCRIPTION |
---|---|
axis |
optional Axis or axes along which to average.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
boolean_to_int
staticmethod
¶
Converts boolean to integer number - 1 for true and 0 for false
:return: stream object
convolution
staticmethod
¶
Computes discrete, linear convolution of one-dimensional constant vector and one-dimensional vector item of the input stream.
PARAMETER | DESCRIPTION |
---|---|
constant_vector |
vector of numbers
TYPE:
|
mode |
"full", "same" or "valid"
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
demod
staticmethod
¶
Demodulates the acquired data from the indicated stream at the given frequency and integration weights. If operating on a stream of tuples, assumes that the 2nd item is the timestamps and uses them for the demodulation, reproducing the demodulation performed in real time. If operated on a single stream, assumes that the first item is at time zero and that the elements are separated by 1ns.
PARAMETER | DESCRIPTION |
---|---|
frequency |
frequency for demodulation calculation
TYPE:
|
iw_cos |
cosine integration weight. Integration weight can be either a scalar for constant integration weight, or a python iterable for arbitrary integration weights.
TYPE:
|
iw_sin |
sine integration weight. Integration weight can be either a scalar for constant integration weight, or a python iterable for arbitrary integration weights.
TYPE:
|
integrate |
sum the demodulation result and returns a scalar if True (default), else the demodulated stream without summation is returned
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
stream object |
Example
Note
The demodulation in the stream processing does not take in consideration any real-time modifications to the frame, phase or frequency of the element. If the program has any QUA command that changes them, the result of the stream processing demodulation will be invalid.
dot_product
staticmethod
¶
Computes dot product of the given vector and an item of the input stream
PARAMETER | DESCRIPTION |
---|---|
vector |
constant vector of numbers
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
fft
staticmethod
¶
Computes one-dimensional discrete fourier transform for every item in the stream. Item can be a vector of numbers, in this case fft will assume all imaginary numbers are 0. Item can also be a vector of number pairs - in this case for each pair - the first will be real and second imaginary.
PARAMETER | DESCRIPTION |
---|---|
output |
supported from QOP 1.30 and QOP 2.0, options are "normal", "abs" and "angle":
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
multiply_by
staticmethod
¶
Multiply the input stream item by a constant scalar or vector. the input item can be either scalar or vector.
PARAMETER | DESCRIPTION |
---|---|
scalar_or_vector |
either a scalar number, or a vector of scalars.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
tuple_convolution
staticmethod
¶
Computes discrete, linear convolution of two one-dimensional vectors of the input stream
PARAMETER | DESCRIPTION |
---|---|
mode |
"full", "same" or "valid"
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
tuple_dot_product
staticmethod
¶
Computes dot product between the two vectors of the input stream
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
tuple_multiply
staticmethod
¶
Computes multiplication between the two elements of the input stream. Can be any combination of scalar and vectors.
RETURNS | DESCRIPTION |
---|---|
CommandsType
|
stream object |
qm.qua._dsl._ResultSource¶
qm.qua._dsl._ResultSource
¶
A python object representing a source of values that can be processed in a stream_processing()
pipeline
This interface is chainable, which means that calling most methods on this object will create a new streaming source
See the base class _ResultStream for operations
auto_reshape
¶
Creates a buffer with dimensions according to the program structure in QUA.
For example, when running the following program the result "reshaped" will have shape of (30,10):
input1
¶
A stream of raw ADC data from input 1. Only relevant when saving data from measure statement.
input2
¶
A stream of raw ADC data from input 2. Only relevant when saving data from measure statement.
timestamps
¶
Get a stream with only the timestamps of the stream-items
with_timestamps
¶
Get a stream with the relevant timestamp for each stream-item