source: trunk/examples/objects/app-fermi/python/ex3/fermi_io.py @ 1656

Last change on this file since 1656 was 1656, checked in by dkearney, 14 years ago

removing references to rappture tables, rappture will automagically decide
where to place new table columns, its one less thing for the user to fuss with.
users will reference the connect a TableColumn? variable with the correct name
and populate the TableColumn? in their science code. adding examples for matlab, octave, fixes for other languages.

File size: 2.7 KB
Line 
1def fermi_io():
2
3    # assume global interface variable.
4    # newly created objects are stored in the
5    # global interface variable. if there is more
6    # than one global interface variable, the
7    # interface that should be used is specified
8    # using the Rp_???InitX version of the funtion
9    # where ??? represents the type of object the
10    # user is trying to create.
11
12    # describe the inputs
13    # declare a number named "temperature",
14    # with units of Kelvin, default value 300,
15    #
16    # the next number is named "Ef", has units of
17    # electron Volts, default value of -5.5
18    #
19    # Rappture::Number is assumed to be an input
20
21    Rappture.Number(name="temperature",units="K",default=300)
22    Rappture.Number(name="Ef",units="eV",default=-5.5)
23
24    # describe the outputs
25    # two new columns are added to the default table
26    # the first column is named "Fermi-Dirac Factor",
27    # a description is provided, and it has no units.
28    # the second column is named "Energy", a description
29    # is provided, and has units of electron Volts.
30    # Rappture::Table is assumed to be an output
31    x1 = Rappture.Table.column(name="Fermi-Dirac Factor",
32            desc="Plot of Fermi-Dirac Calculation")
33    y1 = Rappture.Table.column(name="Energy",
34            desc="Energy cooresponding to each fdf",
35            hints=["units=eV"])
36    x2 = results.column(name="Fermi-Dirac Factor * 2",
37            desc="Plot of Fermi-Dirac Calculation multiplied by 2")
38    y2 = results.column(name="Energy * 2",
39            desc="Energy cooresponding to each fdf multiplied by 2",
40            hints=["units=eV"])
41
42
43    # describe how the outputs shoud be displayed
44    # initialize a view named "fdfView", with a 1x1 layout.
45    # next, add a plot named "fdfPlot" to the view fdfView".
46    # populate the plot with data from the table
47    # "factorsTable". Plot the column named
48    # "Fermi-Dirac Factor" vs the column named "Energy".
49    # place the plot, named fdfPlot, at position 1x1 (by default)
50    # within the view's layout.
51    # Rappture.View is assumed to be an output
52    # v.plot(xdata, ydata, format, at, name)
53    v = Rappture.View(name="fdfView")
54    v.plot(x1, y1, "g:o", [1,1], "fdfPlot")
55
56    # two stacked plots in the same view
57    v2 = Rappture.View(name="fdfView2")
58    v2.plot(x1, y1, "g:o", [1,1], "fdfPlot2")
59    v2.plot(x2, y2, "b-o", [2,1], "fdfPlot3")
60
61    # two side by side plots in the same view
62    v3 = Rappture.View(name="fdfView3")
63    v3.plot(x1, y1, "g:o", [1,1], "fdfPlot4")
64    v3.plot(x2, y2, "b-o", [1,2], "fdfPlot5")
65
66    # grouped curves in one plot in a view
67    v4 = Rappture.View(name="fdfView1")
68    v4.plot(x1, y1, "g:o", [1,1], "fdfPlot6")
69    v4.plot(x2, y2, "b-o", [1,1], "fdfPlot7")
Note: See TracBrowser for help on using the repository browser.