iam-git / WellMet (public) (License: MIT) (since 2021-08-31) (hash sha1)
WellMet is pure Python framework for spatial structural reliability analysis. Or, more specifically, for "failure probability estimation and detection of failure surfaces by adaptive sequential decomposition of the design domain".
List of commits:
Subject Hash Author Date (UTC)
qt_gui: prepare new BoxEstimationData class; rework ErrorGraph 37387100715f980771a8a37f99eec3e723759cd3 I am 2022-12-11 23:17:06
dicebox.circumtri: replace ndim by nvar to make TriEstimation pandas-friendly 0824222ae4c9c1f3fede971481816ed9ded9707a I am 2022-12-11 23:14:05
step back: introduce box_estimations, keep "estimations" for user ones dde983d57423e28083980cbae05f0a81fc8311e6 I am 2022-12-10 03:54:09
simplex.BetterCubatureIntegration: hotfix f8a607e5d60c591eb81037010717519c1fe6e993 I am 2022-12-08 00:29:57
qt_gui.qt_gui: add EstimationTableWidget bb44fc8a056ed90906c217cfc95f7cabc6ef71eb I am 2022-12-07 23:17:42
remove deprecated never used Plotly code d42ebb3535e4736a1e9fdb84c8d6dae633c83a33 I am 2022-12-07 15:03:51
dicebox.circumtri.CircumTri: enable estimations 4fe25ad47d71b1fd19fe00ad03d9b320b8c8614c I am 2022-12-07 14:30:46
dicebox: introduce new clean experimental CircumTri box aca3e971212590a59e9d07a3ff1aa952d02a848b I am 2022-12-07 04:19:55
simplex.Triangulation: keep locally pdfs and failsi, send tuple on simplex invalidation d2885ce44585e22294f9940159d6313642164f4c I am 2022-12-07 04:14:05
convex_hull.QHull: manual update() fix 5ccff702b9920c7525c88d306f2300cd43b2e76b I am 2022-12-07 04:02:39
simplex: implement BetterCubatureIntegration 88b14adc4423f0587bd51bed06e74ce6d0d60bd1 I am 2022-12-05 22:20:31
convex_hull.BrickHull: add get_hyperplane_distances() method a use it as fallback for the Qhull 48d35c953a5cbbf739e5e838709bc00fe2f047d4 I am 2022-12-05 03:30:12
convex_hull.Qhull: add get_hyperplane_distances() method, add auto_update parameter 28aada4b79b52f58c4ad43d270be997ec6359166 I am 2022-12-04 22:49:41
move diceboxes to the dedicated drawer 31c7d30ed43f04b9469df843f909814c062adf5e I am 2022-12-04 21:27:37
reader: finally, add new Store class for the estimations 673b7daa8213807d0217089b3317674595156f6d I am 2022-12-03 17:46:22
f_models.SNorm: hotfix 5f364d1770e18d18fb810760b6207c905b551762 I am 2022-12-02 21:33:48
f_models: rewrite SNorm in lazy way. Old SNorm class renamed to SNormClassic 3b6805b2a1d0bce88960bc016bbe74bb5274810b I am 2022-12-02 21:11:37
simplex: implement CircumCenter class 0a1a67122854cfb331f696163f22cfc67331f3e8 I am 2022-12-01 01:40:38
voronoi.ContactVoronoi: add explore_couple() method 72f4dffa5e8e7ee3165df4648f6a35d75d6678a3 I am 2022-11-29 11:59:07
voronoi: almost finished 00b697466c226212aeb1ea76a717cf3db48c3187 I am 2022-11-28 16:28:48
Commit 37387100715f980771a8a37f99eec3e723759cd3 - qt_gui: prepare new BoxEstimationData class; rework ErrorGraph
Author: I am
Author date (UTC): 2022-12-11 23:17
Committer name: I am
Committer date (UTC): 2022-12-11 23:17
Parent(s): 0824222ae4c9c1f3fede971481816ed9ded9707a
Signer:
Signing key:
Signing status: N
Tree: f23db028bb342a48e98da882b4f5e828e4182d29
File Lines added Lines deleted
wellmet/qt_gui/qt_graph_widgets.py 381 197
wellmet/qt_gui/qt_gui.py 15 7
File wellmet/qt_gui/qt_graph_widgets.py changed (mode: 100644) (index 443f6d2..6d8e689)
... ... import pandas as pd # required for estimation graph
11 11
12 12
13 13 from .. import stm_df from .. import stm_df
14
15
16
17
18
19 class GRaph(pg.PlotWidget):
20 def __init__(self, stream, parent=None, *args, **kwargs):
21 super().__init__(parent, *args, **kwargs)
22 #č tím potokem je myšleno hlavní okínko
23 self.stream = stream
24 self.stream.box_runned.connect(self.replot)
25 self.stream.slice_changed.connect(self.replot)
26
27 self.stream.redraw_called.connect(self.redraw)
28
29
30 self.redraw()
31
32
33
34 def redraw(self):
35 self.clear()
36 self.setBackground('w')
37 #č y limita v podstatě znemožní Log y graf
38 self.setLimits(xMin=-0.45)#, yMin=-0.45)
39 #size=self.w.px_size*1.5
40 pos = () #np.empty((nsim, 4))
41 size = self.stream.px_size * 2
42 self.failures = self.plot(pos, pen=None, symbol='x', symbolPen='r',\
43 symbolSize=size*1.5, name='Failures') # symbolBrush=0.2,
44 self.failures.setZValue(100)
45
46 self.proxy_failures = self.plot(pos, pen=None, symbol='p', symbolPen=0.5,\
47 symbolSize=size, symbolBrush=(217,83,25), name='Proxy failures')
48 self.proxy_failures.setZValue(95)
49
50 self.successes = self.plot(pos, pen=None, symbol='+', \
51 symbolSize=size*1.5, symbolPen='g', name='Successes')
52 self.successes.setZValue(90)
53
54 self.proxy_successes = self.plot(pos, pen=None, symbol='p', symbolPen=0.5, \
55 symbolSize=size, symbolBrush=(119,172,48), name='Proxy successes')
56 self.proxy_successes.setZValue(85)
57
58
59 self.nodes = self.plot(pos, pen=None, symbol='o', symbolPen=0.5, \
60 symbolSize=size, name='Nodes')
61 self.nodes.setZValue(80)
62
63 self.replot()
64
65
66 def replot(self):
67 nsim = self.stream.slider.value()
68
69 sample_box = self.stream.sample_box[:nsim]
70
71 lengths = np.sum(np.square(sample_box.G), axis=1)
72 lengths = np.sqrt(lengths, out=lengths) #lengths of each radius-vector
73
74
75 pos = np.empty((nsim, 2))
76 pos[:,0] = np.arange(nsim)
77 pos[:,1] = lengths
78
79 if hasattr(sample_box, 'failsi'): #č to je normálně sample_box
80 failsi = sample_box.failsi
81
82 try: # proxy denotes implicitly-known values
83 proxy = sample_box.proxy.astype(bool)
84 except AttributeError:
85 proxy = np.full(nsim, False, dtype=np.bool)
86
87 mask = np.all((failsi, ~proxy), axis=0)
88 self.draw(self.failures, pos[mask])
89
90 mask = np.all((~failsi, ~proxy), axis=0)
91 self.draw(self.successes, pos[mask])
92
93 mask = np.all((failsi, proxy), axis=0)
94 self.draw(self.proxy_failures, pos[mask])
95
96 mask = np.all((~failsi, proxy), axis=0)
97 self.draw(self.proxy_successes, pos[mask])
98
99 else: #č není to teda sample_box...
100 #č snad se nám povede nakreslit aspoň tečky?
101 self.draw(self.nodes, pos)
102
103
104 @staticmethod
105 def draw(plot_item, data):
106 #č musím to udělat takhle
107 #č jinač to zlobí při posunutích slajderu
108 if len(data):
109 plot_item.setData(data)
110 plot_item.show()
111 else:
112 plot_item.hide()
113
114
115
116
117
118
119
120
121
122
14 123 """ """
15 124 ============= =============
16 125 График виӝет График виӝет
 
