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

Contents of /trunk/pyvisi/examples/seismicOffsetPlotExample2.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: 2283 byte(s)
Initial merge of pyvisi into esys repository.
1 # $Id: seismicOffsetPlotExample2.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
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 #from pyvisi.utils import * # pyvisi specific utils
29 # import the objects to render the scene using the specific renderer
30 from pyvisi.renderers.gnuplot import * # gnuplot
31 #from pyvisi.renderers.vtk import * # vtk
32
33 # define the scene object
34 # a Scene is a container for all of the kinds of things you want to put
35 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
36 # contour plots, spheres etc.
37 scene = Scene()
38
39 # create an OffsetPlot object
40 plot = OffsetPlot(scene)
41
42 # add some helpful info to the plot
43 plot.title = 'Sample seismic data - waves1d.dat'
44 plot.xlabel = 't'
45 plot.ylabel = 'y'
46
47 # assign some data to the plot
48 plot.setData(t, data)
49
50 # render the scene to screen
51 scene.render(pause=True, interactive=True)
52
53 # save the scene to file
54 # save as png
55 plot.setData(t, data)
56 # have to do this now because we've already
57 # render()ed the scene. This requirement
58 # will be removed in the future.
59 scene.save(fname="seismicOffsetPlotExample2.png", format=PngImage())
60
61 # save as postscript
62 plot.setData(t, data)
63 # have to do this now because we've already
64 # save()d the scene. This requirement will
65 # be removed in the future.
66 scene.save(fname="seismicOffsetPlotExample2.ps", format=PsImage())
67
68 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26