/[escript]/trunk/pyvisi_old/examples/seismicOffsetPlot2.py
ViewVC logotype

Annotation of /trunk/pyvisi_old/examples/seismicOffsetPlot2.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations)
Mon Dec 12 01:57:07 2005 UTC (13 years, 10 months ago) by cochrane
Original Path: trunk/pyvisi/examples/seismicOffsetPlot2.py
File MIME type: text/x-python
File size: 1927 byte(s)
Initial merge of pyvisi into esys repository.
1 cochrane 337 # $Id: seismicOffsetPlot2.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
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 pyvisi import * # base level visualisation stuff
35     #from pyvisi.utils import * # pyvisi specific utils
36     # import the objects to render the scene using the specific renderer
37     if ren_mod == "gnuplot":
38     from pyvisi.renderers.gnuplot import * # gnuplot
39     elif ren_mod == "vtk":
40     from pyvisi.renderers.vtk import * # vtk
41     else:
42     raise ValueError, "Unknown renderer module"
43    
44     # define the scene object
45     # a Scene is a container for all of the kinds of things you want to put
46     # into your plot for instance, images, meshes, arrow/vector/quiver plots,
47     # contour plots, spheres etc.
48     scene = Scene()
49    
50     # create an OffsetPlot object
51     plot = OffsetPlot(scene)
52    
53     # add some helpful info to the plot
54     plot.title = 'Sample seismic data - waves1d.dat'
55     plot.xlabel = 't'
56     plot.ylabel = 'y'
57    
58     # assign some data to the plot
59     plot.setData(t, data)
60    
61     # render the scene to screen
62     scene.render(pause=True, interactive=True)
63    
64     # save the scene to file
65     scene.save(fname="seismicOffsetPlot2.png", format=PngImage())
66    
67     # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26