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)
convex_hull: 2FORM za mně je Ready. Orth potřebuje Gram-Schmidtovou ortogonalizaci. Oboje jsou otestovany ve 2D. There is some weirdness with candidates inherited from WIP recent commit. It need to be fixed. ffae78d5a15884476760b8ab759963d7ef8ff5fc Aleksei Gerasimov 2021-07-19 14:48:34
convex_hull: 2FORM estimation WIP a0f04ef282d6dacbda52c9734f36f9e7ec9b46da I am 2021-07-19 06:14:54
convex_hull.fire: use sf instead of cdf function to fix precision issue in distant areas. e3b9f036f9d50994357e32827586fb98d85d43a7 I am 2021-07-15 09:13:58
qt_plot: add matplotlib menu 73835a59908b82f08d618a06c4c05a96703715b1 I am 2021-07-14 17:01:54
mart: add candidates plot functions 56b3f5320e83071886c0d8f65a3d9df7c5a231a8 I am 2021-07-13 10:55:13
dicebox.Goal.assess_candidates: put back dd attribute 5da7c67800b8cd6eb3f221273a8270393a571e2b I am 2021-07-12 08:47:00
sball: fix Radial pdf 830fbf3119e2e54e42ea48640dfe553ffa2b3c1f I am 2021-07-08 19:50:42
spring: try to fix infinite loop 0e9a6161996c1b078698b1631d10f1a171332818 I am 2021-07-08 17:54:04
dicebox.Goal: add q_psee potential 4c151252460f6e96f7c1ac5662f81474eae305a0 I am 2021-07-08 00:34:27
dicebox.Goal: Goal is back after the breakage! 19c3c63001ebc19ed5e17892e4b11edb4dbfe828 I am 2021-07-06 16:14:14
IS_stat.PushAndPull: small variance fix, spíše formální 7b5b87655b6978828ed06ba3743ada46a2bfde6b I am 2021-07-06 04:31:43
qt_plot.Ghull: update Ghull related code. A lot of fixes. Вроде фурычит. 29cd8fce14cecc872e1be856d73d9669a6395b08 I am 2021-07-05 18:47:53
IS_stat: new class added (for Ghull, actually) 27b2685694655cb75657c6629d10706669d1f2e2 I am 2021-07-04 22:05:48
convex_hull.Ghull: integrovaní memikruží je hodně překopano. Breakage. není zatím testováno 2d39dcd67948a99028013b0f7f420adf86eb19e9 I am 2021-07-04 22:02:48
dicebox: replace everywhere "potencial" typo by correct "potential" word. Save English eyes! c4aae036362d93c8a0a5bde9f30537d1b549adaa I am 2021-06-30 14:30:26
welford: add method for sparse data c9dd961c58243ac890b9a518cfff5901dd6a5789 I am 2021-06-28 13:47:09
welford: yet another Welford's algoritm implementation ec31907d6727c408306f4b25c09b7f87632b0ecf I am 2021-06-27 22:27:06
IS_stat.TrueIS: pridal jsem do komentářu vzpomínky 1c5b4596a4da1206b02ed91954cbe8147ec1e208 I am 2021-06-27 15:23:42
IS_stat: add get_IS_estimation() function d048b4cd4e90d8440e7ff2a3ad86bc0f3c160d4f I am 2021-06-26 19:55:14
spring: new brand hustý modul pro vyrovnání odhadů 3fc5eb00de1eb65cff2db71640c340602687f52f I am 2021-06-25 00:52:06
Commit ffae78d5a15884476760b8ab759963d7ef8ff5fc - convex_hull: 2FORM za mně je Ready. Orth potřebuje Gram-Schmidtovou ortogonalizaci. Oboje jsou otestovany ve 2D. There is some weirdness with candidates inherited from WIP recent commit. It need to be fixed.
Author: Aleksei Gerasimov
Author date (UTC): 2021-07-19 14:48
Committer name: Aleksei Gerasimov
Committer date (UTC): 2021-07-19 14:48
Parent(s): a0f04ef282d6dacbda52c9734f36f9e7ec9b46da
Signer:
Signing key:
Signing status: N
Tree: 66bf886dc79ae0b64136532c367d3dfdd4fcaaf5
File Lines added Lines deleted
convex_hull.py 185 58
qt_plot.py 45 54
File convex_hull.py changed (mode: 100644) (index d757b85..2d25f88)
2 2 # coding: utf-8 # coding: utf-8
3 3
4 4 import numpy as np import numpy as np
5 #from . import IS_stat
5 import mpmath
6 6 from . import sball from . import sball
7 #from . import f_models
8 7 from scipy import stats from scipy import stats
9 8 from scipy import spatial from scipy import spatial
10 9 from .candybox import CandyBox from .candybox import CandyBox
11 10 from .IS_stat import PushAndPull # for Shell_IS from .IS_stat import PushAndPull # for Shell_IS
12 11
12 mpmath.mp.dps = 325 # to cover anything double-presigion float can handle
13 13
14 14 #č jako sůl potřebujem statefull třidu, #č jako sůl potřebujem statefull třidu,
15 15 #č která by schovávala vnitřní implementaciju, #č která by schovávala vnitřní implementaciju,
 
