Skip to content

Commit

Permalink
taylor_proc
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinoval committed Oct 20, 2019
1 parent 24a5f19 commit d4d2a6e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
Binary file added 1.vtk
Binary file not shown.
Binary file added c649-01.xls
Binary file not shown.
4 changes: 2 additions & 2 deletions save_from_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from odbcAccess import expODBC
import xlwt as xls

db = expODBC(r"d:\experiments\Áàçà äàííûõ\db-work2.accdb")
exp_code = 'c632-05'
db = expODBC(r"D:\work\NIIM\db-work2.accdb")
exp_code = 'c649-01'
xls_file_name = exp_code+'.xls'
experiment = db.getExperimentData(exp_code)
wb = xls.Workbook()
Expand Down
57 changes: 57 additions & 0 deletions stl_taylor_proc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import matplotlib.pylab as plt
import matplotlib.patches as mpatches
from itertools import cycle
import vtkplotter as vtk
from usefull_features import group_by
import numpy as np
import scipy.optimize as opt


p = vtk.Plotter(shape=(1, 2), bg='white', axes=1)
a = vtk.load('tayl.stl')
sc = [c[1] for c in a.getPoints()]
a.pointColors(sc)
b = a.ybounds()
i = a.isolines(200, b[0], b[1])
i2 = a.isolines(50, b[1]*0.7, b[1]).clean()
ii = i.clean()
ii2 = i2.clean()
pnts1 = np.array([tuple(p) for p in ii.getPoints()], dtype=[
('x', float), ('y', float), ('z', float)])
pnts2 = np.array([tuple(p) for p in ii2.getPoints()], dtype=[
('x', float), ('y', float), ('z', float)])
g1 = group_by(pnts1, by='y', crit=1e-3)
g2 = group_by(pnts2, by='y', crit=1e-3)
p.show(a, i, i2, at=0, N=2)
p.show(vtk.Points(ii.getPoints()), vtk.Points(i2.getPoints()),
vtk.Points(g1[10].tolist(), c='green'),
vtk.Points(g1[0].tolist(), c='red'), at=1, interactive=True)

N = 10
z = []
r = []
for g in g1+g2:
if len(g) < 10:
continue

def residuals(p):
rez = []
for point in g:
rez.append((point['x']-p[0])**2+(point['z']-p[1])**2-p[2]**2)
return rez
task = opt.least_squares(residuals, [0, 0, 1], bounds=[
[-np.inf, -np.inf, 0], [np.inf, np.inf, np.inf]])
print(task.x)
c = mpatches.Circle([0, 0], task.x[2], fill=False, color='k', lw=2)
plt.gca().add_artist(c)
plt.plot(g['x']-task.x[0], g['z']-task.x[1], '.')
z.append(g[0]['y'])
r.append(task.x[2])


plt.grid()
plt.gca().set_aspect('equal', 'box')
plt.figure()
plt.plot(z[:-1], r[:-1], 'o')
# plt.ylim(0, 12)
plt.show()
Binary file added tayl.stl
Binary file not shown.

0 comments on commit d4d2a6e

Please sign in to comment.