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)
mplot: plot2D swithed to matplotlib 366326fb53bcbc54d7e6fb108b9dc256833bf679 I am 2021-03-18 01:44:07
three-ways image WIP a2987cde393c4e795342f6dc40d5920760b468d4 I am 2021-03-17 16:37:18
Ghull is ready e1a49fe0cb390ce9664e8f892c1da6d30231cc99 I am 2021-03-16 14:29:09
simplex: finish Ghull 5cb6d06a1c77cdb0cc1d3e83cfb217924b2345f1 I am 2021-03-03 23:06:13
simplex.Ghull: WIP 043724e7d4fe0c25ac698becf6498bc2abb8bf29 I am 2021-03-03 17:06:08
sball: je naimplementována třída Shell b335ba64be48582ca2f31baf035d0f5c6c75090c I am 2021-03-03 13:45:02
sball: new gamma-based solution. Keep the old version as well b6ac51b6b08ca2e7d5c398fa56c5a9a0832ab301 I am 2021-02-24 10:55:11
mart: add convergence plot 85a9ef727d15fc6567b7b0a594ed52cef9fe5680 I am 2021-02-22 23:32:34
mart: add basic plot and scatter functions 20e04c27db7ee3ac3a6418300eb4fc1ef532a1c7 I am 2021-02-22 14:45:31
mart: add convex hull related functions 5284e4c1c747fe25d220e7e3a6a9803d8bc6d4a1 I am 2021-02-21 20:57:52
axes3d_: draw only bottom pane 5a24020e052a7adbc17485b4c9c74d7eea801765 Alex 2021-02-12 20:50:09
mart3d: tri surface fix 2f1889070cea6c97937e00d76ce029744c9f8d07 Alex 2021-02-12 10:01:59
mart3d: add plot_wireframe 8b21a8ca659e4f2146459ea5f4cc006535f51308 I am 2021-02-12 04:45:56
mart and mart3d: add new functions fdbfd002214bf7ab7be8df8e90d6b96b62c82d13 I am 2021-02-10 17:18:02
qt_plot: update slider on redraw, add simplex estimation with no graphics 7b392cd9ee8487a620466fe757a17c7fcfff2770 I am 2021-02-09 23:00:32
mart: WIP 81d970b1e515032f0414d1cc4c6d7473f187d162 I am 2021-02-09 19:38:36
mart3d: add scatter_points() 26644c64e3b996b68e1ee133e4531380d4e00090 I am 2021-02-08 18:03:51
mart3d: new matplotlib-support module 8b6b13937a0694998e0b4de7b8a96d89abecc64a I am 2021-02-08 13:47:56
gmodels: increased no of discretization points in boundary for Pareto function 7f12597e2d15b2564d612a014fd75492663043dd Miroslav Vořechovský 2021-02-05 15:28:32
gmodels.py added boundary for Pareto function e7bc61e9c5854bc4cff0ee05b651b4b7ede4e0a1 Miroslav Vořechovský 2021-02-05 15:14:52
Commit 366326fb53bcbc54d7e6fb108b9dc256833bf679 - mplot: plot2D swithed to matplotlib
Author: I am
Author date (UTC): 2021-03-18 01:44
Committer name: I am
Committer date (UTC): 2021-03-18 01:44
Parent(s): a2987cde393c4e795342f6dc40d5920760b468d4
Signer:
Signing key:
Signing status: N
Tree: f0e82ede225a2c0c25e13056bb181ed4b7d65113
File Lines added Lines deleted
mart.py 72 21
mgraph.py 151 0
mplot.py 37 308
plot.py 10 8
File mart.py changed (mode: 100644) (index c1e84b9..071b20e)
8 8 import numpy as np import numpy as np
9 9 import matplotlib.tri as mtri import matplotlib.tri as mtri
10 10 import matplotlib.colors as mcolor import matplotlib.colors as mcolor
11 import matplotlib.patches as mpatches
12
13 from . import misc
11 14
12 15 def get_simplices_colors(sb, simplices): #simplices = bx.tri.simplices def get_simplices_colors(sb, simplices): #simplices = bx.tri.simplices
13 16 s = '#a7ffb5' #'xkcd:light seafoam green' #a7ffb5 s = '#a7ffb5' #'xkcd:light seafoam green' #a7ffb5
 
