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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 637 - (hide annotations)
Thu Mar 23 10:55:31 2006 UTC (14 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 3360 byte(s)
more copyright statements added
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 gross 637
7     @var __author__: name of author
8     @var __license__: licence agreement
9     @var __copyright__: copyrights
10     @var __url__: url entry point on documentation
11     @var __version__: version
12     @var __date__: date of the version
13 cochrane 337 """
14    
15 gross 637 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
16     http://www.access.edu.au
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __author__="Paul Cochrane"
21     __url__="http://www.iservo.edu.au/esys"
22     __version__="$Revision$"
23     __date__="$Date$"
24    
25    
26 cochrane 337 # set up some data to plot
27     from Numeric import *
28    
29     # read in the data (being fortunate we know how much data there is)
30     fp = open('waves.dat')
31     t = zeros((100), typecode=Float)
32     x = zeros((13), typecode=Float)
33     data = zeros((100,13), typecode=Float)
34     for i in range(100):
35     for j in range(13):
36     line = fp.readline()
37     arr = line.split()
38     t[i] = float(arr[0])
39     x[j] = float(arr[1])
40     data[i,j] = float(arr[2])
41     fp.close()
42    
43     # example code for how a user would write a script in pyvisi
44 gross 605 from esys.pyvisi import * # base level visualisation stuff
45     #from esys.pyvisi.utils import * # pyvisi specific utils
46 cochrane 337 # import the objects to render the scene using the specific renderer
47 gross 605 #from esys.pyvisi.renderers.gnuplot import * # gnuplot
48     from esys.pyvisi.renderers.vtk import * # vtk
49 cochrane 337
50     # define the scene object
51     # a Scene is a container for all of the kinds of things you want to put
52     # into your plot for instance, images, meshes, arrow/vector/quiver plots,
53     # contour plots, spheres etc.
54     scene = Scene()
55    
56     # create a LinePlot object
57     plot = LinePlot(scene)
58    
59     # add some helpful info to the plot
60     plot.title = 'Sample seismic data'
61     plot.xlabel = 't'
62     plot.ylabel = 'y'
63    
64     plot.linestyle = 'lines'
65    
66     # assign some data to the plot
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    
71     # render the scene to screen
72     scene.render(pause=True, interactive=True)
73    
74     # save the scene to file
75     # save as png
76     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
77     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
78     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
79     # have to do this now because we've already
80     # render()ed the scene. This requirement
81     # will be removed in the future.
82     scene.save(fname="seismicOffsetPlotExample.png", format=PngImage())
83    
84     # save as postscript
85     plot.setData(t, data[:,0], data[:,1], data[:,2], data[:,3],
86     data[:,4], data[:,5], data[:,6], data[:,7], data[:,8],
87     data[:,9], data[:,10], data[:,11], data[:,12], offset=True)
88     # have to do this now because we've already
89     # save()d the scene. This requirement will
90     # be removed in the future.
91     scene.save(fname="seismicOffsetPlotExample.ps", format=PsImage())
92    
93     # vim: expandtab shiftwidth=4:
94    

  ViewVC Help
Powered by ViewVC 1.1.26