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

Annotation of /trunk/pyvisi/examples/seismicOffsetPlot1.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations)
Mon Dec 12 01:57:07 2005 UTC (14 years, 6 months ago) by cochrane
File MIME type: text/x-python
File size: 2039 byte(s)
Initial merge of pyvisi into esys repository.
1 cochrane 337 # $Id: seismicOffsetPlot1.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
6     """
7    
8     import sys
9     numArgs = len(sys.argv)
10     if numArgs == 1:
11     ren_mod = "vtk"
12     else:
13     ren_mod = sys.argv[1]
14    
15     # set up some data to plot
16     from Numeric import *
17    
18     # read in the data (being fortunate we know how much data there is)
19     fp = open('waves.dat')
20     t = zeros((100), typecode=Float)
21     x = zeros((13), typecode=Float)
22     data = zeros((100,13), typecode=Float)
23     for i in range(100):
24     for j in range(13):
25     line = fp.readline()
26     arr = line.split()
27     t[i] = float(arr[0])
28     x[j] = float(arr[1])
29     data[i,j] = float(arr[2])
30     fp.close()
31    
32     # example code for how a user would write a script in pyvisi
33     from pyvisi import * # base level visualisation stuff
34     #from pyvisi.utils import * # pyvisi specific utils
35     # import the objects to render the scene using the specific renderer
36     if ren_mod == "gnuplot":
37     from pyvisi.renderers.gnuplot import * # gnuplot
38     elif ren_mod == "vtk":
39     from 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 a LinePlot object
50     plot = LinePlot(scene)
51    
52     # add some helpful info to the plot
53     plot.title = 'Sample seismic data'
54     plot.xlabel = 't'
55     plot.ylabel = 'y'
56    
57     plot.linestyle = 'lines'
58    
59     # assign some data to the plot
60     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
61     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
62     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
63    
64     # render the scene to screen
65     scene.render(pause=True, interactive=True)
66    
67     # save the scene to file
68     scene.save(fname="seismicOffsetPlot1.png", format=PngImage())
69    
70     # vim: expandtab shiftwidth=4:
71    

  ViewVC Help
Powered by ViewVC 1.1.26