/[escript]/trunk/pyvisi/examples/seismicOffsetPlot3.py
ViewVC logotype

Contents of /trunk/pyvisi/examples/seismicOffsetPlot3.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (show annotations)
Mon Mar 20 07:16:27 2006 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 1947 byte(s)
pyvisi with vtk runs noe on the altix
1 # $Id: seismicOffsetPlot3.py,v 1.3 2005/11/08 08:23:45 paultcochrane Exp $
2 """
3 Example of plotting multiple curves offset from each other with pyvisi
4
5 This is an example with simulated seismic data, and is a larger dataset
6 than seismicOffsetPlotExample.py and makes use of the x data.
7 """
8
9 import sys
10 numArgs = len(sys.argv)
11 if numArgs == 1:
12 ren_mod = "vtk"
13 else:
14 ren_mod = sys.argv[1]
15
16 # set up some data to plot
17 from Numeric import *
18
19 # read in the data (being fortunate we know how much data there is)
20 fp = open('waves1d.dat')
21 t = zeros((1000), typecode=Float)
22 x = zeros((102), typecode=Float)
23 data = zeros((1000,102), typecode=Float)
24 for i in range(1000):
25 for j in range(102):
26 line = fp.readline()
27 arr = line.split()
28 t[i] = float(arr[0])
29 x[j] = float(arr[1])
30 data[i,j] = float(arr[2])
31 fp.close()
32
33 # example code for how a user would write a script in pyvisi
34 from esys.pyvisi import * # base level visualisation stuff
35 # import the objects to render the scene using the specific renderer
36 if ren_mod == "gnuplot":
37 from esys.pyvisi.renderers.gnuplot import * # gnuplot
38 elif ren_mod == "vtk":
39 from esys.pyvisi.renderers.vtk import * # vtk
40 else:
41 raise ValueError, "Unknown renderer module"
42
43 # define the scene object
44 # a Scene is a container for all of the kinds of things you want to put
45 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
46 # contour plots, spheres etc.
47 scene = Scene()
48
49 # create an OffsetPlot object
50 plot = OffsetPlot(scene)
51
52 # add some helpful info to the plot
53 plot.title = 'Sample seismic data - waves1d.dat, using x and t data'
54 plot.xlabel = 't'
55 plot.ylabel = 'x'
56
57 # assign some data to the plot
58 plot.setData(t, x, data)
59
60 # render the scene to screen
61 scene.render(pause=True, interactive=True)
62
63 # save the scene to file
64 scene.save(fname="seismicOffsetPlotExample3.png", format=PngImage())
65
66 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26