-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_pulse_to_cloud.py
47 lines (38 loc) · 1.25 KB
/
send_pulse_to_cloud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# create a pulse and send it to the Q-CTRL cloud
import numpy as np
from qctrl import Qctrl
import os
import matplotlib.pyplot as plt
import numpy as np
from qctrlvisualizer import get_qctrl_style, plot_controls
qctrl = Qctrl(email=os.getenv('EMAIL'), password=os.getenv('PASSWORD'))
control_count = 5
segment_count = 16
duration = 30.0
shot_count = 32
controls = []
for k in range(control_count):
# Create a random string of complex numbers for each controls.
real_part = np.random.random(size=[segment_count])
imag_part = np.random.random(size=[segment_count])
print(real_part, imag_part)
values = 0.15 * k * (real_part + 1j * imag_part)
print(values)
controls.append({"duration": duration, "values": values})
# Plot the last control as an example.
plot_controls(
figure=plt.figure(),
controls={
"$\Omega$": [
{"duration": duration / segment_count, "value": value} for value in values
]
},
)
# Obtain the results of the experiment.
experiment_results = qctrl.functions.calculate_qchack_measurements(
controls=controls,
shot_count=shot_count,
)
measurements = experiment_results.measurements
for k, measurement_counts in enumerate(measurements):
print(f"control #{k}: {measurement_counts}")