Skip to content

Commit

Permalink
Update examples for labone release 22.08
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasah committed Aug 31, 2022
1 parent 8ba6991 commit 406e209
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 76 deletions.
2 changes: 1 addition & 1 deletion examples/awg.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.0
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/daq_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
62 changes: 36 additions & 26 deletions examples/hdawg_awg.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down Expand Up @@ -48,33 +48,39 @@ with device.set_transaction():
device.awgs[0].userregs(0)
```

### Configuring the AWG program
### Define and compile the AWG program

```python
import textwrap
from zhinst.toolkit import Sequence

AWG_N = 2000
awg_program = Sequence()
awg_program.constants["AWG_N"] = AWG_N
awg_program.code = """
wave w0 = gauss(AWG_N, AWG_N/2, AWG_N/20);
wave w1 = placeholder(AWG_N);
wave w2 = zeros(AWG_N);
wave w3 = placeholder(AWG_N);
assignWaveIndex(1, w1, 1);
assignWaveIndex(1, w3, 3);
while(getUserReg(0) == 0) {
setTrigger(1);
setTrigger(0);
playWave(w0);
playWave(w1);
playWave(w2);
playWave(w3);
}
"""
print(awg_program)
```

awg_program = textwrap.dedent(f"""
const AWG_N = {AWG_N};
wave w0 = gauss(AWG_N, AWG_N/2, AWG_N/20);
wave w1 = placeholder(AWG_N);
wave w2 = zeros(AWG_N);
wave w3 = placeholder(AWG_N);
assignWaveIndex(1, w1, 1);
assignWaveIndex(1, w3, 3);
while(getUserReg(0) == 0) {
setTrigger(1);
setTrigger(0);
playWave(w0);
playWave(w1);
playWave(w2);
playWave(w3);
}
""")
device.awgs[0].load_sequencer_program(awg_program)
```python
elf_file, info = device.awgs[0].compile_sequencer_program(awg_program)
info
```

#### Write the waveforms into the device memory
### Define Waveforms

```python
from zhinst.toolkit import Waveforms
Expand All @@ -88,12 +94,16 @@ waveforms.assign_waveform(
slot=3,
wave1=-1.0 * np.blackman(AWG_N)
)
device.awgs[0].write_to_waveform_memory(waveforms)
```

### Run the program
### Upload and Run the program

This can be done in a single transaction which reduces the network communication overhead to a minimum

```python
device.awgs[0].single(True)
device.awgs[0].enable(True)
with device.set_transaction():
device.awgs[0].elf.data(elf_file)
device.awgs[0].write_to_waveform_memory(waveforms)
device.awgs[0].single(True)
device.awgs[0].enable(True)
```
2 changes: 1 addition & 1 deletion examples/hdawg_precomp_curve_fit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/hf2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/nodetree.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
7 changes: 4 additions & 3 deletions examples/scope_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand All @@ -28,8 +28,7 @@ Requirements:

* LabOne Version >= 22.02
* Instruments:
1 x MF or UHF Instrument with DIG Option (HF2 does not support
multi-channel recording).
1 x MF or UHF Instrument with DIG Option (HF2 does not support multi-channel recording).

```python
from zhinst.toolkit import Session
Expand Down Expand Up @@ -269,6 +268,8 @@ _, (ax1, ax2) = plt.subplots(2)
plot_time_domain(ax1, data_no_trig, SCOPE_CHANNEL)
ax1.set_title(f"{len(data_no_trig)} Scope records from {device} (triggering disabled)")

plt.subplots_adjust(hspace = 1)

# Plot the scope data with triggering enabled.
plot_time_domain(ax2, data_with_trig, SCOPE_CHANNEL)
ax2.axvline(0.0, linewidth=2, linestyle="--", color="k", label="Trigger time")
Expand Down
6 changes: 1 addition & 5 deletions examples/shfqa_qubit_readout_measurement.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down Expand Up @@ -173,7 +173,3 @@ plt.ylabel("imaginary part")
plt.grid()
plt.show()
```

```python

```
2 changes: 1 addition & 1 deletion examples/shfqa_qubit_readout_weights.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/shfqa_sweeper.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
4 changes: 2 additions & 2 deletions examples/shfqc_propagation_delay.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down
4 changes: 2 additions & 2 deletions examples/shfqc_qubit_spectroscopy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down
4 changes: 2 additions & 2 deletions examples/shfqc_rabi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down
4 changes: 2 additions & 2 deletions examples/shfqc_resonator_spectroscopy_cw.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down
4 changes: 2 additions & 2 deletions examples/shfqc_resonator_spectroscopy_cw_power.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down
2 changes: 1 addition & 1 deletion examples/shfsg_rabi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/shfsg_sine.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/sweeper_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/uhf_boxcar.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
2 changes: 1 addition & 1 deletion examples/uhfqa_result_unit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.7
jupytext_version: 1.14.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
1 change: 1 addition & 0 deletions src/zhinst/toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
"PollFlags",
"Session",
"Waveforms",
"Sequence",
]
2 changes: 1 addition & 1 deletion src/zhinst/toolkit/driver/devices/shfsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def available_trigger_slopes(self) -> t.List[str]:

@property
def available_marker_outputs(self) -> t.List[str]:
"""List the available trigger slopes for the sequencer."""
"""List the available trigger marker outputs for the sequencer."""
return [
option.enum
for option in self.root.sgchannels[
Expand Down
5 changes: 4 additions & 1 deletion src/zhinst/toolkit/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def __init__(self, session: "Session"):
self._session = session

def __repr__(self):
return f"LabOneModules({self._session.daq_server.host}:{self._session.daq_server.port})"
return str(
"LabOneModules("
f"{self._session.daq_server.host}:{self._session.daq_server.port})"
)

def create_awg_module(self) -> tk_modules.BaseModule:
"""Create an instance of the AwgModule.
Expand Down
Loading

0 comments on commit 406e209

Please sign in to comment.