... ... from .IS_stat import PushAndPull # for Shell_IS
18 18 #č Ze scipy bych viděl podporu atributů .points, .npoints, .equations #č Ze scipy bych viděl podporu atributů .points, .npoints, .equations
19 19 #č Určitě bych chtěl funkce .update() a .is_outside(sample) #č Určitě bych chtěl funkce .update() a .is_outside(sample)
20 20 #č Atribute .space by ukazoval, v jakém prostoru konvexní obál je vytvořen #č Atribute .space by ukazoval, v jakém prostoru konvexní obál je vytvořen
21 # GBall, BrickHull, DirectHull, CompleteHull and QHull has been implemented
21 22
22 23
24 def calculate_brick_complement_probability(mins, maxs):
25 "For Gaussian space"
26 #č na začátku nastavíme obyčejnou 1
27 #č v cyklu bude nasobit delkami
28 #č podle jednotlivých souřadnic
29 #č a typ se změní na mpf (hodně přesná aritmetika)
30 volume = 1
31
32 # ncdf() do not support matrix input
33 for xmin, xmax in zip(mins, maxs):
34 volume *= mpmath.ncdf(xmax) - mpmath.ncdf(xmin)
35
36 # print test
37 # if len(mins) == 2:
38 # min_x, min_y = mins
39 # max_x, max_y = maxs
40 # test_volume = 0
41 # test_volume += np.sum(stats.norm.cdf(mins))
42 # test_volume += np.sum(stats.norm.sf(maxs))
43 # test_volume -= stats.norm.cdf(min_x) * stats.norm.cdf(min_y)
44 # test_volume -= stats.norm.cdf(min_x) * stats.norm.sf(max_y)
45 # test_volume -= stats.norm.sf(max_x) * stats.norm.cdf(min_y)
46 # test_volume -= stats.norm.sf(max_x) * stats.norm.sf(max_y)
47 # print("test_volume:", test_volume)
48
49 return float(1-volume)
50
51 # inspired by
52 # https://math.stackexchange.com/questions/192610/how-to-build-a-orthogonal-basis-from-a-vector/979013
53 def get_orth_basis(vector):
54 if len(vector)==2:
55 x, y = vector
56 return np.array([[x, y],[-y, x]])
57 elif len(vector)==4:
58 x_1, x_2, x_3, x_4 = vector
59 return np.array([
60 [x_1, x_2, x_3, x_4],
61 [-x_2, x_1, -x_4, x_3],
62 [-x_3, x_4, x_1, -x_2],
63 [-x_4, -x_3, x_2, x_1]])
64 else:
65 # not currently implemented
66 return np.diag(np.full(len(vector),1))
67
68
69
23 70 #ё рельса #ё рельса
24 71 #č nepodařílo se mi nějak rozumně zobecnit pro libovolný prostor #č nepodařílo se mi nějak rozumně zobecnit pro libovolný prostor
25 72 #č takže Gauss #č takže Gauss
 
