1 | import project |
---|

2 | |
---|

3 | from pylab import * |
---|

4 | |
---|

5 | #import pylab as p1 |
---|

6 | #import mpl3d.mplot3d as p3 |
---|

7 | |
---|

8 | ion() |
---|

9 | |
---|

10 | # load data |
---|

11 | def get_data_from_file(filename): |
---|

12 | |
---|

13 | fid = open(filename) |
---|

14 | lines = fid.readlines() |
---|

15 | fid.close() |
---|

16 | x = zeros((len(lines),1), Float) |
---|

17 | y = zeros((len(lines),1), Float) |
---|

18 | z = zeros((len(lines),1), Float) |
---|

19 | i = 0 |
---|

20 | for line in lines[1:]: |
---|

21 | fields = line.split(',') |
---|

22 | x[i] = float(fields[0]) |
---|

23 | y[i] = float(fields[1]) |
---|

24 | z[i] = float(fields[2]) |
---|

25 | i = i + 1 |
---|

26 | |
---|

27 | return x, y, z |
---|

28 | |
---|

29 | x, y, z = get_data_from_file(project.offshore_dem_name_aho11+'.xya') |
---|

30 | # interpolate x,y to X,Y grid? |
---|

31 | |
---|

32 | plot(x,y,'.') |
---|

33 | xlabel('easting') |
---|

34 | ylabel('northing') |
---|

35 | axis([min(x),max(x),min(y),min(z)]) |
---|

36 | import sys; sys.exit() |
---|

37 | |
---|

38 | fig = p1.figure(1) |
---|

39 | ax = p3.Axes3D(fig) |
---|

40 | #ax.plot_surface(x,y,z) |
---|

41 | #ax.plot_wireframe(x,y,z) |
---|

42 | #ax.plot3D(ravel(x,y,z)) |
---|

43 | ax.set_xlabel('easting') |
---|

44 | ax.set_ylabel('northing') |
---|

45 | ax.set_zlabel('elevation') |
---|

46 | fig.add_axes(ax) |
---|

47 | p1.show() |
---|

48 | surfacefig = 'solution_surface' |
---|

49 | p1.savefig(surfacefig) |
---|

50 | p1.close() |
---|

51 | |
---|

52 | # example 1 |
---|

53 | X = rand(20,20) |
---|

54 | im = imshow(X) |
---|

55 | |
---|

56 | # example 2 |
---|

57 | delta = 0.025 |
---|

58 | x = y = arange(-3.0,3,delta) |
---|

59 | X, Y = meshgrid(x,y) |
---|

60 | Z1 = bivariate_normal(X,Y,1.0,1.0,0.0,0.0) |
---|

61 | Z2 = bivariate_normal(X,Y,1.5,0.5,1.0,1.0) |
---|

62 | im = imshow(Z2-Z1,interpolation='bilinear') |
---|

63 | axis('off') |
---|