mwxlib 1.5.0__py3-none-any.whl → 1.5.10__py3-none-any.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.
Potentially problematic release.
This version of mwxlib might be problematic. Click here for more details.
- mwx/bookshelf.py +19 -13
- mwx/controls.py +10 -10
- mwx/framework.py +85 -71
- mwx/graphman.py +114 -112
- mwx/matplot2.py +13 -12
- mwx/matplot2g.py +22 -30
- mwx/matplot2lg.py +10 -10
- mwx/mgplt.py +1 -1
- mwx/nutshell.py +110 -79
- mwx/plugins/ffmpeg_view.py +3 -4
- mwx/plugins/fft_view.py +2 -2
- mwx/plugins/frame_listview.py +12 -7
- mwx/testsuite.py +10 -10
- mwx/utilus.py +17 -11
- mwx/wxpdb.py +3 -3
- {mwxlib-1.5.0.dist-info → mwxlib-1.5.10.dist-info}/METADATA +1 -1
- mwxlib-1.5.10.dist-info/RECORD +28 -0
- {mwxlib-1.5.0.dist-info → mwxlib-1.5.10.dist-info}/WHEEL +1 -1
- mwxlib-1.5.0.dist-info/RECORD +0 -28
- {mwxlib-1.5.0.dist-info → mwxlib-1.5.10.dist-info}/top_level.txt +0 -0
mwx/matplot2g.py
CHANGED
|
@@ -109,9 +109,9 @@ def _to_image(src, cutoff=0, threshold=None, binning=1):
|
|
|
109
109
|
|
|
110
110
|
def _Property(name):
|
|
111
111
|
return property(
|
|
112
|
-
lambda self:
|
|
113
|
-
lambda self,v: setattr(self.parent, name, v),
|
|
114
|
-
lambda self:
|
|
112
|
+
lambda self: getattr(self.parent, name),
|
|
113
|
+
lambda self, v: setattr(self.parent, name, v),
|
|
114
|
+
lambda self: delattr(self.parent, name))
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
class AxesImagePhantom:
|
|
@@ -227,7 +227,7 @@ class AxesImagePhantom:
|
|
|
227
227
|
|
|
228
228
|
clim = property(
|
|
229
229
|
lambda self: self.__art.get_clim(),
|
|
230
|
-
lambda self,v: self.__art.set_clim(v),
|
|
230
|
+
lambda self, v: self.__art.set_clim(v),
|
|
231
231
|
doc="Lower/Upper color limit values of the buffer.")
|
|
232
232
|
|
|
233
233
|
attributes = property(
|
|
@@ -236,12 +236,12 @@ class AxesImagePhantom:
|
|
|
236
236
|
|
|
237
237
|
pathname = property(
|
|
238
238
|
lambda self: self.__attributes.get('pathname'),
|
|
239
|
-
lambda self,v: self.update_attr({'pathname': v}),
|
|
239
|
+
lambda self, v: self.update_attr({'pathname': v}),
|
|
240
240
|
doc="Fullpath of the buffer, if bound to a file.")
|
|
241
241
|
|
|
242
242
|
annotation = property(
|
|
243
243
|
lambda self: self.__attributes.get('annotation', ''),
|
|
244
|
-
lambda self,v: self.update_attr({'annotation': v}),
|
|
244
|
+
lambda self, v: self.update_attr({'annotation': v}),
|
|
245
245
|
doc="Annotation of the buffer.")
|
|
246
246
|
|
|
247
247
|
@property
|
|
@@ -321,9 +321,9 @@ class AxesImagePhantom:
|
|
|
321
321
|
"""Current buffer ROI (region of interest)."""
|
|
322
322
|
if self.parent.region.size:
|
|
323
323
|
nx, ny = self.xytopixel(*self.parent.region)
|
|
324
|
-
sx = slice(max(0,nx[0]), nx[1])
|
|
325
|
-
sy = slice(max(0,ny[1]), ny[0])
|
|
326
|
-
return self.__buf[sy,sx]
|
|
324
|
+
sx = slice(max(0, nx[0]), nx[1]) # nx slice
|
|
325
|
+
sy = slice(max(0, ny[1]), ny[0]) # ny slice 反転 (降順)
|
|
326
|
+
return self.__buf[sy, sx]
|
|
327
327
|
return self.__buf
|
|
328
328
|
|
|
329
329
|
@roi.setter
|
|
@@ -342,7 +342,7 @@ class AxesImagePhantom:
|
|
|
342
342
|
|
|
343
343
|
def xytoc(self, x, y=None, nearest=True):
|
|
344
344
|
"""Convert xydata (x,y) -> data[(x,y)] value of neaerst pixel.
|
|
345
|
-
|
|
345
|
+
If `nearest` is False, the return value is interpolated with spline.
|
|
346
346
|
"""
|
|
347
347
|
h, w = self.__buf.shape[:2]
|
|
348
348
|
nx, ny = self.xytopixel(x, y, cast=nearest)
|
|
@@ -355,7 +355,7 @@ class AxesImagePhantom:
|
|
|
355
355
|
|
|
356
356
|
def xytopixel(self, x, y=None, cast=True):
|
|
357
357
|
"""Convert xydata (x,y) -> [nx,ny] pixel.
|
|
358
|
-
If cast,
|
|
358
|
+
If `cast` is True, the return value will be integer pixel values.
|
|
359
359
|
"""
|
|
360
360
|
def _cast(n):
|
|
361
361
|
return np.int32(np.floor(np.round(n, 1)))
|
|
@@ -372,7 +372,8 @@ class AxesImagePhantom:
|
|
|
372
372
|
return (nx-0.5, ny-0.5)
|
|
373
373
|
|
|
374
374
|
def xyfrompixel(self, nx, ny=None):
|
|
375
|
-
"""Convert pixel [nx,ny] -> (x,y) xydata (float number).
|
|
375
|
+
"""Convert pixel [nx,ny] -> (x,y) xydata (float number).
|
|
376
|
+
"""
|
|
376
377
|
if ny is None:
|
|
377
378
|
## warn("Setting xy data with single tuple.", DeprecationWarning)
|
|
378
379
|
nx, ny = nx
|
|
@@ -831,15 +832,6 @@ class GraphPlot(MatplotPanel):
|
|
|
831
832
|
else:
|
|
832
833
|
self.load(v)
|
|
833
834
|
|
|
834
|
-
@property
|
|
835
|
-
def newbuffer(self):
|
|
836
|
-
"""New buffer loader."""
|
|
837
|
-
return None
|
|
838
|
-
|
|
839
|
-
@newbuffer.setter
|
|
840
|
-
def newbuffer(self, v):
|
|
841
|
-
self.load(v)
|
|
842
|
-
|
|
843
835
|
@property
|
|
844
836
|
def unit(self):
|
|
845
837
|
"""Logical length per pixel arb.unit [u/pixel]."""
|
|
@@ -1217,9 +1209,9 @@ class GraphPlot(MatplotPanel):
|
|
|
1217
1209
|
If centred, correct the point to the center of the nearest pixel.
|
|
1218
1210
|
"""
|
|
1219
1211
|
dx, dy = x-xo, y-yo
|
|
1220
|
-
L = np.hypot(dy,dx)
|
|
1221
|
-
a = np.arctan2(dy,dx)
|
|
1222
|
-
aa = np.linspace(-pi,pi,9) + pi/8 # 角度の検索範囲
|
|
1212
|
+
L = np.hypot(dy, dx)
|
|
1213
|
+
a = np.arctan2(dy, dx)
|
|
1214
|
+
aa = np.linspace(-pi, pi, 9) + pi/8 # 角度の検索範囲
|
|
1223
1215
|
k = np.searchsorted(aa, a)
|
|
1224
1216
|
x = xo + L * np.cos(aa[k] - pi/8)
|
|
1225
1217
|
y = yo + L * np.sin(aa[k] - pi/8)
|
|
@@ -1413,7 +1405,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1413
1405
|
if x.size:
|
|
1414
1406
|
self.__rectarts.append(
|
|
1415
1407
|
self.axes.add_patch(
|
|
1416
|
-
patches.Polygon(list(zip(x,y)),
|
|
1408
|
+
patches.Polygon(list(zip(x, y)),
|
|
1417
1409
|
color='red', ls='solid', lw=1/2, ec='white', alpha=0.2)
|
|
1418
1410
|
)
|
|
1419
1411
|
)
|
|
@@ -1458,7 +1450,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1458
1450
|
self.__lastpoint = self.calc_point(org.xdata, org.ydata, centred=False)
|
|
1459
1451
|
if not self.__rectsel:
|
|
1460
1452
|
x, y = self.__lastpoint
|
|
1461
|
-
self.set_current_rect((x,x), (y,y))
|
|
1453
|
+
self.set_current_rect((x, x), (y, y)) # start new region
|
|
1462
1454
|
self.__orgpoints = self.get_current_rect()
|
|
1463
1455
|
|
|
1464
1456
|
def OnRegionDragMove(self, evt, shift=False, meta=False):
|
|
@@ -1477,7 +1469,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1477
1469
|
i = np.searchsorted(nn, n)
|
|
1478
1470
|
x = xo + nn[i] * np.sign(x-xo) * ux
|
|
1479
1471
|
y = yo + nn[i] * np.sign(y-yo) * uy
|
|
1480
|
-
self.set_current_rect((xo,x), (yo,y))
|
|
1472
|
+
self.set_current_rect((xo, x), (yo, y))
|
|
1481
1473
|
else:
|
|
1482
1474
|
xc, yc = self.__lastpoint
|
|
1483
1475
|
xo, yo = self.__orgpoints
|
|
@@ -1612,7 +1604,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1612
1604
|
j = self.__marksel
|
|
1613
1605
|
if j:
|
|
1614
1606
|
xm, ym = self.marked.get_data(orig=0)
|
|
1615
|
-
xm, ym = np.delete(xm,j), np.delete(ym,j)
|
|
1607
|
+
xm, ym = np.delete(xm, j), np.delete(ym, j)
|
|
1616
1608
|
self.__marksel = []
|
|
1617
1609
|
self.marked.set_data(xm, ym)
|
|
1618
1610
|
n = len(xm)
|
|
@@ -1621,7 +1613,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1621
1613
|
|
|
1622
1614
|
def update_art_of_mark(self, *args):
|
|
1623
1615
|
if args:
|
|
1624
|
-
for k,x,y in zip(*args):
|
|
1616
|
+
for k, x, y in zip(*args):
|
|
1625
1617
|
art = self.__markarts[k] # art の再描画処理をして終了
|
|
1626
1618
|
art.xy = x, y
|
|
1627
1619
|
self.draw(self.marked)
|
|
@@ -1632,7 +1624,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1632
1624
|
if self.marked.get_visible() and self.handler.current_state in (MARK, MARK+DRAGGING):
|
|
1633
1625
|
N = self.maxnum_markers
|
|
1634
1626
|
xm, ym = self.marked.get_data(orig=0)
|
|
1635
|
-
for k, (x,y) in enumerate(zip(xm[:N],ym[:N])):
|
|
1627
|
+
for k, (x, y) in enumerate(zip(xm[:N], ym[:N])):
|
|
1636
1628
|
self.__markarts.append(
|
|
1637
1629
|
self.axes.annotate(k, #<matplotlib.text.Annotation>
|
|
1638
1630
|
xy=(x,y), xycoords='data',
|
mwx/matplot2lg.py
CHANGED
|
@@ -217,8 +217,8 @@ class Histogram(LinePlot):
|
|
|
217
217
|
常に整数ビット画像となるので,高速なビンづめ法で計算する
|
|
218
218
|
|
|
219
219
|
Attributes:
|
|
220
|
-
|
|
221
|
-
__frame
|
|
220
|
+
__graphs : list of attached graph <matplot2g.GraphPlot>
|
|
221
|
+
__frame : reference to the current frame
|
|
222
222
|
"""
|
|
223
223
|
def __init__(self, *args, **kwargs):
|
|
224
224
|
LinePlot.__init__(self, *args, **kwargs)
|
|
@@ -356,7 +356,7 @@ class Histogram(LinePlot):
|
|
|
356
356
|
i, j = x.searchsorted(self.region)
|
|
357
357
|
else:
|
|
358
358
|
i, j = (0, -1)
|
|
359
|
-
self.__fil.set_xy(list(chain([(x[i],0)], zip(x[i:j],y[i:j]), [(x[j-1],0)])))
|
|
359
|
+
self.__fil.set_xy(list(chain([(x[i], 0)], zip(x[i:j], y[i:j]), [(x[j-1], 0)])))
|
|
360
360
|
else:
|
|
361
361
|
self.__fil.set_xy([(0,0)])
|
|
362
362
|
else:
|
|
@@ -387,10 +387,10 @@ class LineProfile(LinePlot):
|
|
|
387
387
|
"""LinePlot panel for line profile (Multi-graph : Single-frame)
|
|
388
388
|
|
|
389
389
|
Attributes:
|
|
390
|
-
|
|
391
|
-
__frame
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
__graphs : list of attached graph <matplot2g.GraphPlot>
|
|
391
|
+
__frame : reference to the current frame
|
|
392
|
+
__logicp : line axis in logical unit
|
|
393
|
+
__linewidth : line width to integrate [pixel]
|
|
394
394
|
"""
|
|
395
395
|
def __init__(self, *args, **kwargs):
|
|
396
396
|
LinePlot.__init__(self, *args, **kwargs)
|
|
@@ -635,7 +635,7 @@ class LineProfile(LinePlot):
|
|
|
635
635
|
|
|
636
636
|
x, y = self.plotdata
|
|
637
637
|
if x.size:
|
|
638
|
-
self.__fil.set_xy(list(chain([(x[0],0)], zip(x,y), [(x[-1],0)])))
|
|
638
|
+
self.__fil.set_xy(list(chain([(x[0], 0)], zip(x, y), [(x[-1], 0)])))
|
|
639
639
|
self.writeln()
|
|
640
640
|
|
|
641
641
|
## --------------------------------
|
|
@@ -723,10 +723,10 @@ class LineProfile(LinePlot):
|
|
|
723
723
|
ys = np.convolve(window/window.sum(), y, mode='same')
|
|
724
724
|
|
|
725
725
|
## maxima = signal.find_peaks_cwt(ys, np.arange(lw,lw*2))
|
|
726
|
-
maxima,_ = signal.find_peaks(ys, width=lw, prominence=20)
|
|
726
|
+
maxima, _ = signal.find_peaks(ys, width=lw, prominence=20)
|
|
727
727
|
|
|
728
728
|
## minima = signal.find_peaks_cwt(-ys, np.arange(lw,lw*2))
|
|
729
|
-
minima,_ = signal.find_peaks(-ys, width=lw, prominence=20)
|
|
729
|
+
minima, _ = signal.find_peaks(-ys, width=lw, prominence=20)
|
|
730
730
|
|
|
731
731
|
peaks = np.sort(np.append(maxima, minima))
|
|
732
732
|
if peaks.size:
|
mwx/mgplt.py
CHANGED
|
@@ -84,7 +84,7 @@ class Gnuplot:
|
|
|
84
84
|
while len(data) > len(opts): # opts 指定の数が足りない場合 (maybe+1)
|
|
85
85
|
opts.append("w l")
|
|
86
86
|
|
|
87
|
-
pcmd = ["tempfile using 1:{} {}".format(j+2,opt) for j,opt in enumerate(opts)]
|
|
87
|
+
pcmd = ["tempfile using 1:{} {}".format(j+2, opt) for j, opt in enumerate(opts)]
|
|
88
88
|
data = np.vstack((axis, data))
|
|
89
89
|
with open(self.tempfile, 'w') as o:
|
|
90
90
|
for v in data.T:
|