... ... def fire(hull, ns, use_MS=False):
47 94 return hull.sample.f_model.new_sample(fire_G, space='G') return hull.sample.f_model.new_sample(fire_G, space='G')
48 95
49 96
50 # common function for DirectHull, CompleteHull and QHull
97 #
98 # Common orth functions for DirectHull, CompleteHull and QHull
99 #
100
101 # (even private function can be shared :D )
102 def _orth_helper(hull):
103 # supposed hull.space == 'G'
104 hull._update()
105 to_fire = np.nanargmax(hull.b)
106 a = hull.A[to_fire]
107
108 orth_basis = get_orth_basis(a)
109
110 #č musí tam bejt G coordinates
111 A = orth_basis @ hull.points.T
112 bp = np.nanmax(A, axis=1)
113 bm = np.nanmin(A, axis=1)
114
115 return orth_basis, bp, bm
116
117
118 def get_orth_outside(hull):
119 if hull.space == 'G' :
120 # hull._update() will perform _orth_helper()
121 A, bp, bm = hull._orth_helper()
122 return calculate_brick_complement_probability(bm, bp)
123 else:
124 #č když prostor není G, můžeme sice něco odvodit od s-ball
125 #č ale nechť se s tím pará GHull, vrátíme nulu.
126 return 0
127
128 def get_orth_equations(hull):
129 # hull._update() will perform _orth_helper()
130 direct_plan, bp, bm = hull._orth_helper()
131
132 A = np.vstack((-direct_plan, direct_plan))
133 b = np.concatenate((bm, -bp))
134 return np.hstack((A,b[:,None]))
135
136
137 #
138 # Common 2FORM functions for DirectHull, CompleteHull and QHull
139 #
140
51 141 # (even private function can be shared :D ) # (even private function can be shared :D )
52 142 def _2FORM_helper(hull): def _2FORM_helper(hull):
53 143 # supposed hull.space == 'G' # supposed hull.space == 'G'
 
... ... def _2FORM_helper(hull):
70 160 # x_backward == min(x) == max(-a @ points.T) # x_backward == min(x) == max(-a @ points.T)
71 161 x_forward = np.max(x) x_forward = np.max(x)
72 162 x_backward = np.min(x) x_backward = np.min(x)
73 print(-np.max(hull.b), x_forward)
163 #print(-np.max(hull.b), x_forward)
74 164 return x_backward, x_forward, a return x_backward, x_forward, a
75 165
76 # common function for DirectHull, CompleteHull and QHull
166
77 167 def get_2FORM_outside(hull): def get_2FORM_outside(hull):
78 168 if hull.space == 'G': if hull.space == 'G':
79 169 # hull._update() will perform _FORM_helper() # hull._update() will perform _FORM_helper()
 
... ... def get_2FORM_outside(hull):
84 174 #č ale nechť se s tím pará GHull, vrátíme nulu. #č ale nechť se s tím pará GHull, vrátíme nulu.
85 175 return 0 return 0
86 176
87
88 # common function for DirectHull, CompleteHull and QHull
89 #č kdyby někdo chtěl všecko vidět vlastmina očima...
90 #č ale jinak předpokladám, že se funkce nebude spouštět přílíš často
91 def get_2FORM_points(hull):
92 if hull.space == 'G':
93 # hull._update() will perform _FORM_helper()
94 x_backward, x_forward, a = hull._2FORM_helper()
95 nodes_G = a * np.array([[x_backward], [x_forward]])
96 #č bacha, zadávám explicitně G prostor!
97 return hull.sample.f_model.new_sample(nodes_G, space='G')
98
177 def get_2FORM_equations(hull):
178 # hull._update() will perform _2FORM_helper()
179 x_backward, x_forward, a = hull._2FORM_helper()
180 A = np.vstack((-a, a))
181 b = np.array([[x_backward],[-x_forward]])
182 return np.hstack((A,b))
183
99 184
100 185 #č jistě musíme mít nějaký zbytečný kus kódu #č jistě musíme mít nějaký zbytečný kus kódu
101 186 #č třida jen pro formu, jen tak na hračku #č třida jen pro formu, jen tak na hračku
 