... ... Estimation graph widgets
20 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 130 """ """
22 131
132
133 #č na tuto třídu kladu požadavek aby kdyby něco uměla přepinat mezi zdroje
134 #č teď to nepotřebuji a nevím jestli to vůbec budu chtit v budoucnu.
135 #č Proto ji nechám teď vazanou jen na skřiňku.
136 class BoxEstimationData(QtCore.QObject):
137 estimations_updated = QtCore.pyqtSignal(pd.DataFrame)
138
139 def __init__(self, box_estimations, signal, parent=None):
140 #č QObject má jediný parametr a tím je parent
141 super().__init__(parent=parent)
142 self.box_estimations = box_estimations
143 signal.connect(self.recalculate)
144
145 self.setup_context_menu()
146 self.recalculate()
147
148
149 def setup_context_menu(self):
150 self.TRI_menu = QtWidgets.QMenu("WellMet")
151
152 # self.TRI_overall_chk = QtGui.QAction("TRI_overall_estimations", self.TRI_menu)
153 # self.TRI_overall_chk.setCheckable(True)
154 # self.TRI_overall_chk.setChecked(True)
155 # self.TRI_overall_chk.triggered.connect(self.recalculate)
156 # self.TRI_menu.addAction(self.TRI_overall_chk)
157 #
158 # self.simplex_chk = QtGui.QAction("Simplex estimations", self.TRI_menu)
159 # self.simplex_chk.setCheckable(True)
160 # self.simplex_chk.setChecked(True)
161 # self.simplex_chk.triggered.connect(self.recalculate)
162 # self.TRI_menu.addAction(self.simplex_chk)
163
164 # # year, it was
165 # ## hope, it is temporary
166 # #self.sources_action_group = QtGui.QActionGroup(self.TRI_menu)
167 # #self.sources_action_group.addAction(self.TRI_overall_chk)
168 # #self.sources_action_group.addAction(self.simplex_chk)
169
170 #self.TRI_menu.addSeparator()
171
172 # self.proxy_chk = QtGui.QAction("Proxy", self.TRI_menu)
173 # self.proxy_chk.setCheckable(True)
174 # self.proxy_chk.setChecked(hasattr(self.dice_box, 'proxy'))
175 # self.proxy_chk.triggered.connect(self.recalculate)
176 # self.TRI_menu.addAction(self.proxy_chk)
177 #
178 # self.TRI_menu.addSeparator()
179
180 self.reaction = QtGui.QAction("Update", self.TRI_menu)
181 self.reaction.triggered.connect(self.recalculate)
182 self.TRI_menu.addAction(self.reaction)
183
184 self.excelaction = QtGui.QAction("Export to Excel", self.TRI_menu)
185 self.excelaction.triggered.connect(self.export_to_excel)
186 self.TRI_menu.addAction(self.excelaction)
187
188
189 def export_to_excel(self):
190 #č já bych nechtěl, aby mně export najednou spadl
191 #č z jakéhokoliv důvodu
192 try:
193 proposal_filename = '.xlsx'
194 filename, *__ = pg.FileDialog.getSaveFileName(self.stream, 'Export to Excel',\
195 proposal_filename, initialFilter='*.xlsx')
196 if filename:
197 self.df.to_excel(filename)
198 except BaseException as e:
199 print(self.__class__.__name__ + ":", repr(e))
200
201
202 def recalculate(self):
203 self.df = df = pd.DataFrame(self.box_estimations)
204 try:
205 df.index = df.nsim
206 #č odhady skříňky netřeba sortirovat.
207 #č až se tu objeví něco dalšího, dodáme sort.
208 self.estimations_updated.emit(df)
209
210 except BaseException as e:
211 print(self.__class__.__name__ + ":", repr(e))
212
213
214
215
216 class ErrorGraph(pg.PlotWidget):
217 def __init__(self, pf_exact, signal, menu, parent=None, *args, **kwargs):
218 super().__init__(parent, *args, **kwargs)
219
220 self.pf_exact = pf_exact
221
222 signal.connect(self.redraw)
223
224 self.setup_context_menu(menu)
225 self.setup()
226
227 def setup_context_menu(self, menu):
228 # creates instance of LegendItem
229 # and saves it into plotItem.legend
230 self.legend = self.addLegend()
231
232 self.plotItem.ctrl.xGridCheck.setChecked(True)
233 self.plotItem.ctrl.yGridCheck.setChecked(True)
234
235 # menu of SimplexEstimationData
236 self.plotItem.vb.menu.addMenu(menu)
237
238 #č já se bojím. radší to uložím
239 self.custom_menu = self.plotItem.vb.menu.addMenu("Error graph")
240
241 self.legend_chk = QtGui.QAction("Legend", self.custom_menu)
242 self.legend_chk.setCheckable(True)
243 self.legend_chk.triggered.connect(lambda: self.legend.setVisible(self.legend_chk.isChecked()))
244 self.custom_menu.addAction(self.legend_chk)
245 # apply custom menu option
246 self.legend.setVisible(self.legend_chk.isChecked())
247
248 self.laction = QtGui.QAction("Show labels", self.custom_menu)
249 self.laction.triggered.connect(self.show_labels)
250 self.custom_menu.addAction(self.laction)
251
252
253 def show_labels(self):
254 self.setLabel('left', "Failure probability estimation error")
255 self.setLabel('bottom', "Number of simulations")
256
257
258 def setup(self, *args, **kwargs):
259 self.clear()
260 self.setBackground('w')
261 self.setLimits(xMin=-0.45)
262 x = y = () # zde jen vytvoříme kostru, nakrmime daty v .redraw()
263
264 # We will use logMode by default
265 self.setLogMode(y=True)
266
267 pen = pg.mkPen(color='m', width=2)
268 self.pen_vertex = self.plot(x, y, pen=pen, name="simple pf estimation")
269 pen = pg.mkPen(color='r', width=2)
270 self.pen_weighted_vertex = self.plot(x, y, pen=pen, name="weighted pf estimation")
271
272
273 def redraw(self, df):
274 #č nevadí, ale není to slušné
275 # #č zapíšeme do data rámu, snad nikomu nebude vadit
276 # df['vertex_estimation_error'] = df['vertex_estimation'] - pf_exact
277 # df['weighted_vertex_estimation_error'] = df['weighted_vertex_estimation'] - pf_exact
278
279 v = (df['vertex_estimation'] - self.pf_exact).abs()
280 wv = (df['weighted_vertex_estimation'] - self.pf_exact).abs()
281 if len(v) > 1: #č nevím proč hazí chyby. Asi kvůli zadané širce.
282 self.pen_vertex.setData(v.index.to_numpy(), v.to_numpy())
283 self.pen_weighted_vertex.setData(wv.index.to_numpy(), wv.to_numpy())
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299 #
300 # DEPRECATED
301 #
302
23 303
24 304 def get_estimation_data(estimations, metric): def get_estimation_data(estimations, metric):
25 305 metric_dict = dict() metric_dict = dict()
 
