source: branches/nanovis2/examples/zoo/curve/curve.tcl @ 3305

Last change on this file since 3305 was 3305, checked in by ldelgass, 12 years ago

sync with trunk

File size: 3.4 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Rappture <curve> elements
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  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# ======================================================================
10package require Rappture
11
12# open the XML file containing the run parameters
13set driver [Rappture::library [lindex $argv 0]]
14
15set npts [$driver get input.(points).current]
16set min 0.01
17set max 10.0
18set dx [expr {($max-$min)/double($npts)}]
19
20# generate a single curve
21$driver put output.curve(single).about.label "Single curve"
22$driver put output.curve(single).about.description \
23    "This is an example of a single curve."
24$driver put output.curve(single).xaxis.label "Time"
25$driver put output.curve(single).xaxis.description "Time during the experiment."
26$driver put output.curve(single).xaxis.units "s"
27$driver put output.curve(single).yaxis.label "Voltage v(11)"
28$driver put output.curve(single).yaxis.description "Output from the amplifier."
29$driver put output.curve(single).yaxis.units "V"
30
31for {set x $min} {$x < $max} {set x [expr {$x+$dx}]} {
32    set y [expr {cos($x)/(1+$x)}]
33    $driver put -append yes output.curve(single).component.xy "$x $y\n"
34}
35
36# generate multiple curves on the same plot
37foreach factor {1 2} {
38    $driver put output.curve(multi$factor).about.group "Multiple curve"
39    $driver put output.curve(multi$factor).about.label "Factor a=$factor"
40    $driver put output.curve(multi$factor).about.description \
41        "This is an example of a multiple curves on the same plot."
42    $driver put output.curve(multi$factor).xaxis.label "Frequency"
43    $driver put output.curve(multi$factor).xaxis.description \
44        "Frequency of the input source."
45    $driver put output.curve(multi$factor).xaxis.units "Hz"
46    $driver put output.curve(multi$factor).xaxis.scale "log"
47    $driver put output.curve(multi$factor).yaxis.label "Current"
48    $driver put output.curve(multi$factor).yaxis.description \
49        "Current through the pull-down resistor."
50    $driver put output.curve(multi$factor).yaxis.units "uA"
51    $driver put output.curve(multi$factor).yaxis.log "log"
52
53    for {set x $min} {$x < $max} {set x [expr {$x+$dx}]} {
54        set y [expr {pow(2.0,$factor*$x)/$x}]
55        $driver put -append yes \
56            output.curve(multi$factor).component.xy "$x $y\n"
57    }
58}
59
60# generate a scatter curve
61$driver put output.curve(scatter).about.label "Scatter curve"
62$driver put output.curve(scatter).about.description \
63    "This is an example of a scatter curve."
64$driver put output.curve(scatter).about.type "scatter"
65$driver put output.curve(scatter).xaxis.label "Time"
66$driver put output.curve(scatter).xaxis.description "Time during the experiment."
67$driver put output.curve(scatter).xaxis.units "s"
68$driver put output.curve(scatter).yaxis.label "Voltage v(11)"
69$driver put output.curve(scatter).yaxis.description "Output from the amplifier."
70$driver put output.curve(scatter).yaxis.units "V"
71
72for {set x $min} {$x < $max} {set x [expr {$x+$dx}]} {
73    set y [expr {cos($x)/(1+$x)}]
74    $driver put -append yes output.curve(scatter).component.xy "$x $y\n"
75}
76
77# save the updated XML describing the run...
78Rappture::result $driver
79exit 0
Note: See TracBrowser for help on using the repository browser.