... ... class GBall:
144 229 #č tak zde get_r vždy musí vracet prostě R #č tak zde get_r vždy musí vracet prostě R
145 230 return hull.get_R() return hull.get_R()
146 231
232 def get_orth_outside(hull):
233 x = np.full(hull.sample.nvar, hull.get_r())
234 return calculate_brick_complement_probability(-x, x)
235
147 236
148 237 def get_2FORM_outside(hull): def get_2FORM_outside(hull):
149 238 return 2*stats.norm.sf(hull.get_r()) return 2*stats.norm.sf(hull.get_r())
 
... ... class BrickHull: #č nebo BoundingBrick
249 338 return np.hstack((A,b[:,None])) return np.hstack((A,b[:,None]))
250 339
251 340
341 def get_orth_outside(hull):
342 if hull.space == 'G':
343 hull._update()
344 return calculate_brick_complement_probability(hull.mins, hull.maxs)
345 else:
346 #č když prostor není G, můžeme sice něco odvodit od s-ball
347 #č ale nechť se s tím pará GHull, vrátíme nulu.
348 return 0
349
350 def get_orth_equations(hull):
351 return hull.equations
352
353
252 354 def _2FORM_helper(hull): def _2FORM_helper(hull):
253 355 hull._update() hull._update()
254 356 #č je to úplně zbýtečně trapit se nejakejma argama #č je to úplně zbýtečně trapit se nejakejma argama
 
... ... class BrickHull: #č nebo BoundingBrick
266 368 # and corresponding number of variable # and corresponding number of variable
267 369 return pfs[i], i return pfs[i], i
268 370
371
269 372 def get_2FORM_outside(hull): def get_2FORM_outside(hull):
270 373 if hull.space == 'G': if hull.space == 'G':
271 374 # hull._update() will perform _FORM_helper() # hull._update() will perform _FORM_helper()
 
... ... class BrickHull: #č nebo BoundingBrick
276 379 #č ale nechť se s tím pará GHull, vrátíme nulu. #č ale nechť se s tím pará GHull, vrátíme nulu.
277 380 return 0 return 0
278 381
279 #č kdyby někdo chtěl všecko vidět vlastmina očima...
280 #č ale jinak předpokladám, že se funkce nebude spouštět přílíš často
281 def get_2FORM_points(hull):
282 if hull.space == 'G':
283 # hull._update() will perform _FORM_helper()
284 __p_out, i = hull._2FORM_helper()
285
286 # 0.0 - musí pak příjmout float
287 nodes_G = np.full((2, hull.sample.nvar), 0.0)
288 nodes_G[0, i] = hull.mins[i]
289 nodes_G[1, i] = hull.maxs[i]
290 #č bacha, zadávám explicitně G prostor!
291 return hull.sample.f_model.new_sample(nodes_G, space='G')
292
293 def get_2FORM_direction(hull):
382
383 def get_2FORM_equations(hull):
294 384 __p_out, i = hull._2FORM_helper() __p_out, i = hull._2FORM_helper()
295 a = np.full(hull.sample.nvar, 0)
296 a[i] = 1
297 return hull.mins[i], hull.maxs[i], a
385 equations = np.zeros((2,hull.sample.nvar+1))
386 equations[0, i] = 1
387 equations[0, -1] = -hull.maxs[i]
388 equations[1, i] = -1
389 equations[1, -1] = hull.mins[i]
390 return equations
391
298 392
299 393 # add use_MC to the function signature # add use_MC to the function signature
300 394 # but remain unimplemented for now # but remain unimplemented for now
 
