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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations)
Mon Dec 12 01:57:07 2005 UTC (13 years, 9 months ago) by cochrane
File MIME type: text/x-python
File size: 2287 byte(s)
Initial merge of pyvisi into esys repository.
1 # $Id: seismicOffsetPlotExample3.py,v 1.2 2005/03/22 06:22:36 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 # set up some data to plot
10 from Numeric import *
11
12 # read in the data (being fortunate we know how much data there is)
13 fp = open('waves1d.dat')
14 t = zeros((1000), typecode=Float)
15 x = zeros((102), typecode=Float)
16 data = zeros((1000,102), typecode=Float)
17 for i in range(1000):
18 for j in range(102):
19 line = fp.readline()
20 arr = line.split()
21 t[i] = float(arr[0])
22 x[j] = float(arr[1])
23 data[i,j] = float(arr[2])
24 fp.close()
25
26 # example code for how a user would write a script in pyvisi
27 from pyvisi import * # base level visualisation stuff
28 # import the objects to render the scene using the specific renderer
29 from pyvisi.renderers.gnuplot import * # gnuplot
30 #from pyvisi.renderers.vtk import * # vtk
31
32 # define the scene object
33 # a Scene is a container for all of the kinds of things you want to put
34 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
35 # contour plots, spheres etc.
36 scene = Scene()
37
38 # create an OffsetPlot object
39 plot = OffsetPlot(scene)
40
41 # add some helpful info to the plot
42 plot.title = 'Sample seismic data - waves1d.dat, using x and t data'
43 plot.xlabel = 't'
44 plot.ylabel = 'x'
45
46 # assign some data to the plot
47 plot.setData(t, x, data)
48
49 # render the scene to screen
50 scene.render(pause=True, interactive=True)
51
52 # save the scene to file
53 # save as png
54 plot.setData(t, x, data)
55 # have to do this now because we've already
56 # render()ed the scene. This requirement
57 # will be removed in the future.
58 scene.save(fname="seismicOffsetPlotExample3.png", format=PngImage())
59
60 # save as postscript
61 plot.setData(t, x, data)
62 # have to do this now because we've already
63 # save()d the scene. This requirement will
64 # be removed in the future.
65 scene.save(fname="seismicOffsetPlotExample3.ps", format=PsImage())
66
67 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26