| 1 |
""" |
| 2 |
Example of remote control of DataLab current session, |
| 3 |
from a Python script running outside DataLab (e.g. in Spyder) |
| 4 |
|
| 5 |
Created on Fri May 12 12:28:56 2023 |
| 6 |
|
| 7 |
@author: p.raybaut |
| 8 |
""" |
| 9 |
|
| 10 |
# %% Importing necessary modules |
| 11 |
|
| 12 |
# NumPy for numerical array computations: |
| 13 |
import numpy as np |
| 14 |
|
| 15 |
# DataLab remote control client: |
| 16 |
from sigima.client import SimpleRemoteProxy as RemoteProxy |
| 17 |
|
| 18 |
# %% Connecting to DataLab current session |
| 19 |
|
| 20 |
proxy = RemoteProxy() |
| 21 |
|
| 22 |
# %% Executing commands in DataLab (...) |
| 23 |
|
| 24 |
z = np.random.rand(20, 20) |
| 25 |
proxy.add_image("toto", z) |
| 26 |
|
| 27 |
# %% Executing commands in DataLab (...) |
| 28 |
|
| 29 |
proxy.toggle_auto_refresh(False) # Turning off auto-refresh |
| 30 |
x = np.array([1.0, 2.0, 3.0]) |
| 31 |
y = np.array([4.0, 5.0, -1.0]) |
| 32 |
proxy.add_signal("toto", x, y) |
| 33 |
|
| 34 |
# %% Executing commands in DataLab (...) |
| 35 |
|
| 36 |
proxy.calc("derivative") |
| 37 |
proxy.toggle_auto_refresh(True) # Turning on auto-refresh |
| 38 |
|
| 39 |
# %% Executing commands in DataLab (...) |
| 40 |
|
| 41 |
proxy.set_current_panel("image") |
| 42 |
|
| 43 |
# %% Executing a lot of commands without refreshing DataLab |
| 44 |
|
| 45 |
z = np.random.rand(400, 400) |
| 46 |
proxy.add_image("foobar", z) |
| 47 |
with proxy.context_no_refresh(): |
| 48 |
for _idx in range(100): |
| 49 |
proxy.calc("fft") |