... ... def get_estimation_data(estimations, metric):
44 324
45 325 class SimplexEstimationData(QtCore.QObject): class SimplexEstimationData(QtCore.QObject):
46 326 #š budeme mӓť svůj vlastní signaľčík #š budeme mӓť svůj vlastní signaľčík
47 simplex_estimation_updated = QtCore.pyqtSignal()
327 estimations_updated = QtCore.pyqtSignal(pd.DataFrame)
48 328
49 329 def __init__(self, dice_box, stream=None, *args, **kwargs): def __init__(self, dice_box, stream=None, *args, **kwargs):
50 330 super().__init__(stream, *args, **kwargs) super().__init__(stream, *args, **kwargs)
 
... ... class SimplexEstimationData(QtCore.QObject):
128 408
129 409 self.df = stm_df.get_tri_data_frame(self.dice_box, sources=sources,\ self.df = stm_df.get_tri_data_frame(self.dice_box, sources=sources,\
130 410 apply_proxy=self.proxy_chk.isChecked()) apply_proxy=self.proxy_chk.isChecked())
131 self.simplex_estimation_updated.emit()
411 self.estimations_updated.emit(self.df)
132 412
133 413 except BaseException as e: except BaseException as e:
134 414 print(self.__class__.__name__ + ":", repr(e)) print(self.__class__.__name__ + ":", repr(e))
 
