-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.py
36 lines (33 loc) · 1008 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ordinarykriging as ok
import matplotlib.mlab as mpl
import pylab as plb
import time
def plotit(x, y, z, title):
plb.figure()
try:
X = list()
Y = list()
[X.append(i) for i in x if i not in X]
[Y.append(i) for i in y if i not in Y]
Z = plb.reshape(z, (len(Y), len(X)))
plb.contourf(X, Y, Z, 10)
except:
plb.scatter(x, y, c=z)
plb.title(title)
plb.colorbar()
plb.show()
def run():
t1=time.time()
a=mpl.csv2rec('datas.csv')
g=ok.Grid(a.x, a.y, a.v)
##plotit(g.grid.x, g.grid.y, g.grid.v, "Initial grid")
model=g.fitSermivariogramModel('Exponential', nlag=20)
##model.plot()
x,y=g.regularBasicGrid(nx=40, ny=40)
pg=g.predictedGrid(x, y, model)
##plotit(pg.grid.x, pg.grid.y, pg.grid.v, "Predicted grid")
##plotit(pg.grid.x, pg.grid.y, pg.grid.e, "Predicted Error grid")
t2=time.time()
print("Operation performed in %.2f seconds"%(t2-t1))
if __name__ == '__main__':
run()