... ... class BrickHull: #č nebo BoundingBrick
328 422 class DirectHull: class DirectHull:
329 423 # take some global functions # take some global functions
330 424 fire = fire fire = fire
425 _orth_helper = _orth_helper
426 get_orth_outside = get_orth_outside
427 get_orth_equations = get_orth_equations
428
331 429 _2FORM_helper = _2FORM_helper _2FORM_helper = _2FORM_helper
332 430 get_2FORM_outside = get_2FORM_outside get_2FORM_outside = get_2FORM_outside
333 get_2FORM_points = get_2FORM_points
334 get_2FORM_direction = _2FORM_helper
431 get_2FORM_equations = get_2FORM_equations
335 432
336 433
337 434 def __init__(hull, sample, direct_plan, space='G'): def __init__(hull, sample, direct_plan, space='G'):
 
... ... class DirectHull:
422 519 class CompleteHull: class CompleteHull:
423 520 # take some global functions # take some global functions
424 521 fire = fire fire = fire
522 _orth_helper = _orth_helper
523 get_orth_outside = get_orth_outside
524 get_orth_equations = get_orth_equations
525
425 526 _2FORM_helper = _2FORM_helper _2FORM_helper = _2FORM_helper
426 527 get_2FORM_outside = get_2FORM_outside get_2FORM_outside = get_2FORM_outside
427 get_2FORM_points = get_2FORM_points
428 get_2FORM_direction = _2FORM_helper
528 get_2FORM_equations = get_2FORM_equations
429 529
430 530 def __init__(hull, sample, direct_plan, space='G'): def __init__(hull, sample, direct_plan, space='G'):
431 531 hull.sample = sample hull.sample = sample
 
... ... class CompleteHull:
541 641
542 642 class QHull: class QHull:
543 643 # take some global function # take some global function
644 _orth_helper = _orth_helper
645 #get_orth_outside = get_orth_outside
646 get_orth_equations = get_orth_equations
647
544 648 _2FORM_helper = _2FORM_helper _2FORM_helper = _2FORM_helper
545 get_2FORM_points = get_2FORM_points
546 get_2FORM_direction = _2FORM_helper
649 #get_2FORM_outside = get_2FORM_outside
650 get_2FORM_equations = get_2FORM_equations
547 651
548 652 def __init__(self, sample, space='G', incremental=True): def __init__(self, sample, space='G', incremental=True):
549 653 self.sample = sample self.sample = sample
 
... ... class QHull:
664 768
665 769
666 770
771 def get_orth_outside(hull):
772 try:
773 return get_orth_outside(hull)
774 except:
775 #č asi máme problém s triangulací
776 #č odvažně vratíme jedničku
777 #č neřikejte mi, že musím pěčlivějc zpracovavat chyby!
778 return 1
779
667 780 def get_2FORM_outside(hull): def get_2FORM_outside(hull):
668 if not hull.enough_points:
669 return 1 #č odvažný odhad
670 elif hull.space == 'G':
671 try:
672 # hull._update() will perform _FORM_helper()
673 x_backward, x_forward, __a = hull._2FORM_helper()
674 return stats.norm.cdf(x_backward) + stats.norm.sf(x_forward)
675 except: #č ve světě QHull se může nastat jakékoliv zázrak
676 #č Nějaká chyba! Něco se pokazilo!
677 #č nasrat. Posíláme odvažně jedničku-redkvičku
678 return 1
679 else:
680 #č když prostor není G, můžeme sice něco odvodit od s-ball
681 #č ale nechť se s tím pará GHull, vrátíme nulu.
682 return 0
781 try:
782 return get_2FORM_outside(hull)
783 except:
784 #č asi máme problém s triangulací
785 #č odvažně vratíme jedničku
786 #č neřikejte mi, že musím pěčlivějc zpracovavat chyby!
787 return 1
683 788
684 789
685 790
 
