qick.helpers
Support functions.
Functions
|
Create I and Q arrays for a DRAG pulse. |
|
convert a channel number or a list of ch numbers to list of integers |
|
Test if a signed int will fit in the specified number of bytes. |
|
Check whether the keys defined for a pulse are supported and sufficient for this generator and pulse type. |
|
Create a numpy array containing a cosine shaped envelope function |
|
Convert a base64-encoded array back into numpy. |
|
Create a numpy array containing a Gaussian function |
|
Read QICK programs from JSON. |
|
Dump QICK programs to a JSON string. |
|
Convert a parameter value from user units to ASM units. |
|
Create a numpy array containing a triangle function |
Classes
|
JSON encoder with support for numpy objects and custom classes with to_dict methods. |
- qick.helpers.to_int(val, scale, quantize=1, parname=None, trunc=False)[source]
Convert a parameter value from user units to ASM units. Normally this means converting from float to int. For the v2 tProcessor this can also convert QickSweep to QickSweepRaw. To avoid overflow, values are rounded towards zero using np.trunc().
- Parameters:
- Returns:
ASM value
- Return type:
int or QickSweepRaw
- qick.helpers.check_bytes(val, length)[source]
Test if a signed int will fit in the specified number of bytes.
- qick.helpers.cosine(length=100, maxv=30000)[source]
Create a numpy array containing a cosine shaped envelope function
- qick.helpers.gauss(mu=0, si=25, length=100, maxv=30000)[source]
Create a numpy array containing a Gaussian function
- qick.helpers.DRAG(mu, si, length, maxv, delta, alpha)[source]
Create I and Q arrays for a DRAG pulse. Based on QubiC and Qiskit-Pulse implementations.
- Parameters:
mu (float) – Mu (peak offset) of Gaussian
si (float) – Sigma (standard deviation) of Gaussian
length (int) – Length of array
maxv (float) – Maximum amplitude of Gaussian
delta (float) – anharmonicity of the qubit (units of 1/sample time)
alpha (float) – alpha parameter of DRAG (order-1 scale factor)
- Returns:
Numpy array with I and Q components of the DRAG pulse
- Return type:
array, array
- qick.helpers.triang(length=100, maxv=30000)[source]
Create a numpy array containing a triangle function
- class qick.helpers.NpEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoder
JSON encoder with support for numpy objects and custom classes with to_dict methods. Taken from https://stackoverflow.com/questions/50916422/python-typeerror-object-of-type-int64-is-not-json-serializable
- default(obj)[source]
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- qick.helpers.ch2list(ch: Union[List[int], int]) List[int] [source]
convert a channel number or a list of ch numbers to list of integers
- Parameters:
ch – channel number or list of channel numbers
- Returns:
list of channel number(s)