Debian Codegraph @

07p/demos/python/n-body/to_matlab.xauto

raw
1 # This is an example of an 'expert' AUTO CLUI script.
2 # This script takes a set of AUTO data files and produces
3 # files which can be read into Matlab .
4 # For example, the command:
5 #
6 # autox to_matlab.xauto foo bar
7 #
8 # will take the bifurcation diagram file b.foo and produce
9 # the file bar_bifur, and it will take the solution
10 # file s.foo and, for each solution in the file,
11 # produce a file bar_solution_??, where ?? is
12 # the solution label number.
13
14 # In expert scripts we need to explicitly import the
15 # AUTOclui library
16 from AUTOclui import *
17
18 # We also import a few general Python utility
19 # libraries.
20 import sys
21
22 # This function actually performs the decoding of the
23 # AUTO data files.
24 def to_matlab(filename,prefix):
25 # We parse the bifurcation diagram file and solution file.
26 data=loadbd(filename)
27 # The Python object has a method for taking the
28 # data and writing it out as columns, so
29 # we use that here.
30 data.writeRawFilename(prefix+'_bifur')
31
32 # Next, we write out the solutions by first using data() to get the
33 # solution list.
34 data=data()
35 # The we iterate over each of the solutions in the file
36 # using the loop.
37 for solution in data:
38 # Just like above, the Python object for solutions
39 # has a method for taking the
40 # data and writing it out as columns, so
41 # we use that here.
42 solution.writeRawFilename(prefix+'_solution_'+`solution["Label"]`)
43
44
45 # This is the Python syntax for making a script runnable
46 if __name__ == '__main__':
47 # The first argument is the name of the file that
48 # you wish to parse.
49 filename = sys.argv[1]
50 # The second argument is the prefix to use for the
51 # output files.
52 prefix = sys.argv[2]
53 to_matlab(filename,prefix)
54
55
56
57
58
59
60