... ... def convex_plot(ax, fmt='-m', ns=100, **kwargs):
167 170 return lines return lines
168 171
169 172
173 def gcircle(ax, r=1, nrod=200, **kwargs):
174 if ax.space == 'G':
175 circle = mpatches.Circle((0,0), r, **kwargs)
176 else:
177 phi = np.linspace(0, 6.283185307, nrod, endpoint=True)
178 cos_phi = np.cos(phi)
179 sin_phi = np.sin(phi)
180
181 sample_G = np.array((cos_phi, sin_phi)).T * r
182
183 f_model = ax.sample_box.f_model
184 sample = f_model.new_sample(sample_G, space='G', extend=True)
185 xy = getattr(sample, ax.space)[:,:2]
186 circle = mpatches.Polygon(xy, **kwargs)
187
188 #č vrací add_patch něco?
189 return ax.add_patch(circle)
170 190
171 191
192 def uframe(ax, **kwargs):
193 if ax.space in ('P', 'aP', 'U', 'aU'):
194 alpha = ax.sample_box.alpha
195 frame = mpatches.Rectangle((0,0), alpha[0], alpha[1], fill=False, **kwargs)
196 return ax.add_patch(frame)
172 197
173 198
174 199
175 def isočáry(ax, space, ngrid=200, limits=None):
200 def isocurves(ax, ngrid=200, limits=None, ncurves=5, **kwargs):
176 201 if limits is None: if limits is None:
177 xmin, xmax = ax.get_xlim()
178 ymin, ymax = ax.get_ylim()
202 #xmin, xmax = ax.get_xlim()
203 #ymin, ymax = ax.get_ylim()
204
205 sample_G = np.array([[-ncurves, -ncurves], [ncurves, ncurves]])
206 sample = ax.sample_box.f_model.new_sample(sample_G, space='G', extend=True)
207 xy = getattr(sample, ax.space)[:,:2]
208 xmin, ymin = np.min(xy, axis=0)
209 xmax, ymax = np.max(xy, axis=0)
210
179 211 else: # G-čko zlobí else: # G-čko zlobí
180 212 xmin, xmax, ymin, ymax = limits xmin, xmax, ymin, ymax = limits
181
213
214
215
182 216 x = np.linspace(xmin, xmax, ngrid) x = np.linspace(xmin, xmax, ngrid)
183 217 y = np.linspace(ymin, ymax, ngrid) y = np.linspace(ymin, ymax, ngrid)
184 218 X, Y = np.meshgrid(x, y) X, Y = np.meshgrid(x, y)
185 219 XY = np.vstack((X.flatten(), Y.flatten())).T XY = np.vstack((X.flatten(), Y.flatten())).T
186 Z = f.sample_pdf(XY, space)
220 Z = ax.sample_box.f_model.sample_pdf(XY, ax.space)
221
187 222
188 ncurves = 3
189 223 const = 1 / (xmax - xmin) / (ymax - ymin) const = 1 / (xmax - xmin) / (ymax - ymin)
190 224 r_levels = np.arange(ncurves) + 1 r_levels = np.arange(ncurves) + 1
191 225 levels = misc.isolevels_2d(Z, const, np.flip(r_levels), from_top=False) levels = misc.isolevels_2d(Z, const, np.flip(r_levels), from_top=False)
192
193 return ax.contour(X, Y, Z.reshape(ngrid, ngrid), levels, linewidths=lw, colors=[[96/255, 64/255, 96/255], [0.5, 0.25, 0.5], [161/255, 72/255, 162/255]])#, alpha=0.5) colors: h=300, s=50%
194
195
196
197
198
199
200
201
202
203
204
205
206
226 return ax.contour(X, Y, Z.reshape(ngrid, ngrid), levels, **kwargs)
207 227
208 228
209 229
 
