source: trunk/examples/zoo/number/number.py

Last change on this file was 5681, checked in by ldelgass, 9 years ago

Merge new Python examples from 1.3 branch (uq sync)

File size: 1.6 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Rappture <number> elements
3# ======================================================================
4#  AUTHOR:  Martin Hunt, Purdue University
5#  Copyright (c) 2015  HUBzero Foundation, LLC
6#
7#  See the file "license.terms" for information on usage and
8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9# ======================================================================
10
11import Rappture
12import sys
13
14# uncomment these for debugging
15# sys.stderr = open('tool.err', 'w')
16# sys.stdout = open('tool.out', 'w')
17
18rx = Rappture.PyXml(sys.argv[1])
19
20# The example this is based on did a copy of the inputs
21# to outputs, like below.  This is very efficient, but
22# would not be a normal thing to do.
23# rx.copy('output.number(outt)', 'input.(temperature)')
24# rx.copy('output.number(outv)', 'input.(vsweep)')
25
26temp = rx['input.(temperature).current'].value
27
28# If we need a unitless float, then this is necessary.
29# But in this example, we do not because Rappture accepts
30# numbers with units for the value.
31# temp = float(Rappture.Units.convert(temp, to='K', units='off'))
32
33vsweep = rx['input.(vsweep).current'].value
34# vsweep = float(Rappture.Units.convert(vsweep, to='V', units='off'))
35
36rx['output.number(temperature).about.label'] = 'Ambient temperature'
37rx['output.number(temperature).units'] = 'K'
38rx['output.number(temperature).current'] = temp
39
40rx['output.number(vsweep).about.label'] = 'Voltage Sweep'
41rx['output.number(vsweep).units'] = 'V'
42rx['output.number(vsweep).current'] = vsweep
43
44rx.close()
Note: See TracBrowser for help on using the repository browser.