... ... class SimplexEstimationGraph(pg.PlotWidget):
383 663 print(self.__class__.__name__ + ":", repr(e)) print(self.__class__.__name__ + ":", repr(e))
384 664
385 665
386
387 class SimplexErrorGraph(pg.PlotWidget):
388 def __init__(self, simplex_data, parent=None, *args, **kwargs):
389 super().__init__(parent, *args, **kwargs)
390 self.simplex_data = simplex_data
391 self.simplex_data.simplex_estimation_updated.connect(self.redraw)
392
393 self.setup_context_menu()
394 self.setup()
395
396 def setup_context_menu(self):
397 # creates instance of LegendItem
398 # and saves it into plotItem.legend
399 self.legend = self.addLegend()
400
401 self.plotItem.ctrl.xGridCheck.setChecked(True)
402 self.plotItem.ctrl.yGridCheck.setChecked(True)
403
404 # menu of SimplexEstimationData
405 self.plotItem.vb.menu.addMenu(self.simplex_data.TRI_menu)
406
407 #č já se bojím. radší to uložím
408 self.custom_menu = self.plotItem.vb.menu.addMenu("Error graph")
409
410 self.legend_chk = QtGui.QAction("Legend", self.custom_menu)
411 self.legend_chk.setCheckable(True)
412 self.legend_chk.triggered.connect(lambda: self.legend.setVisible(self.legend_chk.isChecked()))
413 self.custom_menu.addAction(self.legend_chk)
414 # apply custom menu option
415 self.legend.setVisible(self.legend_chk.isChecked())
416
417 self.laction = QtGui.QAction("Show labels", self.custom_menu)
418 self.laction.triggered.connect(self.show_labels)
419 self.custom_menu.addAction(self.laction)
420
421
422 def show_labels(self):
423 self.setLabel('left', "Failure probability estimation error")
424 self.setLabel('bottom', "Number of simulations")
425
426
427 def setup(self, *args, **kwargs):
428 self.clear()
429 self.setBackground('w')
430 self.setLimits(xMin=-0.45)
431 x = y = () # zde jen vytvoříme kostru, nakrmime daty v .redraw()
432
433 # We will use logMode by default
434 self.setLogMode(y=True)
435
436 #xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
437 #red = (253, 0, 17, 96)
438
439 #self.pen_f = self.plot(x, y, brush=red)#, name="failure domain estimation")
440 #self.pen_f.setZValue(-100)
441
442
443 pen = pg.mkPen(color='m', width=2)
444 self.pen_vertex = self.plot(x, y, pen=pen, name="simple pf estimation")
445 pen = pg.mkPen(color='r', width=2) #(118, 187, 255)
446 self.pen_weighted_vertex = self.plot(x, y, pen=pen, name="weighted pf estimation")
447
448
449
450 #č když se někde objeví nula se zapnutým LogModem -
451 #č qtpygraph hned spadne a není možne ten pad zachytit
452 def zerosafe(self, x, y, fallback_y=None):
453 x = np.array(x)
454 y = np.array(y)
455 if fallback_y is None:
456 fallback_y = y
457 y = np.where(y > 0, y, fallback_y)
458 mask = y > 0
459 return x[mask], y[mask]
460
461
462 def redraw(self):
463 #č neotravujme uživatele chybovejma hlaškama
464 if hasattr(self.simplex_data.dice_box, 'pf_exact'):
465 try: #ё тут всё что угодно может пойти не так
466 pf_exact = self.simplex_data.dice_box.pf_exact
467
468 df = self.simplex_data.df
469 #č zapíšeme do data rámu, snad nikomu nebude vadit
470 df['vertex_estimation_error'] = df['vertex_estimation'] - pf_exact
471 df['weighted_vertex_estimation_error'] = df['weighted_vertex_estimation'] - pf_exact
472
473 v = df['vertex_estimation_error'].abs()
474 wv = df['weighted_vertex_estimation_error'].abs()
475
476 x, y = self.zerosafe(v.index, v.to_numpy())
477 self.pen_vertex.setData(x, y)
478
479 x, y = self.zerosafe(wv.index, wv.to_numpy())
480 self.pen_weighted_vertex.setData(x, y)
481
482
483 except BaseException as e:
484 print(self.__class__.__name__ + ":", repr(e))
666 #
667 #class SimplexErrorGraph(pg.PlotWidget):
668 # def __init__(self, simplex_data, parent=None, *args, **kwargs):
669 # super().__init__(parent, *args, **kwargs)
670 # self.simplex_data = simplex_data
671 # self.simplex_data.simplex_estimation_updated.connect(self.redraw)
672 #
673 # self.setup_context_menu()
674 # self.setup()
675 #
676 # def setup_context_menu(self):
677 # # creates instance of LegendItem
678 # # and saves it into plotItem.legend
679 # self.legend = self.addLegend()
680 #
681 # self.plotItem.ctrl.xGridCheck.setChecked(True)
682 # self.plotItem.ctrl.yGridCheck.setChecked(True)
683 #
684 # # menu of SimplexEstimationData
685 # self.plotItem.vb.menu.addMenu(self.simplex_data.TRI_menu)
686 #
687 # #č já se bojím. radší to uložím
688 # self.custom_menu = self.plotItem.vb.menu.addMenu("Error graph")
689 #
690 # self.legend_chk = QtGui.QAction("Legend", self.custom_menu)
691 # self.legend_chk.setCheckable(True)
692 # self.legend_chk.triggered.connect(lambda: self.legend.setVisible(self.legend_chk.isChecked()))
693 # self.custom_menu.addAction(self.legend_chk)
694 # # apply custom menu option
695 # self.legend.setVisible(self.legend_chk.isChecked())
696 #
697 # self.laction = QtGui.QAction("Show labels", self.custom_menu)
698 # self.laction.triggered.connect(self.show_labels)
699 # self.custom_menu.addAction(self.laction)
700 #
701 #
702 # def show_labels(self):
703 # self.setLabel('left', "Failure probability estimation error")
704 # self.setLabel('bottom', "Number of simulations")
705 #
706 #
707 # def setup(self, *args, **kwargs):
708 # self.clear()
709 # self.setBackground('w')
710 # self.setLimits(xMin=-0.45)
711 # x = y = () # zde jen vytvoříme kostru, nakrmime daty v .redraw()
712 #
713 # # We will use logMode by default
714 # self.setLogMode(y=True)
715 #
716 # #xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
717 # #red = (253, 0, 17, 96)
718 #
719 # #self.pen_f = self.plot(x, y, brush=red)#, name="failure domain estimation")
720 # #self.pen_f.setZValue(-100)
721 #
722 #
723 # pen = pg.mkPen(color='m', width=2)
724 # self.pen_vertex = self.plot(x, y, pen=pen, name="simple pf estimation")
725 # pen = pg.mkPen(color='r', width=2) #(118, 187, 255)
726 # self.pen_weighted_vertex = self.plot(x, y, pen=pen, name="weighted pf estimation")
727 #
728 #
729 #
730 # #č když se někde objeví nula se zapnutým LogModem -
731 # #č qtpygraph hned spadne a není možne ten pad zachytit
732 # def zerosafe(self, x, y, fallback_y=None):
733 # x = np.array(x)
734 # y = np.array(y)
735 # if fallback_y is None:
736 # fallback_y = y
737 # y = np.where(y > 0, y, fallback_y)
738 # mask = y > 0
739 # return x[mask], y[mask]
740 #
741 #
742 # def redraw(self):
743 # #č neotravujme uživatele chybovejma hlaškama
744 # if hasattr(self.simplex_data.dice_box, 'pf_exact'):
745 # try: #ё тут всё что угодно может пойти не так
746 # pf_exact = self.simplex_data.dice_box.pf_exact
747 #
748 # df = self.simplex_data.df
749 # #č zapíšeme do data rámu, snad nikomu nebude vadit
750 # df['vertex_estimation_error'] = df['vertex_estimation'] - pf_exact
751 # df['weighted_vertex_estimation_error'] = df['weighted_vertex_estimation'] - pf_exact
752 #
753 # v = df['vertex_estimation_error'].abs()
754 # wv = df['weighted_vertex_estimation_error'].abs()
755 #
756 # x, y = self.zerosafe(v.index, v.to_numpy())
757 # self.pen_vertex.setData(x, y)
758 #
759 # x, y = self.zerosafe(wv.index, wv.to_numpy())
760 # self.pen_weighted_vertex.setData(x, y)
761 #
762 #
763 # except BaseException as e:
764 # print(self.__class__.__name__ + ":", repr(e))
485 765
486 766
487 767
 
