source: branches/uq/examples/graph/graph.py @ 4644

Last change on this file since 4644 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 1.2 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-2012  HUBzero Foundation, LLC
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
28io.put('output.curve(result).about.label','Formula: Y vs X',append=0)
29io.put('output.curve(result).yaxis.label','Y')
30io.put('output.curve(result).xaxis.label','X')
31
32for i in range(npts):
33    x = (xmax-xmin)/npts * i + xmin;
34    y = eval(formula)
35    io.put('output.curve(result).component.xy', '%g %g\n' % (x,y), append=1)
36
37Rappture.result(io)
Note: See TracBrowser for help on using the repository browser.