1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import sys
24
25 import help
26
27
30
31 self.__relax_help__ = \
32 """Class for interfacing with the program Dasha."""
33
34
35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
36
37
38 self.__relax__ = relax
39
40
41 - def create(self, run=None, algor='LM', dir=None, force=0):
42 """Function for creating the Dasha script.
43
44 Keyword Arguments
45 ~~~~~~~~~~~~~~~~~
46
47 run: The name of the run.
48
49 algor: The minimisation algorithm.
50
51 dir: The directory to place the files. The default is the value of 'run'.
52
53 force: A flag which if set to 1 will cause the results file to be overwritten if it already
54 exists.
55
56
57 Description
58 ~~~~~~~~~~~
59
60 The script file created is called 'dir/dasha_script'.
61
62
63 Optimisation algorithms
64 ~~~~~~~~~~~~~~~~~~~~~~~
65
66 The two minimisation algorithms within Dasha are accessible through the algor argument which
67 can be set to:
68
69 'LM' - The Levenberg-Marquardt algorithm.
70 'NR' - Newton-Raphson algorithm.
71
72 For Levenberg-Marquardt minisation, the function 'lmin' will be called, while for Newton
73 -Raphson, the function 'min' will be executed.
74 """
75
76
77 if self.__relax__.interpreter.intro:
78 text = sys.ps3 + "dasha.create("
79 text = text + "run=" + `run`
80 text = text + ", algor=" + `algor`
81 text = text + ", dir=" + `dir`
82 text = text + ", force=" + `force` + ")"
83 print text
84
85
86 if type(run) != str:
87 raise RelaxStrError, ('run', run)
88
89
90 if type(algor) != str:
91 raise RelaxStrError, ('optimisation algorithm', algor)
92
93
94 if dir != None:
95 if type(dir) != str:
96 raise RelaxNoneStrError, ('directory name', dir)
97
98
99 if type(force) != int or (force != 0 and force != 1):
100 raise RelaxBinError, ('force flag', force)
101
102
103 self.__relax__.generic.dasha.create(run=run, algor=algor, dir=dir, force=force)
104
105
106 - def execute(self, run=None, dir=None, force=0):
107 """Function for executing Dasha.
108
109 Keyword Arguments
110 ~~~~~~~~~~~~~~~~~
111
112 run: The name of the run.
113
114 dir: The directory to place the files. The default is the value of 'run'.
115
116 force: A flag which if set to 1 will cause the results file to be overwritten if it already
117 exists.
118
119
120 Execution
121 ~~~~~~~~~
122
123 Dasha will be executed as
124
125 $ dasha < dasha_script | tee dasha_results
126
127
128
129 """
130
131
132 if self.__relax__.interpreter.intro:
133 text = sys.ps3 + "dasha.execute("
134 text = text + "run=" + `run`
135 text = text + ", dir=" + `dir`
136 text = text + ", force=" + `force` + ")"
137 print text
138
139
140 if type(run) != str:
141 raise RelaxStrError, ('run', run)
142
143
144 if dir != None:
145 if type(dir) != str:
146 raise RelaxNoneStrError, ('directory name', dir)
147
148
149 if type(force) != int or (force != 0 and force != 1):
150 raise RelaxBinError, ('force flag', force)
151
152
153 self.__relax__.generic.dasha.execute(run=run, dir=dir, force=force)
154
155
157 """Function for extracting data from the Dasha results file.
158
159 Keyword Arguments
160 ~~~~~~~~~~~~~~~~~
161
162 run: The name of the run.
163
164 dir: The directory where the file 'dasha_results' is found. The default is the value of 'run'.
165 """
166
167
168 if self.__relax__.interpreter.intro:
169 text = sys.ps3 + "dasha.extract("
170 text = text + "run=" + `run`
171 text = text + ", dir=" + `dir` + ")"
172 print text
173
174
175 if type(run) != str:
176 raise RelaxStrError, ('run', run)
177
178
179 if dir != None:
180 if type(dir) != str:
181 raise RelaxNoneStrError, ('directory name', dir)
182
183
184 self.__relax__.generic.dasha.extract(run=run, dir=dir)
185