... ... class VoronoiEstimationGraph(pg.PlotWidget):
915 1195
916 1196
917 1197
918
919 class GRaph(pg.PlotWidget):
920 def __init__(self, stream, parent=None, *args, **kwargs):
921 super().__init__(parent, *args, **kwargs)
922 #č tím potokem je myšleno hlavní okínko
923 self.stream = stream
924 self.stream.box_runned.connect(self.replot)
925 self.stream.slice_changed.connect(self.replot)
926
927 self.stream.redraw_called.connect(self.redraw)
928
929
930 self.redraw()
931
932
933
934 def redraw(self):
935 self.clear()
936 self.setBackground('w')
937 #č y limita v podstatě znemožní Log y graf
938 self.setLimits(xMin=-0.45)#, yMin=-0.45)
939 #size=self.w.px_size*1.5
940 pos = () #np.empty((nsim, 4))
941 size = self.stream.px_size * 2
942 self.failures = self.plot(pos, pen=None, symbol='x', symbolPen='r',\
943 symbolSize=size*1.5, name='Failures') # symbolBrush=0.2,
944 self.failures.setZValue(100)
945
946 self.proxy_failures = self.plot(pos, pen=None, symbol='p', symbolPen=0.5,\
947 symbolSize=size, symbolBrush=(217,83,25), name='Proxy failures')
948 self.proxy_failures.setZValue(95)
949
950 self.successes = self.plot(pos, pen=None, symbol='+', \
951 symbolSize=size*1.5, symbolPen='g', name='Successes')
952 self.successes.setZValue(90)
953
954 self.proxy_successes = self.plot(pos, pen=None, symbol='p', symbolPen=0.5, \
955 symbolSize=size, symbolBrush=(119,172,48), name='Proxy successes')
956 self.proxy_successes.setZValue(85)
957
958
959 self.nodes = self.plot(pos, pen=None, symbol='o', symbolPen=0.5, \
960 symbolSize=size, name='Nodes')
961 self.nodes.setZValue(80)
962
963 self.replot()
964
965
966 def replot(self):
967 nsim = self.stream.slider.value()
968
969 sample_box = self.stream.sample_box[:nsim]
970
971 lengths = np.sum(np.square(sample_box.G), axis=1)
972 lengths = np.sqrt(lengths, out=lengths) #lengths of each radius-vector
973
974
975 pos = np.empty((nsim, 2))
976 pos[:,0] = np.arange(nsim)
977 pos[:,1] = lengths
978
979 if hasattr(sample_box, 'failsi'): #č to je normálně sample_box
980 failsi = sample_box.failsi
981
982 try: # proxy denotes implicitly-known values
983 proxy = sample_box.proxy.astype(bool)
984 except AttributeError:
985 proxy = np.full(nsim, False, dtype=np.bool)
986
987 mask = np.all((failsi, ~proxy), axis=0)
988 self.draw(self.failures, pos[mask])
989
990 mask = np.all((~failsi, ~proxy), axis=0)
991 self.draw(self.successes, pos[mask])
992
993 mask = np.all((failsi, proxy), axis=0)
994 self.draw(self.proxy_failures, pos[mask])
995
996 mask = np.all((~failsi, proxy), axis=0)
997 self.draw(self.proxy_successes, pos[mask])
998
999 else: #č není to teda sample_box...
1000 #č snad se nám povede nakreslit aspoň tečky?
1001 self.draw(self.nodes, pos)
1002
1003
1004 @staticmethod
1005 def draw(plot_item, data):
1006 #č musím to udělat takhle
1007 #č jinač to zlobí při posunutích slajderu
1008 if len(data):
1009 plot_item.setData(data)
1010 plot_item.show()
1011 else:
1012 plot_item.hide()
1013
File wellmet/qt_gui/qt_gui.py changed (mode: 100644) (index 1451b57..6a2d0b3)
... ... class QtGuiWindow(QtWidgets.QMainWindow):
259 259 # self.tabifyDockWidget(self.dockables[0], dock) # self.tabifyDockWidget(self.dockables[0], dock)
260 260
261 261 #č graphy už nemusí jít po stm widgetech #č graphy už nemusí jít po stm widgetech
262 if hasattr(self.sample_box, 'estimations'):
262 if hasattr(self.sample_box, 'box_estimations'):
263 263 dock = QtWidgets.QDockWidget("Estimation data", self) dock = QtWidgets.QDockWidget("Estimation data", self)
264 264 widget = EstimationTableWidget(self.sample_box.box_estimations, self.box_runned, dock) widget = EstimationTableWidget(self.sample_box.box_estimations, self.box_runned, dock)
265 265 dock.setWidget(widget) dock.setWidget(widget)
266 266 self.dockables.append(dock) self.dockables.append(dock)
267 267 self.tabifyDockWidget(self.dockables[0], dock) self.tabifyDockWidget(self.dockables[0], dock)
268
269 self.simplex_data = qt_graph_widgets.SimplexEstimationData(self.sample_box, self)
268
269 self.box_estimation_data = qt_graph_widgets.BoxEstimationData(
270 self.sample_box.box_estimations, self.box_runned, self)
271 else:
272 self.box_estimation_data = qt_graph_widgets.SimplexEstimationData(self.sample_box, self)
273
270 274 #č graphy už nemusí jít po stm widgetech #č graphy už nemusí jít po stm widgetech
271 275 dock = QtWidgets.QDockWidget("TRI_overall estimation graph", self) dock = QtWidgets.QDockWidget("TRI_overall estimation graph", self)
272 276 dock.setWidget(qt_graph_widgets.TriEstimationGraph(self.sample_box, 'TRI_overall_estimations', self, dock)) dock.setWidget(qt_graph_widgets.TriEstimationGraph(self.sample_box, 'TRI_overall_estimations', self, dock))
 