... ... except BaseException as e:
701 806
702 807
703 808 class Ghull: class Ghull:
704 def __init__(self, hull, use_MC=False, non_Gaussian_reduction=0.9):
809 def __init__(self, hull, calculate_orth=True, calculate_2FORM=True, use_MC=False, non_Gaussian_reduction=0.9):
705 810 self.hull = hull self.hull = hull
706 811 self.shell = sball.Shell(hull.sample.nvar) self.shell = sball.Shell(hull.sample.nvar)
707 812 self.outside_dist = sball.Shell(hull.sample.nvar) self.outside_dist = sball.Shell(hull.sample.nvar)
708 813 self.sample = hull.sample self.sample = hull.sample
709 814
815 #č vlastně nevím, ale nemusejí byť úplně zadarmo...
816 self.calculate_orth = calculate_orth
817 self.calculate_2FORM = calculate_2FORM
818
710 819 self.use_MC = use_MC self.use_MC = use_MC
711 820
712 821 if use_MC: if use_MC:
 
... ... class Ghull:
742 851 nodes = self.sample.f_model.new_sample(nodes_G, space='G') nodes = self.sample.f_model.new_sample(nodes_G, space='G')
743 852 return nodes return nodes
744 853
854 def get_orth_outside(self):
855 if self.hull.space == 'G':
856 return self.hull.get_orth_outside()
857 else:
858 #č bude to horší jak s-ball, ale budiž.
859 x = np.full(self.sample.nvar, self.get_R())
860 return calculate_brick_complement_probability(-x, x)
861
745 862 def get_2FORM_outside(self): def get_2FORM_outside(self):
746 863 if self.hull.space == 'G': if self.hull.space == 'G':
747 864 return self.hull.get_2FORM_outside() return self.hull.get_2FORM_outside()
 
... ... class Ghull:
750 867 #č Když 2FORM, tak 2FORM! #č Když 2FORM, tak 2FORM!
751 868 return 2 * stats.norm.sf(self.get_R()) return 2 * stats.norm.sf(self.get_R())
752 869
870 def get_FORM_outside(self):
871 if self.hull.space == 'G':
872 return stats.norm.sf(self.get_r())
873 else:
874 return stats.norm.sf(self.get_R())
875
753 876 def get_R(self): def get_R(self):
754 877 sum_squared = np.sum(np.square(self.sample.G), axis=1) sum_squared = np.sum(np.square(self.sample.G), axis=1)
755 878 #index = np.argmax(sum_squared) #index = np.argmax(sum_squared)
 
... ... class Ghull:
796 919 shell_estimation = {-22:shell.ps, -3: shell.p_shell, -11: shell.pf} shell_estimation = {-22:shell.ps, -3: shell.p_shell, -11: shell.pf}
797 920 global_stats = {"nsim":self.sample.nsim, "ndim":self.sample.nvar, \ global_stats = {"nsim":self.sample.nsim, "ndim":self.sample.nvar, \
798 921 "nfacets": self.hull.nsimplex, "r":r, "R":R, \ "nfacets": self.hull.nsimplex, "r":r, "R":R, \
799 "2FORM_outside": self.get_2FORM_outside(),\
800 922 "inner":shell.ps, "shell":shell.p_shell, "outer":shell.pf} "inner":shell.ps, "shell":shell.p_shell, "outer":shell.pf}
923 global_stats['FORM_outside'] = self.get_FORM_outside()
924 if self.calculate_2FORM:
925 global_stats['2FORM_outside'] = self.get_2FORM_outside()
926 if self.calculate_orth:
927 global_stats['orth_outside'] = self.get_orth_outside()
801 928 return shell_estimation, global_stats return shell_estimation, global_stats
802 929
803 930 #č nie #č nie
File qt_plot.py changed (mode: 100644) (index 1fcf59b..eaa8ca2)
... ... class HullEstimationWidget(pg.LayoutWidget):
3050 3050 params.append({'name': 'inside', 'type': 'color', 'value': (133, 172, 102, 255) }) params.append({'name': 'inside', 'type': 'color', 'value': (133, 172, 102, 255) })
3051 3051 params.append({'name': 'convex_hull', 'type': 'color', 'value': (85, 170, 255, 255) }) # (186, 109, 0, 255) params.append({'name': 'convex_hull', 'type': 'color', 'value': (85, 170, 255, 255) }) # (186, 109, 0, 255)
3052 3052 params.append({'name': 'fire', 'type': 'color', 'value': (245, 117, 0, 255) }) params.append({'name': 'fire', 'type': 'color', 'value': (245, 117, 0, 255) })
3053 params.append({'name': 'FORM', 'type': 'color', 'value': (255, 0, 0, 255) })
3053 params.append({'name': 'orth', 'type': 'color', 'value': (255, 0, 0, 255) })
3054 3054 params.append({'name': 'outside', 'type': 'color', 'value': 0.6}) params.append({'name': 'outside', 'type': 'color', 'value': 0.6})
3055 3055 params.append({'name': 'R', 'type': 'color', 'value': (85, 85, 255, 255) }) params.append({'name': 'R', 'type': 'color', 'value': (85, 85, 255, 255) })
3056 3056 params.append({'name': 'Update as the box runned', 'type': 'bool', 'value': False }) # 'tip': "This is a checkbox" params.append({'name': 'Update as the box runned', 'type': 'bool', 'value': False }) # 'tip': "This is a checkbox"
 