... ... def fix_locator(ax, loc):
235 255 loc_y = mpl.ticker.FixedLocator(loc) loc_y = mpl.ticker.FixedLocator(loc)
236 256 ax.yaxis.set_major_locator(loc_y) ax.yaxis.set_major_locator(loc_y)
237 257
258 #č něco_kulatého
259 def curly(ax, linewidths=[0.7, 0.5, 0.4, 0.3, 0.2, 0.1], nrid=200, color='k', **kwargs):
260 if ax.space in ('U', 'aU'):
261 return None
262
263 elif (ax.sample_box.nvar==2) and (ax.space in ('Rn', 'aRn', 'R', 'aR', 'P', 'aP')):
264 isocurves(ax, ngrid=nrid, limits=None, ncurves=len(linewidths),\
265 linewidths=np.flip(linewidths), colors=[color], **kwargs)
266
267 else:
268 for i, lw in zip(range(len(linewidths)), linewidths):
269 gcircle(ax, r=i+1, nrod=nrid, color=color, linewidth=lw, fill=False)
270
271
272 def setup(ax, lw=1): #č šup
273 #ax.set_xlabel('$x_{1}$')
274 #ax.set_ylabel('$x_{2}$')
275
276 #ax.set_frame_on(False) #č pak se mi nezobrazí osy
277 ax.set_aspect(1)
278 #ax.set_box_aspect(1)
279 if ax.space in ('P', 'aP', 'U', 'aU'):
280 ax.margins(0)
281 ax.set_frame_on(False)
282 uframe(ax, linewidth=lw)
283 else:
284 center_spines(ax)
285
286
287
288
File mgraph.py added (mode: 100644) (index 0000000..faac09f)
1 #!/usr/bin/env python
2 # coding: utf-8
3
4
5 #č nazvy proměnných jsou v angličtině
6 #č Ale komenty teda ne)
7
8
9 #č sehnaní datarámu necháme uživateli
10 def tri_estimation_fill(ax, df):
11 # some default values
12 if not ax.get_xlabel():
13 ax.set_xlabel('Number of simulations')
14 if not ax.get_ylabel():
15 ax.set_ylabel('Probability measure')
16
17 #xkcd_green = (167, 255, 181) # xkcd:light seafoam green #a7ffb5
18 green = "#A7FFB5"
19 #xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
20 red = "#FDC1C5"
21 #xkcd_cream = (255, 243, 154) # let's try xkcd: dark cream (#fff39a)
22 cream = "#FFF39A"
23 grey = "#DDDDDD"
24 colors = (red, cream, grey, green)
25 o = df['outside'].to_numpy()
26 s = df['success'].to_numpy()
27 f = df['failure'].to_numpy()
28 m = df['mix'].to_numpy()
29 labels = ("failure domain estimation", "mixed simplices measure",\
30 "out of sampling domain estimation", "success domain estimation")
31 return ax.stackplot(df.index, f, m, o, s, labels=labels, colors=colors)
32
33
34 #č sehnaní datarámu necháme uživateli
35 # inverted
36 def trii_estimation_fill(ax, df):
37 # some default values
38 if not ax.get_xlabel():
39 ax.set_xlabel('Number of simulations')
40 if not ax.get_ylabel():
41 ax.set_ylabel('Probability measure')
42
43 #xkcd_green = (167, 255, 181) # xkcd:light seafoam green #a7ffb5
44 green = "#A7FFB5"
45 #xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
46 red = "#FDC1C5"
47 #xkcd_cream = (255, 243, 154) # let's try xkcd: dark cream (#fff39a)
48 cream = "#FFF39A"
49 grey = "#DDDDDD"
50 colors = (grey, red, cream, green)
51 o = df['outside'].to_numpy()
52 s = df['success'].to_numpy()
53 f = df['failure'].to_numpy()
54 m = df['mix'].to_numpy()
55 labels = ("out of sampling domain estimation", "failure domain estimation",\
56 "mixed simplices measure", "success domain estimation")
57 return ax.stackplot(df.index, o, f, m, s, labels=labels, colors=colors)
58
59
60
61 #č ok, tak uděláme všecko dohromady
62 #č datarám, jako vždy, uživatel donese svůj vlastní
63 def trii_estimation_plot(ax, df):
64 # fill
65 trii_estimation_fill(ax, df)
66
67 #č teď čáry
68 v = df['vertex_estimation'].to_numpy()
69 wv = df['weighted_vertex_estimation'].to_numpy()
70 # v trii grafu máme outside zdolu
71 mask = v > 0
72 o = df['outside'].to_numpy()[mask]
73 vo = v[mask] + o
74 wvo = wv[mask] + o
75 ax.plot(df.index[mask], vo, '-m', label="simple $p_f$ estimation")
76 ax.plot(df.index[mask], wvo, '-r', label="weighted $p_f$ estimation")
77
78 # pf_exact - povinné :)
79 ax.axhline(ax.sample_box.pf_exact, c='b', label=ax.sample_box.pf_exact_method)
80
81
82
83 ##xkcd_green = (167, 255, 181) # xkcd:light seafoam green #a7ffb5
84 #green = (0, 255, 38, 96)
85 ##xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
86 #red = (253, 0, 17, 96)
87 ##xkcd_cream = (255, 243, 154) # let's try xkcd: dark cream (#fff39a)
88 #cream = (255, 221, 0, 96)
89 #grey = (196, 196, 196, 96)
90
91 class SimplexErrorGraph:
92
93
94 def show_labels(self):
95 self.setLabel('left', "Failure probability estimation error")
96 self.setLabel('bottom', "Number of simulations")
97
98
99 def setup(self, *args, **kwargs):
100
101 #xkcd_red = (253, 193, 197) # xkcd: pale rose (#fdc1c5)
102 #red = (253, 0, 17, 96)
103
104 #self.pen_f = self.plot(x, y, brush=red)#, name="failure domain estimation")
105 #self.pen_f.setZValue(-100)
106
107
108 pen = pg.mkPen(color='m', width=2)
109 self.pen_vertex = self.plot(x, y, pen=pen, name="simple pf estimation")
110 pen = pg.mkPen(color='r', width=2) #(118, 187, 255)
111 self.pen_weighted_vertex = self.plot(x, y, pen=pen, name="weighted pf estimation")
112
113
114
115 #č když se někde objeví nula se zapnutým LogModem -
116 #č qtpygraph hned spadne a není možne ten pad zachytit
117 def zerosafe(self, x, y, fallback_y=None):
118 x = np.array(x)
119 y = np.array(y)
120 if fallback_y is None:
121 fallback_y = y
122 y = np.where(y > 0, y, fallback_y)
123 mask = y > 0
124 return x[mask], y[mask]
125
126
127 def redraw(self):
128 #č neotravujme uživatele chybovejma hlaškama
129 if hasattr(self.simplex_data.dice_box, 'pf_exact'):
130 try: #ё тут всё что угодно может пойти не так
131 pf_exact = self.simplex_data.dice_box.pf_exact
132
133 df = self.simplex_data.df
134 #č zapíšeme do data rámu, snad nikomu nebude vadit
135 df['vertex_estimation_error'] = df['vertex_estimation'] - pf_exact
136 df['weighted_vertex_estimation_error'] = df['weighted_vertex_estimation'] - pf_exact
137
138 v = df['vertex_estimation_error'].abs()
139 wv = df['weighted_vertex_estimation_error'].abs()
140
141 x, y = self.zerosafe(v.index, v.to_numpy())
142 self.pen_vertex.setData(x, y)
143
144 x, y = self.zerosafe(wv.index, wv.to_numpy())
145 self.pen_weighted_vertex.setData(x, y)
146
147
148 except BaseException as e:
149 print(self.__class__.__name__ + ":", repr(e))
150
151
File mplot.py changed (mode: 100644) (index 1f6dd06..fe482f4)
8 8
9 9 import matplotlib import matplotlib
10 10 import matplotlib.pyplot as plt import matplotlib.pyplot as plt
11 matplotlib.rcParams['mathtext.fontset'] = 'stix'
11 matplotlib.rcParams['mathtext.fontset'] = 'cm' # Computer Modern (TeX)
12 12 matplotlib.rcParams['font.family'] = 'STIXGeneral' matplotlib.rcParams['font.family'] = 'STIXGeneral'
13 13
14
15 #from scipy.special import gamma, factorial
16
17 #import numpy as np
18 ##import numpy.ma as ma
19 #import scipy.stats as stats
20 #
21 ##import scipy.integrate as integrate
22 ##from scipy.spatial import ConvexHull
23 ##from scipy.spatial import cKDTree
24 #
25 #from scipy import spatial
26 #
27 ##import lukiskon as lk
28 #import g_models
29 #import f_models
30 #
31 #import whitebox
32 #
33 ##import itertools
34 #
35 ## patří to asi do user kódu
36 ## pro zobrazení v interaktivním okně (IPython)
37 ## get_ipython().run_line_magic('matplotlib', 'nbagg')
38 #
39 #
40 #
41 #
42 ## Estimation of pf given a list of red and green points (Voronoi)
43 ##
44 #
45 #def show_shape(patch):
46 # ax=plt.gca()
47 # ax.add_patch(patch)
48 # #plt.axis('scaled')
49 # plt.show()
50 #
51 #def show_shape(patch, ax):
52 # ax.add_patch(patch)
53 # #plt.axis('scaled')
54 # plt.show()
55 #
56 #def draw_voronoi(ax, ns):
57 #
58 # plt=ax
59 #
60 # #%% Draw R-space
61 # r = 4 # tato r-ko v local namespace, vid?
62 #
63 # x = bx.sampled_plan.R[:ns,0]
64 # y = bx.sampled_plan.R[:ns,1]
65 #
66 # mask = bx.failsi[:ns]
67 #
68 #
69 # plt.plot(x[ mask], y[ mask], 'o', c='r' , markersize=1.0)
70 # plt.plot(x[~mask], y[~mask], 'o', c='g' , markersize=1.0)
71 #
72 # #for j, p in enumerate(sampled_plan_R):
73 # # plt.text(p[0]-0.0, p[1]+0.0, j, ha='right') # label the points
74 #
75 # if gm.__class__.__name__ == 'S_ball':
76 # xbound = np.linspace(-r, +r, 100)
77 # plt.plot(xbound, +np.sqrt(r**2 - xbound**2), '--', c = 'blue', linewidth = 0.5)
78 # plt.plot(xbound, -np.sqrt(r**2 - xbound**2), '--', c = 'blue', linewidth = 0.5)
79 #
80 #
81 # if gm.__class__.__name__ == 'Sin2D':
82 # xbound = np.linspace(-r, +r, 100)
83 # plt.plot(xbound,- xbound/4 + np.sin(5*xbound) + 6, '--', c = 'blue', linewidth = 0.5)
84 #
85 #
86 #
87 # tree = cKDTree(bx.sampled_plan.R[:ns])
88 #
89 # nis = 1500000
90 # pf = 0 # inicializace
91 # ps = 0
92 #
93 # points_weigths = np.zeros(len(bx))
94 # near_neighbors = np.zeros(len(bx))
95 # # loop over points (need to integrate red regions)
96 #
97 #
98 # # set the minimum distance as the standard deviation of IS densisty
99 # h_i = [stats.norm(0, 2) for j in range(nvar)] #! dosadit standard deviation pddle chutí
100 #
101 #
102 # # use IS sampling density with center equal to the current "red" point
103 #
104 # # select nis = 100 points from IS density and
105 # # if the point has its nearest neighbor any red point from the sampled_plan,
106 #
107 # h_plan = np.zeros((nis, nvar))
108 # for j in range(nvar):
109 # h_plan[:, j] = h_i[j].rvs(nis) # realizace váhové funkce náhodné veličiny
110 #
111 # # Rozptyl corrected IS
112 # weights_sim = bx.f.new_sample(h_plan).pdf_R / np.prod([h_i[j].pdf(h_plan[:, j])
113 # for j in range(nvar)], axis=0) # [f1/h1, ..., fn/hn]
114 #
115 #
116 #
117 # dd, ii = tree.query(h_plan)
118 #
119 # Vor_mask = np.empty(len(ii), dtype=bool)# np.where(ii==i, True, False)
120 #
121 # for k in range(len(ii)):
122 # #points_weigths[ii[k]] = points_weigths[ii[k]] + weights_sim[k] / nis
123 # #near_neighbors[ii[k]] = near_neighbors[ii[k]] + 1
124 # Vor_mask[k] = bx.failsi[ii[k]]
125 #
126 # pf = np.sum(weights_sim[Vor_mask])/nis
127 # #print(pf)
128 #
129 #
130 # # rohy. jasně
131 # #plt.plot(сэрегъёс_R[:,0], сэрегъёс_R[:,1], 'o', c='b' )
132 #
133 #
134 # x_grid = h_plan[:,0]
135 # y_grid = h_plan[:,1]
136 #
137 # marker_vole = matplotlib.markers.MarkerStyle(marker='.', fillstyle='full')
138 # plt.scatter(x_grid[ Vor_mask], y_grid[ Vor_mask], c='xkcd:pale rose' , s=0.125**2, edgecolors='face', marker=marker_vole, alpha=1 ) #'YlOrRd' cmap='Wistia',
139 # plt.scatter(x_grid[~Vor_mask], y_grid[~Vor_mask], c='xkcd:light seafoam green', s=0.125**2, edgecolors='face', marker=marker_vole, alpha=1 ) #'YlOrRd' cmap='Wistia',
140 #
141 #
142 # #ax0.plot(x_w[fail_wgP], y_w[fail_wgP], 's', color='xkcd:mango', markersize=1)
143 # # ax0.plot(x_w[fail_wsP], y_w[fail_wsP], 's', color='xkcd:light seafoam green', markersize=1)
144 # # ax0.plot(x_w[fail_w1P], y_w[fail_w1P], 's', color='xkcd:pale rose', markersize=1)
145 # # ax0.plot(x_w[fail_w2P], y_w[fail_w2P], 's', color='xkcd:khaki', markersize=1)
146 #
147 #
148 # #plt.xlim(-8, 8); plt.ylim(-8, 8)
149 # lim = 6.0
150 # ax.set_xlim(-lim, lim)
151 # ax.set_ylim(-lim, lim)
152 # ax.set_aspect('equal')
153 # #ax.set_xticks([-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6])
154 # #ax.set_yticks([-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6])
155 # ax.set_xticks([-6,-4,-2,0,2,4,6])
156 # ax.set_yticks([-6,-4,-2,0,2,4,6])
157 # #plt.axis('equal')
158 #
159 #
160 #
161 #
162 #
163 #
164 # #pf = np.sum(points_weigths[failsi]*1/near_neighbors[failsi])
165 # #pf = np.sum(points_weigths[failsi]) #/ nis / len(failure_points_indexes)
166 #
167 # print(pf)
168 #
169 #
170 ## In[66]:
171 #
172 #
173 #
174 #
175 #from scipy.spatial import cKDTree
176 #
177 ## workaround :D
178 #from matplotlib.axes._axes import _log as matplotlib_axes_logger
179 #matplotlib_axes_logger.setLevel("DEBUG")
180 #
181 #fig, ([ax1, ax2], [ax3, ax4]) = plt.subplots(nrows=2, ncols=2, figsize=(7, 6), tight_layout=True)
182 #
183 #nsim = bx.nsim
184 #
185 #draw_voronoi(ax1, int(nsim/8))
186 #ax1.set_title('n={0}'.format(int(nsim/8)))
187 #
188 #draw_voronoi(ax2, int(nsim/4))
189 #ax2.set_title('n={0}'.format(int(nsim/4)))
190 #
191 #draw_voronoi(ax3, int(nsim/2))
192 #ax3.set_title('n={0}'.format(int(nsim/2)))
193 #
194 #draw_voronoi(ax4, nsim)
195 #ax4.set_title('n={0}'.format(nsim))
196 ##ax1.set_ylabel('U prostor')
197 ##ax3.set_ylabel('R prostor')
198 ##ax1.set_title('Teselace v U prostoru')
199 ##ax2.set_title('Teselace v R prostoru')
200 #
201 #
202 #ax1.set_xlabel('$x_{1}$')
203 #ax1.set_ylabel('$x_{2}$')
204 #ax2.set_xlabel('$x_{1}$')
205 #ax2.set_ylabel('$x_{2}$')
206 #ax3.set_xlabel('$x_{1}$')
207 #ax3.set_ylabel('$x_{2}$')
208 #ax4.set_xlabel('$x_{1}$')
209 #ax4.set_ylabel('$x_{2}$')
210 #
211 ##ax1.set_xlim(-8, 8)
212 ##ax1.set_ylim(-8, 8)
213 ##ax1.set_aspect('equal')
214 #
215 ## plot unit circles for better orientation
216 #
217 #for ax in [ax1, ax2, ax3, ax4]:
218 # circle1 = plt.Circle((0, 0), 1, color='k', linewidth = 0.7, fill=False)
219 # circle2 = plt.Circle((0, 0), 2, color='k', linewidth = 0.5, fill=False)
220 # circle3 = plt.Circle((0, 0), 3, color='k', linewidth = 0.4, fill=False)
221 # circle4 = plt.Circle((0, 0), 4, color='k', linewidth = 0.3, fill=False)
222 # circle5 = plt.Circle((0, 0), 5, color='k', linewidth = 0.2, fill=False)
223 # circle6 = plt.Circle((0, 0), 6, color='k', linewidth = 0.1, fill=False)
224 # show_shape(circle1, ax)
225 # show_shape(circle2, ax)
226 # show_shape(circle3, ax)
227 ##show_shape(circle4)
228 ##show_shape(circle5)
229 ##show_shape(circle6)
230 #
231 ##plt.axis('square')
232 #
233 ##fig.savefig("2x2_Deloneho_Zprod.png", dpi=300)
234 ##fig.savefig("2x2.eps")
235 ##fig.savefig("2x2.svg")
236 ##fig.savefig("2x2.pdf")
237
14 from . import mart
238 15
239 16
240 17 def subplot3D(sample_box, ax3d, space='R'): def subplot3D(sample_box, ax3d, space='R'):
 
