63 lines
2.2 KiB
Plaintext
63 lines
2.2 KiB
Plaintext
---
|
||
title: align_func (v0.29)
|
||
description: API reference for qiskit.pulse.builder.align_func in qiskit v0.29
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.pulse.builder.align_func
|
||
---
|
||
|
||
<span id="qiskit-pulse-builder-align-func" />
|
||
|
||
# qiskit.pulse.builder.align\_func
|
||
|
||
<Function id="qiskit.pulse.builder.align_func" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.18/qiskit/pulse/builder.py" signature="align_func(duration, func)">
|
||
Callback defined alignment pulse scheduling context.
|
||
|
||
Pulse instructions within this context are scheduled at the location specified by arbitrary callback function position that takes integer index and returns the associated fractional location within \[0, 1]. Delay instruction is automatically inserted in between pulses.
|
||
|
||
This context may be convenient to write a schedule of arbitrary dynamical decoupling sequences such as Uhrig dynamical decoupling.
|
||
|
||
Examples:
|
||
|
||
```python
|
||
import numpy as np
|
||
from qiskit import pulse
|
||
|
||
d0 = pulse.DriveChannel(0)
|
||
x90 = pulse.Gaussian(10, 0.1, 3)
|
||
x180 = pulse.Gaussian(10, 0.2, 3)
|
||
|
||
def udd10_pos(j):
|
||
return np.sin(np.pi*j/(2*10 + 2))**2
|
||
|
||
with pulse.build() as udd_sched:
|
||
pulse.play(x90, d0)
|
||
with pulse.align_func(duration=300, func=udd10_pos):
|
||
for _ in range(10):
|
||
pulse.play(x180, d0)
|
||
pulse.play(x90, d0)
|
||
|
||
udd_sched.draw()
|
||
```
|
||
|
||
![../\_images/qiskit.pulse.builder.align\_func\_0\_0.png](/images/api/qiskit/0.29/qiskit.pulse.builder.align_func_0_0.png)
|
||
|
||
**Parameters**
|
||
|
||
* **duration** (`Union`\[`int`, `ParameterExpression`]) – Duration of context. This should be larger than the schedule duration.
|
||
* **func** (`Callable`\[\[`int`], `float`]) – A function that takes an index of sub-schedule and returns the fractional coordinate of of that sub-schedule. The returned value should be defined within \[0, 1]. The pulse index starts from 1.
|
||
|
||
**Yields**
|
||
|
||
None
|
||
|
||
**Notes**
|
||
|
||
The scheduling is performed for sub-schedules within the context rather than channel-wise. If you want to apply the numerical context for each channel, you need to apply the context independently to channels.
|
||
|
||
**Return type**
|
||
|
||
`AlignmentKind`
|
||
</Function>
|
||
|