source: trunk/examples/graph/graph.py @ 115

Last change on this file since 115 was 115, checked in by mmc, 19 years ago

Updated all copyright notices.

File size: 1.0 KB
Line 
1# ----------------------------------------------------------------------
2#  GRAPH
3#
4#  This simple example shows how you can use the Rappture toolkit
5#  to handle I/O for a simple simulator--in this case, one that
6#  evaluates an x/y graph
7#
8# ======================================================================
9#  AUTHOR:  Michael McLennan, Purdue University
10#  Copyright (c) 2004-2005  Purdue Research Foundation
11#
12#  See the file "license.terms" for information on usage and
13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14# ======================================================================
15
16import Rappture
17import sys
18from math import *
19
20io = Rappture.library(sys.argv[1])
21
22xmin = float(io.get('input.number(min).current'))
23xmax = float(io.get('input.number(max).current'))
24formula = io.get('input.string(formula).current')
25print 'formula = %s' % formula
26npts = 100
27
28for i in range(npts):
29    x = (xmax-xmin)/npts * i + xmin;
30    y = eval(formula)
31    io.put('output.curve.component.xy', '%g %g\n' % (x,y), append=1)
32
33Rappture.result(io)
Note: See TracBrowser for help on using the repository browser.