... ... class QtGuiWindow(QtWidgets.QMainWindow):
278 282 self.dockables.append(dock) self.dockables.append(dock)
279 283 self.tabifyDockWidget(self.dockables[0], dock) self.tabifyDockWidget(self.dockables[0], dock)
280 284
281 dock = QtWidgets.QDockWidget("Simplex error graph", self)
282 dock.setWidget(qt_graph_widgets.SimplexErrorGraph(self.simplex_data, dock))
283 self.dockables.append(dock)
284 self.tabifyDockWidget(self.dockables[0], dock)
285 if hasattr(self.sample_box, 'pf_exact'):
286 dock = QtWidgets.QDockWidget("Error graph", self)
287 pf_exact = self.sample_box.pf_exact
288 menu = self.box_estimation_data.TRI_menu
289 signal = self.box_estimation_data.estimations_updated
290 dock.setWidget(qt_graph_widgets.ErrorGraph(pf_exact, signal, menu, dock))
291 self.dockables.append(dock)
292 self.tabifyDockWidget(self.dockables[0], dock)
285 293
286 294 dock = QtWidgets.QDockWidget("Voronoi estimation graph", self) dock = QtWidgets.QDockWidget("Voronoi estimation graph", self)
287 295 dock.setWidget(qt_graph_widgets.VoronoiEstimationGraph(self.sample_box, self, dock)) dock.setWidget(qt_graph_widgets.VoronoiEstimationGraph(self.sample_box, self, dock))
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/WellMet

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/WellMet

Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/WellMet

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main