... ... def subplot3D(sample_box, ax3d, space='R'):
250 27
251 28
252 29
253 def plot3D(sample_box, space='R', filename=''):
30 def plot3D(sample_box, space='R', filename='', format='pdf'):
254 31 if not filename: if not filename:
255 filename = 'store/%s_%s_%s'%(sample_box.gm_signature, space, sample_box.nsim)
32 filename = 'store/%s_%s_%s_plot3D'%(sample_box.gm_signature, space, sample_box.nsim)
256 33 fig = plt.figure() fig = plt.figure()
257 34 ax3d = fig.add_subplot(111, projection='3d') ax3d = fig.add_subplot(111, projection='3d')
258 35 subplot3D(sample_box, ax3d, space) subplot3D(sample_box, ax3d, space)
259 36
260 37 try: # jen pro formu zkusíme, vždyť musí funkce formálně něco dělat, žejo? try: # jen pro formu zkusíme, vždyť musí funkce formálně něco dělat, žejo?
261 fig.savefig(filename + ".png")#, dpi=300)
38 fig.savefig(filename + "." + format)#, dpi=300)
262 39 except: except:
263 40 pass # nic se neděje pass # nic se neděje
264 41
265 42 # vracím plt místo figury, protože nechcem sa trapiť ivent lupem # vracím plt místo figury, protože nechcem sa trapiť ivent lupem
266 43 # return plt insted of just fig to bypass event loop issues # return plt insted of just fig to bypass event loop issues
267 return plt
44 return plt.show()
45
268 46
269 47
270 #
271 ## nikdo mi neuvěří, že by tohle postačílo a nebylo by nutné tohlensto furt úpravovat
272 #def gp_plot(sample_box, space='R', terminal='png', filename=''):
273 # if not filename:
274 # filename = 'store/%s_%s_%s'%(sample_box.gm_signature, space, sample_box.nsim)
275 # if space in ['Rn', 'GK', 'G']:
276 # gp.c('set autoscale xy')
277 # gp.c('set size square')
278 # gp.c('set zeroaxis')
279 # elif space in ['P', 'U']:
280 # gp.c('set xrange [0:1]')
281 # gp.c('set yrange [0:1]')
282 # gp.c('set size square')
283 # #gp.c('set autoscale')
284 # gp.c('unset zeroaxis')
285 # else: # R teda?
286 # gp.c('set size noratio')
287 # gp.c('set autoscale')
288 # gp.c('unset zeroaxis')
289 #
290 # gp.c('set terminal ' + terminal)
291 # gp.c('set output "%s.%s"'%(filename, terminal))
292 # if os.name == 'posix':
293 # gp.c('set decimalsign locale "POSIX"')
294 #
295 # # legenda
296 # gp.c('unset key')
297 #
298 # # se mi zda, že gp bere data v řadcích
299 # f_name = "%s_failure.dat" % (filename)
300 # s_name = "%s_success.dat" % (filename)
301 # gp.s(getattr(sample_box.failure_samples, space).T, f_name)
302 # gp.s(getattr(sample_box.success_samples, space).T, s_name)
303 #
304 #
305 # # rozkaz, který předaváme gnuplotovi
306 # gp_plot = 'plot "%s" title "Success points" w p lc rgb "green", "%s" title "Failure points" w p lc rgb "red"' % (s_name, f_name)
307 #
308 # # Kružničky chcete?
309 # # Кружочки ннада?
310 # if space in ['Rn', 'G']:
311 # gp.c('set parametric')
312 # for i in range(5):
313 # lw = 2 - i*0.3
314 # gp_plot += ', cos(t)*%s,sin(t)*%s notitle w l lc rgb "black" lw %s'%(i+1, i+1, lw)
315 #
316 # # ne všichni majó definované hranice
317 # try:
318 # bounds = sample_box.get_2D_boundary()
319 #
320 # for i in range(len(bounds)):
321 # bound = getattr(bounds[i], space).T
322 # gp.s(bound, "%s_boundary_%s.dat"%(filename, i+1))
323 # gp_plot += ', "%s_boundary_%s.dat" notitle w l lc rgb "blue"'%(filename, i+1)
324 # except AttributeError:
325 # pass
326 #
327 # # Plot!
328 # gp.c(gp_plot)
329 #
330 #
331 #
332 ## nikdo mi neuvěří, že by tohle postačílo a nebylo by nutné tohlensto furt úpravovat
333 #def plot(data2D, terminal='png', filename=''):
334 # if not filename:
335 # filename = 'store/plot_%s'%(len(data2D[0]))
336 #
337 # gp.c('set terminal ' + terminal)
338 # gp.c('set output "%s.%s"'%(filename, terminal))
339 # if os.name == 'posix':
340 # gp.c('set decimalsign locale "POSIX"')
341 #
342 #
343 # # se mi zda, že gp bere data v řadcích
344 # gp.s(data2D, filename+'.dat')
345 #
346 # # Plot!
347 # # rozkaz, který předaváme gnuplotovi
348 # gp.c('plot "%s.dat" ' % (filename))
48 # nikdo mi neuvěří, že by tohle postačílo a nebylo by nutné tohlensto furt úpravovat
49 def plot2D(sample_box, space='R', filename=None, format='pdf'):
50 if filename is None:
51 try:
52 filename = sample_box.filename
53 except:
54 filename = 'store/%s_%s_%s_plot2D'%(sample_box.gm_signature, space, sample_box.nsim)
55
56 fig = plt.figure()
57 ax = fig.add_subplot(111)
58 ax.space = space
59 ax.sample_box = sample_box
60
61 mart.setup(ax)
62 mart.curly(ax)
63 mart.plot_boundaries(ax, linewidth=0.7)
64 mart.scatter_points(ax)
65 try:
66 mart.triplot(ax, color="grey", linewidth=0.4)
67 except:
68 pass
69
70 try: # jen pro formu zkusíme, vždyť musí funkce formálně něco dělat, žejo?
71 fig.savefig(filename + "." + format, dpi=300)
72 except:
73 pass # nic se neděje
74
75 # vracím plt místo figury, protože nechcem sa trapiť ivent lupem
76 # return plt insted of just fig to bypass event loop issues
77 return plt.show()
File plot.py changed (mode: 100644) (index 993a88f..4849f17)
12 12 # #
13 13 # optional dependences # optional dependences
14 14 # #
15 try:# gnuplot
16 from . import gp_plot
17 plot2D = gp_plot.gp_plot
18 except BaseException as e:
19 plot2D_error_str = "plot2D import error: " + repr(e)
20 plot2D = lambda *args, **kwargs:print(plot2D_error_str)
15 #try:# gnuplot
16 # from . import gp_plot
17 # plot2D = gp_plot.gp_plot
18 #except BaseException as e:
19 # plot2D_error_str = "plot2D import error: " + repr(e)
20 # plot2D = lambda *args, **kwargs:print(plot2D_error_str)
21 21
22 22 try:# plot.ly try:# plot.ly
23 23 from . import plotly_plot from . import plotly_plot
 
... ... except BaseException as e:
28 28
29 29 try:# matplotlib try:# matplotlib
30 30 from . import mplot from . import mplot
31 plot2D = mplot.plot2D
31 32 plot3D = mplot.plot3D plot3D = mplot.plot3D
32 33 except BaseException as e: except BaseException as e:
33 plot3D_error_str = "plot3D import error: " + repr(e)
34 plot3D = lambda *args, **kwargs:print(plot3D_error_str)
34 plot_error_str = "plot import error: " + repr(e)
35 plot2D = lambda *args, **kwargs:print(plot_error_str)
36 plot3D = lambda *args, **kwargs:print(plot_error_str)
35 37
36 38 try: # pyqtgraph try: # pyqtgraph
37 39 from . import qt_plot from . import qt_plot
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