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
| import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
from numpy.random import uniform, seed
from matplotlib.mlab import griddata
import time
seed(0)
npts = 48
ngridx = 100
ngridy = 200
x = [57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997, 57.779600000000002, 60.5642, 63.348700000000001, 66.133300000000006, 68.917900000000003, 71.702399999999997] #plage des donnees
y = [28.1937, 28.1937, 28.1937, 28.1937, 28.1937, 28.1937, 39.331899999999997, 39.331899999999997, 39.331899999999997, 39.331899999999997, 39.331899999999997, 39.331899999999997, 50.470100000000002, 50.470100000000002, 50.470100000000002, 50.470100000000002, 50.470100000000002, 50.470100000000002, 61.608400000000003, 61.608400000000003, 61.608400000000003, 61.608400000000003, 61.608400000000003, 61.608400000000003, 72.746600000000001, 72.746600000000001, 72.746600000000001, 72.746600000000001, 72.746600000000001, 72.746600000000001, 83.884900000000002, 83.884900000000002, 83.884900000000002, 83.884900000000002, 83.884900000000002, 83.884900000000002, 95.023099999999999, 95.023099999999999, 95.023099999999999, 95.023099999999999, 95.023099999999999, 95.023099999999999, 106.161, 106.161, 106.161, 106.161, 106.161, 106.161] #plage des
z = [-1.12331, -1.1246499999999999, -1.1284099999999999, -1.11934, -1.1233299999999999, -1.1230100000000001, -1.00088, -1.0019, -0.99307999999999996, -0.99635399999999996, -0.99544500000000002, -0.99269300000000005, -0.89034899999999995, -0.89257200000000003, -0.89359900000000003, -0.88752500000000001, -0.88253499999999996, -0.87981200000000004, -0.780914, -0.77429400000000004, -0.77657100000000001, -0.77299600000000002, -0.77231000000000005, -0.76889600000000002, -0.66271800000000003, -0.65923500000000002, -0.65848200000000001, -0.65167600000000003, -0.64957100000000001, -0.65037, -0.57327499999999998, -0.57718599999999998, -0.56849400000000005, -0.56994100000000003, -0.56124700000000005, -0.56069000000000002, -0.46647899999999998, -0.46522799999999997, -0.461287, -0.45732400000000001, -0.45951900000000001, -0.45488099999999998, -0.37942199999999998, -0.38104500000000002, -0.378776, -0.38169399999999998, -0.37445899999999999, -0.37913400000000003]
# griddata and contour.
start = time.clock()
plt.subplot(211)
xi = np.linspace(57,72,ngridx)
yi = np.linspace(28,107,ngridy)
zi = griddata(x,y,z,xi,yi,interp='linear')
plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
plt.colorbar() # draw colorbar
plt.plot(x, y, 'ko', ms=3)
plt.xlim(57,72)
plt.ylim(28,107)
plt.title('griddata and contour (%d points, %d grid points)' % (npts, ngridx*ngridy))
print 'griddata and contour seconds:', time.clock() - start |
Partager