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

Annotation of /trunk/pyvisi/examples/offsetPlot.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: 2529 byte(s)
more copyright statements added
1 cochrane 337 # $Id: offsetPlot.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 gross 637
8     @var __author__: name of author
9     @var __license__: licence agreement
10     @var __copyright__: copyrights
11     @var __url__: url entry point on documentation
12     @var __version__: version
13     @var __date__: date of the version
14 cochrane 337 """
15    
16 gross 637 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
17     http://www.access.edu.au
18     Primary Business: Queensland, Australia"""
19     __license__="""Licensed under the Open Software License version 3.0
20     http://www.opensource.org/licenses/osl-3.0.php"""
21     __author__="Paul Cochrane"
22     __url__="http://www.iservo.edu.au/esys"
23     __version__="$Revision$"
24     __date__="$Date$"
25    
26    
27 cochrane 337 import sys
28     numArgs = len(sys.argv)
29     if numArgs == 1:
30     ren_mod = "vtk"
31     else:
32     ren_mod = sys.argv[1]
33    
34     # set up some data to plot
35     from Numeric import *
36    
37     # read in the data (being fortunate we know how much data there is)
38     fp = open('waves.dat')
39     t = zeros((100), typecode=Float)
40     x = zeros((13), typecode=Float)
41     data = zeros((100,13), typecode=Float)
42     for i in range(100):
43     for j in range(13):
44     line = fp.readline()
45     arr = line.split()
46     t[i] = float(arr[0])
47     x[j] = float(arr[1])
48     data[i,j] = float(arr[2])
49     fp.close()
50    
51     # example code for how a user would write a script in pyvisi
52 gross 605 from esys.pyvisi import * # base level visualisation stuff
53     #from esys.pyvisi.utils import * # pyvisi specific utils
54 cochrane 337 # import the objects to render the scene using the specific renderer
55     if ren_mod == "gnuplot":
56 gross 605 from esys.pyvisi.renderers.gnuplot import * # gnuplot
57 cochrane 337 elif ren_mod == "vtk":
58 gross 605 from esys.pyvisi.renderers.vtk import * # vtk
59 cochrane 337 else:
60     raise ValueError, "Unknown renderer module"
61    
62     # define the scene object
63     # a Scene is a container for all of the kinds of things you want to put
64     # into your plot for instance, images, meshes, arrow/vector/quiver plots,
65     # contour plots, spheres etc.
66     scene = Scene()
67    
68     # create an OffsetPlot object
69     plot = OffsetPlot(scene)
70    
71     # add some helpful info to the plot
72     plot.title = 'OffsetPlot example - waves.dat'
73     plot.xlabel = 't'
74     plot.ylabel = 'y'
75    
76     # assign some data to the plot
77     plot.setData(t, data)
78    
79     # render the scene to screen
80     scene.render(pause=True, interactive=True)
81    
82     # save the scene to file
83     scene.save(fname="offsetPlot.png", format=PngImage())
84    
85     # vim: expandtab shiftwidth=4:
86    

  ViewVC Help
Powered by ViewVC 1.1.26