... ... class HullEstimationWidget(pg.LayoutWidget):
3114 3114 else: else:
3115 3115 return None return None
3116 3116
3117 def draw_planes(self, equations, space, **kwargs):
3118 if self.ndim == 2:
3119 #č musíme něco zavolat na self.equation_planes
3120 #č equation_planes má funkci add_line()
3121 #č add_line(self, space='G', index=None, **plot_kwargs)
3122 #č která pak plot_kwargs přeposilá funkci addLine()
3123 #č na central widgetu.
3124 #č To vše skončí ve pyqtgrafové InfiniteLine třidě.
3125 #č ta moje třida InfiniteLines sama se stará o shodování prostorů
3126 #č indexy posilat nebudeme (s nimi je to trošku komplikovanější)
3127
3128 #pos = list() #č navrhové body nakreslíme všechny dohromady
3129 for equation in equations:
3130 #č ve 2D bych očekával v rovnici pouze 3 hodnoty (já potřebuji směry)
3131 x, y, offset = equation
3132 design_point = [-x*offset, -y*offset]
3133 #self.sb_item.central_widget.plot(np.array([pos, pos]), symbol='o')
3134 # if y < 0: #č tak to aspoň kreslí
3135 # angle = np.rad2deg(np.arcsin(x))
3136 # else:
3137 # angle = np.rad2deg(np.arccos(y))
3138
3139 if (x*y) < 0: #č tak to aspoň kreslí
3140 angle = np.rad2deg(np.arccos(np.abs(y)))
3141 else:
3142 angle = np.rad2deg(np.arccos(-np.abs(y)))
3143 self.equation_planes.add_line(space=space, pos=design_point, angle=angle, **kwargs)
3144
3145
3146
3117 3147 def draw_convex_hull(self, hull): def draw_convex_hull(self, hull):
3118 3148 try: try:
3119 3149 if self.param.getValues()['index'][0]: # replace previous if self.param.getValues()['index'][0]: # replace previous
 
