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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (hide annotations)
Mon Mar 20 07:16:27 2006 UTC (14 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 2752 byte(s)
pyvisi with vtk runs noe on the altix
1 cochrane 337 # $Id: seismicOffsetPlotExample.py,v 1.3 2005/11/08 05:11:40 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     # set up some data to plot
9     from Numeric import *
10    
11     # read in the data (being fortunate we know how much data there is)
12     fp = open('waves.dat')
13     t = zeros((100), typecode=Float)
14     x = zeros((13), typecode=Float)
15     data = zeros((100,13), typecode=Float)
16     for i in range(100):
17     for j in range(13):
18     line = fp.readline()
19     arr = line.split()
20     t[i] = float(arr[0])
21     x[j] = float(arr[1])
22     data[i,j] = float(arr[2])
23     fp.close()
24    
25     # example code for how a user would write a script in pyvisi
26 gross 605 from esys.pyvisi import * # base level visualisation stuff
27     #from esys.pyvisi.utils import * # pyvisi specific utils
28 cochrane 337 # import the objects to render the scene using the specific renderer
29 gross 605 #from esys.pyvisi.renderers.gnuplot import * # gnuplot
30     from esys.pyvisi.renderers.vtk import * # vtk
31 cochrane 337
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 a LinePlot object
39     plot = LinePlot(scene)
40    
41     # add some helpful info to the plot
42     plot.title = 'Sample seismic data'
43     plot.xlabel = 't'
44     plot.ylabel = 'y'
45    
46     plot.linestyle = 'lines'
47    
48     # assign some data to the plot
49     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
50     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
51     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
52    
53     # render the scene to screen
54     scene.render(pause=True, interactive=True)
55    
56     # save the scene to file
57     # save as png
58     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
59     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
60     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
61     # have to do this now because we've already
62     # render()ed the scene. This requirement
63     # will be removed in the future.
64     scene.save(fname="seismicOffsetPlotExample.png", format=PngImage())
65    
66     # save as postscript
67     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
68     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
69     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
70     # have to do this now because we've already
71     # save()d the scene. This requirement will
72     # be removed in the future.
73     scene.save(fname="seismicOffsetPlotExample.ps", format=PsImage())
74    
75     # vim: expandtab shiftwidth=4:
76    

  ViewVC Help
Powered by ViewVC 1.1.26