source: branches/1.3/examples/zoo/curve/curve.tcl @ 3786

Last change on this file since 3786 was 3786, checked in by gah, 8 years ago

fix multiple barchart results, fix PDB reader, dynamically create tabs for vtkviewer

File size: 5.8 KB
1# ----------------------------------------------------------------------
2#  EXAMPLE: Rappture <curve> elements
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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
12# open the XML file containing the run parameters
13set driver [Rappture::library [lindex $argv 0]]
15set npts [$driver get input.(points).current]
16set min 0.01
17set max 10.0
18set dx [expr {($max-$min)/double($npts)}]
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"
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"
36# generate multiple curves on the same plot
37foreach factor {1 2} {
38    $driver put output.curve(multi$factor) "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"
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    }
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"
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"
77# generate a bar curve
78$driver put output.curve(bars).about.label "Bar chart"
79$driver put output.curve(bars).about.description \
80    "This is an example of a scatter curve."
81$driver put output.curve(bars).about.type "bar"
82$driver put output.curve(bars).xaxis.label "Time"
83$driver put output.curve(bars).xaxis.description "Time during the experiment."
84$driver put output.curve(bars).xaxis.units "s"
85$driver put output.curve(bars).yaxis.label "Voltage v(11)"
86$driver put output.curve(bars).yaxis.description "Output from the amplifier."
87$driver put output.curve(bars).yaxis.units "V"
89for {set x 0} {$x < $npts} {incr x} {
90    set y [expr {sin($x)/(1+$x)}]
91    $driver put -append yes output.curve(bars).component.xy "$x $y\n"
94# generate mixed curves on the same plot
95set deg2rad 0.017453292519943295
97$driver put output.curve(line) "Mixed element types"
98$driver put output.curve(line).about.label "Sine"
99$driver put output.curve(line).about.description \
100    "This is an example of a mixed curves on the same plot."
101$driver put output.curve(line).xaxis.label "Degrees"
102#$driver put output.curve(line).yaxis.label "Sine"
103$driver put output.curve(line).about.type "line"
104for {set x 0} {$x <= 360} {incr x 30} {
105    set y [expr {sin($x*$deg2rad)}]
106    $driver put -append yes output.curve(line).component.xy "$x $y\n"
109$driver put output.curve(bar) "Mixed element types"
110$driver put output.curve(bar).about.label "Cosine"
111$driver put output.curve(bar).about.description \
112    "This is an example of a mixed curves on the same plot."
113$driver put output.curve(bar).xaxis.label "Degrees"
114#$driver put output.curve(bar).yaxis.label "Cosine"
115$driver put output.curve(bar).about.type "bar"
116$driver put output.curve(bar) "-barwidth 24.0"
118for {set x 0} {$x <= 360} {incr x 30} {
119    set y [expr {cos($x*$deg2rad)}]
120    $driver put -append yes output.curve(bar).component.xy "$x $y\n"
123$driver put output.curve(point) "Mixed element types"
124$driver put output.curve(point).about.label "Random"
125$driver put output.curve(point).about.description \
126    "This is an example of a mixed curves on the same plot."
127$driver put output.curve(point).xaxis.label "Degrees"
128#$driver put output.curve(point).yaxis.label "Random"
129$driver put output.curve(point).about.type "scatter"
130for {set x 0} {$x <= 360} {incr x 10} {
131    set y [expr {(rand() * 2.0) - 1}]
132    $driver put -append yes output.curve(point).component.xy "$x $y\n"
135# save the updated XML describing the run...
136Rappture::result $driver
137exit 0
Note: See TracBrowser for help on using the repository browser.