... ... class HullEstimationWidget(pg.LayoutWidget):
3128 3158 self.giracle.add_serie(design_points, z=31, index=self.index('design points'),\ self.giracle.add_serie(design_points, z=31, index=self.index('design points'),\
3129 3159 pen=None, symbol='o', symbolPen=pg.mkPen(None), \ pen=None, symbol='o', symbolPen=pg.mkPen(None), \
3130 3160 symbolBrush=color, symbolSize=size, name='design points') symbolBrush=color, symbolSize=size, name='design points')
3131 if self.ndim == 2:
3132 #č musíme něco zavolat na self.equation_planes
3133 #č equation_planes má funkci add_line()
3134 #č add_line(self, space='G', index=None, **plot_kwargs)
3135 #č která pak plot_kwargs přeposilá funkci addLine()
3136 #č na central widgetu.
3137 #č To vše skončí ve pyqtgrafové InfiniteLine třidě.
3138 #č ta moje třida InfiniteLines sama se stará o shodování prostorů
3139 #č indexy posilat nebudeme (s nimi je to trošku komplikovanější)
3140
3141 #pos = list() #č navrhové body nakreslíme všechny dohromady
3142 for equation in hull.equations:
3143 #č ve 2D bych očekával v rovnici pouze 3 hodnoty (já potřebuji směry)
3144 x, y, offset = equation
3145 design_point = [-x*offset, -y*offset]
3146 #self.sb_item.central_widget.plot(np.array([pos, pos]), symbol='o')
3147 # if y < 0: #č tak to aspoň kreslí
3148 # angle = np.rad2deg(np.arcsin(x))
3149 # else:
3150 # angle = np.rad2deg(np.arccos(y))
3151
3152 if (x*y) < 0: #č tak to aspoň kreslí
3153 angle = np.rad2deg(np.arccos(np.abs(y)))
3154 else:
3155 angle = np.rad2deg(np.arccos(-np.abs(y)))
3156 self.equation_planes.add_line(space=hull.space,\
3157 z=29, pos=design_point, angle=angle, pen=color)
3161 self.draw_planes(hull.equations, space=hull.space, z=29, pen=color)
3158 3162
3159 3163
3160 # 2FORM
3161 FORM_points = hull.get_2FORM_points()
3164 # orth
3165 color = self.param.getValues()['orth'][0] #č tam bude barva
3166 #self.giracle.add_serie(FORM_points, z=32, index=self.index('2FORM points'),\
3167 # pen=None, symbol='o', symbolPen=pg.mkPen(None), \
3168 # symbolBrush=color, symbolSize=size, name='2FORM points')
3169 self.draw_planes(hull.get_orth_equations(), space=hull.space, z=30, pen=color)
3162 3170
3163 color = self.param.getValues()['FORM'][0] #č tam bude barva
3164 3171
3165 self.giracle.add_serie(FORM_points, z=32, index=self.index('2FORM points'),\
3166 pen=None, symbol='o', symbolPen=pg.mkPen(None), \
3167 symbolBrush=color, symbolSize=size, name='2FORM points')
3168 if self.ndim == 2:
3169 #č musíme něco zavolat na self.equation_planes
3170 #č equation_planes má funkci add_line()
3171 #č add_line(self, space='G', index=None, **plot_kwargs)
3172 #č která pak plot_kwargs přeposilá funkci addLine()
3173 #č na central widgetu.
3174 #č To vše skončí ve pyqtgrafové InfiniteLine třidě.
3175 #č ta moje třida InfiniteLines sama se stará o shodování prostorů
3176 #č indexy posilat nebudeme (s nimi je to trošku komplikovanější)
3177
3178 __x_b, __x_f, a = hull.get_2FORM_direction()
3179 if np.prod(a) < 0: #č tak to aspoň kreslí
3180 angle = np.rad2deg(np.arccos(np.abs(y)))
3181 else:
3182 angle = np.rad2deg(np.arccos(-np.abs(y)))
3183 G_nodes = FORM_points.G
3184 self.equation_planes.add_line(space='G',\
3185 z=30, pos=G_nodes[0], angle=angle, pen=color)
3186 self.equation_planes.add_line(space='G',\
3187 z=30, pos=G_nodes[1], angle=angle, pen=color)
3172 # 2FORM
3173 color = self.param.getValues()['fire'][0] #č tam bude barva
3174 #self.giracle.add_serie(FORM_points, z=32, index=self.index('2FORM points'),\
3175 # pen=None, symbol='o', symbolPen=pg.mkPen(None), \
3176 # symbolBrush=color, symbolSize=size, name='2FORM points')
3177 self.draw_planes(hull.get_2FORM_equations(), space=hull.space, z=30, pen=color)
3178
3188 3179
3189 3180 except BaseException as e: except BaseException as e:
3190 3181 msg = "draw_convex_hull error " msg = "draw_convex_hull error "
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