QuLab 2.10.10__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qulab/__init__.py +33 -0
- qulab/__main__.py +4 -0
- qulab/cli/__init__.py +0 -0
- qulab/cli/commands.py +30 -0
- qulab/cli/config.py +170 -0
- qulab/cli/decorators.py +28 -0
- qulab/dicttree.py +523 -0
- qulab/executor/__init__.py +5 -0
- qulab/executor/analyze.py +188 -0
- qulab/executor/cli.py +434 -0
- qulab/executor/load.py +563 -0
- qulab/executor/registry.py +185 -0
- qulab/executor/schedule.py +543 -0
- qulab/executor/storage.py +615 -0
- qulab/executor/template.py +259 -0
- qulab/executor/utils.py +194 -0
- qulab/expression.py +827 -0
- qulab/fun.cp313-win_amd64.pyd +0 -0
- qulab/monitor/__init__.py +1 -0
- qulab/monitor/__main__.py +8 -0
- qulab/monitor/config.py +41 -0
- qulab/monitor/dataset.py +77 -0
- qulab/monitor/event_queue.py +54 -0
- qulab/monitor/mainwindow.py +234 -0
- qulab/monitor/monitor.py +115 -0
- qulab/monitor/ploter.py +123 -0
- qulab/monitor/qt_compat.py +16 -0
- qulab/monitor/toolbar.py +265 -0
- qulab/scan/__init__.py +2 -0
- qulab/scan/curd.py +221 -0
- qulab/scan/models.py +554 -0
- qulab/scan/optimize.py +76 -0
- qulab/scan/query.py +387 -0
- qulab/scan/record.py +603 -0
- qulab/scan/scan.py +1166 -0
- qulab/scan/server.py +450 -0
- qulab/scan/space.py +213 -0
- qulab/scan/utils.py +234 -0
- qulab/storage/__init__.py +0 -0
- qulab/storage/__main__.py +51 -0
- qulab/storage/backend/__init__.py +0 -0
- qulab/storage/backend/redis.py +204 -0
- qulab/storage/base_dataset.py +352 -0
- qulab/storage/chunk.py +60 -0
- qulab/storage/dataset.py +127 -0
- qulab/storage/file.py +273 -0
- qulab/storage/models/__init__.py +22 -0
- qulab/storage/models/base.py +4 -0
- qulab/storage/models/config.py +28 -0
- qulab/storage/models/file.py +89 -0
- qulab/storage/models/ipy.py +58 -0
- qulab/storage/models/models.py +88 -0
- qulab/storage/models/record.py +161 -0
- qulab/storage/models/report.py +22 -0
- qulab/storage/models/tag.py +93 -0
- qulab/storage/storage.py +95 -0
- qulab/sys/__init__.py +2 -0
- qulab/sys/chat.py +688 -0
- qulab/sys/device/__init__.py +3 -0
- qulab/sys/device/basedevice.py +255 -0
- qulab/sys/device/loader.py +86 -0
- qulab/sys/device/utils.py +79 -0
- qulab/sys/drivers/FakeInstrument.py +68 -0
- qulab/sys/drivers/__init__.py +0 -0
- qulab/sys/ipy_events.py +125 -0
- qulab/sys/net/__init__.py +0 -0
- qulab/sys/net/bencoder.py +205 -0
- qulab/sys/net/cli.py +169 -0
- qulab/sys/net/dhcp.py +543 -0
- qulab/sys/net/dhcpd.py +176 -0
- qulab/sys/net/kad.py +1142 -0
- qulab/sys/net/kcp.py +192 -0
- qulab/sys/net/nginx.py +194 -0
- qulab/sys/progress.py +190 -0
- qulab/sys/rpc/__init__.py +0 -0
- qulab/sys/rpc/client.py +0 -0
- qulab/sys/rpc/exceptions.py +96 -0
- qulab/sys/rpc/msgpack.py +1052 -0
- qulab/sys/rpc/msgpack.pyi +41 -0
- qulab/sys/rpc/router.py +35 -0
- qulab/sys/rpc/rpc.py +412 -0
- qulab/sys/rpc/serialize.py +139 -0
- qulab/sys/rpc/server.py +29 -0
- qulab/sys/rpc/socket.py +29 -0
- qulab/sys/rpc/utils.py +25 -0
- qulab/sys/rpc/worker.py +0 -0
- qulab/sys/rpc/zmq_socket.py +227 -0
- qulab/tools/__init__.py +0 -0
- qulab/tools/connection_helper.py +39 -0
- qulab/typing.py +2 -0
- qulab/utils.py +95 -0
- qulab/version.py +1 -0
- qulab/visualization/__init__.py +188 -0
- qulab/visualization/__main__.py +71 -0
- qulab/visualization/_autoplot.py +464 -0
- qulab/visualization/plot_circ.py +319 -0
- qulab/visualization/plot_layout.py +408 -0
- qulab/visualization/plot_seq.py +242 -0
- qulab/visualization/qdat.py +152 -0
- qulab/visualization/rot3d.py +23 -0
- qulab/visualization/widgets.py +86 -0
- qulab-2.10.10.dist-info/METADATA +110 -0
- qulab-2.10.10.dist-info/RECORD +107 -0
- qulab-2.10.10.dist-info/WHEEL +5 -0
- qulab-2.10.10.dist-info/entry_points.txt +2 -0
- qulab-2.10.10.dist-info/licenses/LICENSE +21 -0
- qulab-2.10.10.dist-info/top_level.txt +1 -0
@@ -0,0 +1,464 @@
|
|
1
|
+
import math
|
2
|
+
|
3
|
+
import matplotlib.pyplot as plt
|
4
|
+
import numpy as np
|
5
|
+
from matplotlib.colors import LogNorm, Normalize, SymLogNorm
|
6
|
+
from matplotlib.ticker import EngFormatter, LogFormatterSciNotation
|
7
|
+
from scipy.interpolate import griddata
|
8
|
+
|
9
|
+
|
10
|
+
def good_for_logscale(x, threshold=4):
|
11
|
+
if np.any(x <= 0):
|
12
|
+
return False
|
13
|
+
mid = (np.nanmin(x) + np.nanmax(x)) / 2
|
14
|
+
a = np.count_nonzero(np.nan_to_num(x <= mid, nan=0))
|
15
|
+
b = np.count_nonzero(np.nan_to_num(x >= mid, nan=0))
|
16
|
+
if a / b > threshold:
|
17
|
+
return True
|
18
|
+
return False
|
19
|
+
|
20
|
+
|
21
|
+
def equal_logspace(x):
|
22
|
+
logx = np.logspace(np.log10(x[0]), np.log10(x[-1]), len(x))
|
23
|
+
return np.allclose(x, logx)
|
24
|
+
|
25
|
+
|
26
|
+
def equal_linspace(x):
|
27
|
+
linearx = np.linspace(x[0], x[-1], len(x))
|
28
|
+
return np.allclose(x, linearx)
|
29
|
+
|
30
|
+
|
31
|
+
def as_1d_data(x, y, z):
|
32
|
+
x = np.asarray(x)
|
33
|
+
y = np.asarray(y)
|
34
|
+
z = np.asarray(z)
|
35
|
+
if z.ndim == 1:
|
36
|
+
return x, y, z
|
37
|
+
|
38
|
+
if z.ndim == 2:
|
39
|
+
x, y = np.meshgrid(x, y)
|
40
|
+
return x.ravel(), y.ravel(), z.ravel()
|
41
|
+
|
42
|
+
raise ValueError("z must be 1D or 2D")
|
43
|
+
|
44
|
+
|
45
|
+
def griddata_logx_logy(x, y, z, shape=(401, 401)):
|
46
|
+
x, y, z = as_1d_data(x, y, z)
|
47
|
+
xspace = np.logspace(np.log10(x.min()), np.log10(x.max()), shape[0])
|
48
|
+
yspace = np.logspace(np.log10(y.min()), np.log10(y.max()), shape[1])
|
49
|
+
xgrid, ygrid = np.meshgrid(xspace, yspace)
|
50
|
+
zgrid = griddata((x, y), z, (xgrid, ygrid), method='nearest')
|
51
|
+
return xspace, yspace, zgrid
|
52
|
+
|
53
|
+
|
54
|
+
def griddata_logx_linear_y(x, y, z, shape=(401, 401)):
|
55
|
+
x, y, z = as_1d_data(x, y, z)
|
56
|
+
xspace = np.logspace(np.log10(x.min()), np.log10(x.max()), shape[0])
|
57
|
+
yspace = np.linspace(y.min(), y.max(), shape[1])
|
58
|
+
xgrid, ygrid = np.meshgrid(xspace, yspace)
|
59
|
+
zgrid = griddata((x, y), z, (xgrid, ygrid), method='nearest')
|
60
|
+
return xspace, yspace, zgrid
|
61
|
+
|
62
|
+
|
63
|
+
def griddata_linear_x_logy(x, y, z, shape=(401, 401)):
|
64
|
+
x, y, z = as_1d_data(x, y, z)
|
65
|
+
xspace = np.linspace(x.min(), x.max(), shape[0])
|
66
|
+
yspace = np.logspace(np.log10(y.min()), np.log10(y.max()), shape[1])
|
67
|
+
xgrid, ygrid = np.meshgrid(xspace, yspace)
|
68
|
+
zgrid = griddata((x, y), z, (xgrid, ygrid), method='nearest')
|
69
|
+
return xspace, yspace, zgrid
|
70
|
+
|
71
|
+
|
72
|
+
def griddata_linear_x_linear_y(x, y, z, shape=(401, 401)):
|
73
|
+
x, y, z = as_1d_data(x, y, z)
|
74
|
+
xspace = np.linspace(x.min(), x.max(), shape[0])
|
75
|
+
yspace = np.linspace(y.min(), y.max(), shape[1])
|
76
|
+
xgrid, ygrid = np.meshgrid(xspace, yspace)
|
77
|
+
zgrid = griddata((x, y), z, (xgrid, ygrid), method='nearest')
|
78
|
+
return xspace, yspace, zgrid
|
79
|
+
|
80
|
+
|
81
|
+
def _get_log_ticks(x):
|
82
|
+
log10x = np.log10(x)
|
83
|
+
|
84
|
+
major_ticks = np.array(
|
85
|
+
range(math.floor(log10x[0]) - 1,
|
86
|
+
math.ceil(log10x[-1]) + 1))
|
87
|
+
minor_ticks = np.hstack([
|
88
|
+
np.log10(np.linspace(2, 10, 9, endpoint=False)) + x
|
89
|
+
for x in major_ticks
|
90
|
+
])
|
91
|
+
|
92
|
+
major_ticks = major_ticks[(major_ticks >= log10x[0]) *
|
93
|
+
(major_ticks <= log10x[-1])]
|
94
|
+
minor_ticks = minor_ticks[(minor_ticks >= log10x[0]) *
|
95
|
+
(minor_ticks <= log10x[-1])]
|
96
|
+
|
97
|
+
return log10x, major_ticks, minor_ticks
|
98
|
+
|
99
|
+
|
100
|
+
class MyLogFormatter(EngFormatter):
|
101
|
+
|
102
|
+
def format_ticks(self, values):
|
103
|
+
if self.unit is None or self.unit == '':
|
104
|
+
fmt = LogFormatterSciNotation()
|
105
|
+
return [f"${fmt.format_data(10.0**x)}$" for x in values]
|
106
|
+
else:
|
107
|
+
return super().format_ticks(values)
|
108
|
+
|
109
|
+
def format_eng(self, x):
|
110
|
+
if self.unit is None or self.unit == '':
|
111
|
+
self.unit = ''
|
112
|
+
return f"{10.0**x:g}"
|
113
|
+
else:
|
114
|
+
return super().format_eng(10.0**x)
|
115
|
+
|
116
|
+
|
117
|
+
def imshow_logx(x, y, z, x_unit=None, ax=None, **kwargs):
|
118
|
+
if ax is None:
|
119
|
+
ax = plt.gca()
|
120
|
+
|
121
|
+
log10x, major_ticks, minor_ticks = _get_log_ticks(x)
|
122
|
+
|
123
|
+
dlogx, dy = log10x[1] - log10x[0], y[1] - y[0]
|
124
|
+
extent = (log10x[0] - dlogx / 2, log10x[-1] + dlogx / 2, y[0] - dy / 2,
|
125
|
+
y[-1] + dy / 2)
|
126
|
+
|
127
|
+
img = ax.imshow(z, extent=extent, **kwargs)
|
128
|
+
|
129
|
+
ax.set_xticks(major_ticks, minor=False)
|
130
|
+
ax.xaxis.set_major_formatter(MyLogFormatter(x_unit))
|
131
|
+
ax.set_xticks(minor_ticks, minor=True)
|
132
|
+
|
133
|
+
return img
|
134
|
+
|
135
|
+
|
136
|
+
def imshow_logy(x, y, z, y_unit=None, ax=None, **kwargs):
|
137
|
+
if ax is None:
|
138
|
+
ax = plt.gca()
|
139
|
+
|
140
|
+
log10y, major_ticks, minor_ticks = _get_log_ticks(y)
|
141
|
+
|
142
|
+
dlogy, dx = log10y[1] - log10y[0], x[1] - x[0]
|
143
|
+
extent = (x[0] - dx / 2, x[-1] + dx / 2, log10y[0] - dlogy / 2,
|
144
|
+
log10y[-1] + dlogy / 2)
|
145
|
+
|
146
|
+
img = ax.imshow(z, extent=extent, **kwargs)
|
147
|
+
|
148
|
+
ax.set_yticks(major_ticks, minor=False)
|
149
|
+
ax.yaxis.set_major_formatter(MyLogFormatter(y_unit))
|
150
|
+
ax.set_yticks(minor_ticks, minor=True)
|
151
|
+
|
152
|
+
return img
|
153
|
+
|
154
|
+
|
155
|
+
def imshow_loglog(x, y, z, x_unit=None, y_unit=None, ax=None, **kwargs):
|
156
|
+
if ax is None:
|
157
|
+
ax = plt.gca()
|
158
|
+
|
159
|
+
log10x, x_major_ticks, x_minor_ticks = _get_log_ticks(x)
|
160
|
+
log10y, y_major_ticks, y_minor_ticks = _get_log_ticks(y)
|
161
|
+
|
162
|
+
dlogx, dlogy = log10x[1] - log10x[0], log10y[1] - log10y[0]
|
163
|
+
extent = (log10x[0] - dlogx / 2, log10x[-1] + dlogx / 2,
|
164
|
+
log10y[0] - dlogy / 2, log10y[-1] + dlogy / 2)
|
165
|
+
|
166
|
+
img = ax.imshow(z, extent=extent, **kwargs)
|
167
|
+
|
168
|
+
ax.set_xticks(x_major_ticks, minor=False)
|
169
|
+
ax.xaxis.set_major_formatter(MyLogFormatter(x_unit))
|
170
|
+
ax.set_xticks(x_minor_ticks, minor=True)
|
171
|
+
|
172
|
+
ax.set_yticks(y_major_ticks, minor=False)
|
173
|
+
ax.yaxis.set_major_formatter(MyLogFormatter(y_unit))
|
174
|
+
ax.set_yticks(y_minor_ticks, minor=True)
|
175
|
+
|
176
|
+
return img
|
177
|
+
|
178
|
+
|
179
|
+
def plot_lines(x,
|
180
|
+
y,
|
181
|
+
z,
|
182
|
+
xlabel,
|
183
|
+
ylabel,
|
184
|
+
zlabel,
|
185
|
+
x_unit,
|
186
|
+
y_unit,
|
187
|
+
z_unit,
|
188
|
+
ax,
|
189
|
+
xscale='linear',
|
190
|
+
yscale='linear',
|
191
|
+
zscale='linear',
|
192
|
+
index=None,
|
193
|
+
**kwds):
|
194
|
+
z = np.asarray(z)
|
195
|
+
if len(y) > len(x):
|
196
|
+
x, y = y, x
|
197
|
+
xlabel, ylabel = ylabel, xlabel
|
198
|
+
xscale, yscale = yscale, xscale
|
199
|
+
z = z.T
|
200
|
+
if index is not None:
|
201
|
+
y = y[index]
|
202
|
+
z = z[index, :]
|
203
|
+
|
204
|
+
for i, l in enumerate(y):
|
205
|
+
if y_unit:
|
206
|
+
label = f"{ylabel}={l:.3} [{y_unit}]"
|
207
|
+
else:
|
208
|
+
if isinstance(l, float):
|
209
|
+
label = f"{ylabel}={l:.3}"
|
210
|
+
else:
|
211
|
+
label = f"{ylabel}={l}"
|
212
|
+
ax.plot(x, z[i, :], label=label, **kwds)
|
213
|
+
ax.legend()
|
214
|
+
xlabel = f"{xlabel} [{x_unit}]" if x_unit else xlabel
|
215
|
+
zlabel = f"{zlabel} [{z_unit}]" if z_unit else zlabel
|
216
|
+
ax.set_xlabel(xlabel)
|
217
|
+
ax.set_ylabel(zlabel)
|
218
|
+
ax.set_xscale(xscale)
|
219
|
+
ax.set_yscale(zscale)
|
220
|
+
|
221
|
+
|
222
|
+
def plot_img(x,
|
223
|
+
y,
|
224
|
+
z,
|
225
|
+
xlabel,
|
226
|
+
ylabel,
|
227
|
+
zlabel,
|
228
|
+
x_unit,
|
229
|
+
y_unit,
|
230
|
+
z_unit,
|
231
|
+
fig,
|
232
|
+
ax,
|
233
|
+
xscale='linear',
|
234
|
+
yscale='linear',
|
235
|
+
zscale='linear',
|
236
|
+
resolution=None,
|
237
|
+
**kwds):
|
238
|
+
kwds.setdefault('origin', 'lower')
|
239
|
+
kwds.setdefault('aspect', 'auto')
|
240
|
+
kwds.setdefault('interpolation', 'nearest')
|
241
|
+
|
242
|
+
vmin = kwds.pop('vmin', np.nanmin(z))
|
243
|
+
vmax = kwds.pop('vmax', np.nanmax(z))
|
244
|
+
if zscale == 'log':
|
245
|
+
kwds.setdefault('norm', LogNorm(vmax=vmax, vmin=vmin))
|
246
|
+
elif zscale == 'symlog':
|
247
|
+
kwds.setdefault('norm', SymLogNorm(vmax=vmax,
|
248
|
+
vmin=vmin,
|
249
|
+
linthresh=1e-5))
|
250
|
+
else:
|
251
|
+
kwds.setdefault('norm', Normalize(vmin=vmin, vmax=vmax))
|
252
|
+
zlabel = f"{zlabel} [{z_unit}]" if z_unit else zlabel
|
253
|
+
|
254
|
+
band_area = False
|
255
|
+
if x.ndim == 1 and y.ndim == 2 and y.shape[1] == x.shape[0]:
|
256
|
+
x = np.asarray([x] * y.shape[0])
|
257
|
+
band_area = True
|
258
|
+
elif x.ndim == 2 and y.ndim == 1 and x.shape[0] == y.shape[0]:
|
259
|
+
y = np.asarray([y] * x.shape[1]).T
|
260
|
+
band_area = True
|
261
|
+
if band_area:
|
262
|
+
kwds.pop('origin', None)
|
263
|
+
kwds.pop('aspect', None)
|
264
|
+
kwds.pop('interpolation', None)
|
265
|
+
shading = kwds.pop('shading', 'nearest')
|
266
|
+
pc = ax.pcolormesh(x, y, z, shading=shading, **kwds)
|
267
|
+
xlabel = f"{xlabel} [{x_unit}]" if x_unit else xlabel
|
268
|
+
ylabel = f"{ylabel} [{y_unit}]" if y_unit else ylabel
|
269
|
+
ax.set_xlabel(xlabel)
|
270
|
+
ax.set_ylabel(ylabel)
|
271
|
+
cb = fig.colorbar(pc, ax=ax)
|
272
|
+
ax.set_xscale(xscale)
|
273
|
+
ax.set_yscale(yscale)
|
274
|
+
cb.set_label(zlabel)
|
275
|
+
return
|
276
|
+
|
277
|
+
if resolution is None:
|
278
|
+
resolution = (401, 401)
|
279
|
+
elif isinstance(resolution, int):
|
280
|
+
resolution = (resolution, resolution)
|
281
|
+
|
282
|
+
if (z.ndim == 1 or (xscale == 'linear' and not equal_linspace(x))
|
283
|
+
or (yscale == 'linear' and not equal_linspace(y))
|
284
|
+
or (xscale == 'log' and not equal_logspace(x))
|
285
|
+
or (yscale == 'log' and not equal_logspace(y))):
|
286
|
+
griddata = {
|
287
|
+
('log', 'log'): griddata_logx_logy,
|
288
|
+
('log', 'linear'): griddata_logx_linear_y,
|
289
|
+
('linear', 'log'): griddata_linear_x_logy,
|
290
|
+
('linear', 'linear'): griddata_linear_x_linear_y,
|
291
|
+
}[(xscale, yscale)]
|
292
|
+
x, y, z = griddata(x, y, z, resolution)
|
293
|
+
|
294
|
+
if (xscale, yscale) == ('linear', 'linear'):
|
295
|
+
dx, dy = x[1] - x[0], y[1] - y[0]
|
296
|
+
extent = (x[0] - dx / 2, x[-1] + dx / 2, y[0] - dy / 2, y[-1] + dy / 2)
|
297
|
+
kwds.setdefault('extent', extent)
|
298
|
+
img = ax.imshow(np.asarray(z), **kwds)
|
299
|
+
xlabel = f"{xlabel} [{x_unit}]" if x_unit else xlabel
|
300
|
+
ylabel = f"{ylabel} [{y_unit}]" if y_unit else ylabel
|
301
|
+
elif (xscale, yscale) == ('log', 'linear'):
|
302
|
+
ylabel = f"{ylabel} [{y_unit}]" if y_unit else ylabel
|
303
|
+
img = imshow_logx(x, y, z, x_unit, ax, **kwds)
|
304
|
+
elif (xscale, yscale) == ('linear', 'log'):
|
305
|
+
xlabel = f"{xlabel} [{x_unit}]" if x_unit else xlabel
|
306
|
+
img = imshow_logy(x, y, z, y_unit, ax, **kwds)
|
307
|
+
elif (xscale, yscale) == ('log', 'log'):
|
308
|
+
img = imshow_loglog(x, y, z, x_unit, y_unit, ax, **kwds)
|
309
|
+
else:
|
310
|
+
pass
|
311
|
+
ax.set_xlabel(xlabel)
|
312
|
+
ax.set_ylabel(ylabel)
|
313
|
+
cb = fig.colorbar(img, ax=ax, norm=kwds.get('norm', None))
|
314
|
+
cb.set_label(zlabel)
|
315
|
+
|
316
|
+
|
317
|
+
def plot_scatter(x,
|
318
|
+
y,
|
319
|
+
z,
|
320
|
+
xlabel,
|
321
|
+
ylabel,
|
322
|
+
zlabel,
|
323
|
+
x_unit,
|
324
|
+
y_unit,
|
325
|
+
z_unit,
|
326
|
+
fig,
|
327
|
+
ax,
|
328
|
+
xscale='linear',
|
329
|
+
yscale='linear',
|
330
|
+
zscale='linear',
|
331
|
+
**kwds):
|
332
|
+
if np.any(np.iscomplex(z)):
|
333
|
+
s = np.abs(z)
|
334
|
+
c = np.angle(z)
|
335
|
+
else:
|
336
|
+
s = np.abs(z)
|
337
|
+
c = z.real
|
338
|
+
ax.scatter(x, y, s=s, c=c, **kwds)
|
339
|
+
xlabel = f"{xlabel} [{x_unit}]" if x_unit else xlabel
|
340
|
+
ylabel = f"{ylabel} [{y_unit}]" if y_unit else ylabel
|
341
|
+
ax.set_xlabel(xlabel)
|
342
|
+
ax.set_ylabel(ylabel)
|
343
|
+
ax.set_xscale(xscale)
|
344
|
+
ax.set_yscale(yscale)
|
345
|
+
|
346
|
+
|
347
|
+
def autoplot(x,
|
348
|
+
y,
|
349
|
+
z,
|
350
|
+
xlabel='x',
|
351
|
+
ylabel='y',
|
352
|
+
zlabel='z',
|
353
|
+
x_unit='',
|
354
|
+
y_unit='',
|
355
|
+
z_unit='',
|
356
|
+
fig=None,
|
357
|
+
ax=None,
|
358
|
+
index=None,
|
359
|
+
xscale='auto',
|
360
|
+
yscale='auto',
|
361
|
+
zscale='auto',
|
362
|
+
max_lines=3,
|
363
|
+
scatter_lim=1000,
|
364
|
+
resolution=None,
|
365
|
+
**kwds):
|
366
|
+
"""
|
367
|
+
Plot a 2D array as a line plot or an image.
|
368
|
+
|
369
|
+
Parameters:
|
370
|
+
x (array): x values
|
371
|
+
y (array): y values
|
372
|
+
z (array): z values
|
373
|
+
xlabel (str): x label
|
374
|
+
ylabel (str): y label
|
375
|
+
zlabel (str): z label
|
376
|
+
x_unit (str): x unit
|
377
|
+
y_unit (str): y unit
|
378
|
+
z_unit (str): z unit
|
379
|
+
fig (Figure): figure to plot on
|
380
|
+
ax (Axes): axes to plot on
|
381
|
+
index (int): index of the line to plot
|
382
|
+
xscale (str): x scale 'auto', 'linear' or 'log'
|
383
|
+
yscale (str): y scale 'auto', 'linear' or 'log'
|
384
|
+
zscale (str): z scale 'auto', 'linear' or 'log'
|
385
|
+
max_lines (int): maximum number of lines to plot
|
386
|
+
**kwds: keyword arguments passed to plot_img or plot_lines
|
387
|
+
"""
|
388
|
+
if ax is not None:
|
389
|
+
fig = ax.figure
|
390
|
+
if fig is None:
|
391
|
+
fig = plt.gcf()
|
392
|
+
if ax is None:
|
393
|
+
ax = fig.add_subplot(111)
|
394
|
+
|
395
|
+
x = np.asarray(x)
|
396
|
+
y = np.asarray(y)
|
397
|
+
z = np.asarray(z)
|
398
|
+
|
399
|
+
if xscale == 'auto':
|
400
|
+
if good_for_logscale(x):
|
401
|
+
xscale = 'log'
|
402
|
+
else:
|
403
|
+
xscale = 'linear'
|
404
|
+
if yscale == 'auto':
|
405
|
+
if good_for_logscale(y):
|
406
|
+
yscale = 'log'
|
407
|
+
else:
|
408
|
+
yscale = 'linear'
|
409
|
+
if zscale == 'auto':
|
410
|
+
if good_for_logscale(z):
|
411
|
+
zscale = 'log'
|
412
|
+
else:
|
413
|
+
zscale = 'linear'
|
414
|
+
|
415
|
+
if x.shape == y.shape == z.shape and z.size < scatter_lim:
|
416
|
+
plot_scatter(x,
|
417
|
+
y,
|
418
|
+
z,
|
419
|
+
xlabel,
|
420
|
+
ylabel,
|
421
|
+
zlabel,
|
422
|
+
x_unit,
|
423
|
+
y_unit,
|
424
|
+
z_unit,
|
425
|
+
fig,
|
426
|
+
ax,
|
427
|
+
xscale=xscale,
|
428
|
+
yscale=yscale,
|
429
|
+
zscale=zscale,
|
430
|
+
**kwds)
|
431
|
+
elif z.ndim == 2 and (len(y) <= max_lines or len(x) <= max_lines
|
432
|
+
or index is not None):
|
433
|
+
plot_lines(x,
|
434
|
+
y,
|
435
|
+
z,
|
436
|
+
xlabel,
|
437
|
+
ylabel,
|
438
|
+
zlabel,
|
439
|
+
x_unit=x_unit,
|
440
|
+
y_unit=y_unit,
|
441
|
+
z_unit=z_unit,
|
442
|
+
xscale=xscale,
|
443
|
+
yscale=yscale,
|
444
|
+
zscale=zscale,
|
445
|
+
ax=ax,
|
446
|
+
index=index,
|
447
|
+
**kwds)
|
448
|
+
else:
|
449
|
+
plot_img(x,
|
450
|
+
y,
|
451
|
+
z,
|
452
|
+
xlabel,
|
453
|
+
ylabel,
|
454
|
+
zlabel,
|
455
|
+
x_unit=x_unit,
|
456
|
+
y_unit=y_unit,
|
457
|
+
z_unit=z_unit,
|
458
|
+
xscale=xscale,
|
459
|
+
yscale=yscale,
|
460
|
+
zscale=zscale,
|
461
|
+
fig=fig,
|
462
|
+
ax=ax,
|
463
|
+
resolution=resolution,
|
464
|
+
**kwds)
|