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 minimisation, 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, binary='dasha'):
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 binary: The name of the executable Dasha program file.
120
121
122 Execution
123 ~~~~~~~~~
124
125 Dasha will be executed as
126
127 $ dasha < dasha_script | tee dasha_results
128
129
130 If you would like to use a different Dasha executable file, change the keyword argument
131 'binary' to the appropriate file name. If the file is not located within the environment's
132 path, include the full path in front of the binary file name.
133 """
134
135
136 if self.__relax__.interpreter.intro:
137 text = sys.ps3 + "dasha.execute("
138 text = text + "run=" + `run`
139 text = text + ", dir=" + `dir`
140 text = text + ", force=" + `force`
141 text = text + ", binary=" + `binary` + ")"
142 print text
143
144
145 if type(run) != str:
146 raise RelaxStrError, ('run', run)
147
148
149 if dir != None:
150 if type(dir) != str:
151 raise RelaxNoneStrError, ('directory name', dir)
152
153
154 if type(force) != int or (force != 0 and force != 1):
155 raise RelaxBinError, ('force flag', force)
156
157
158 if type(binary) != str:
159 raise RelaxStrError, ('Dasha binary', binary)
160
161
162 self.__relax__.generic.dasha.execute(run=run, dir=dir, force=force, binary=binary)
163
164
166 """Function for extracting data from the Dasha results file.
167
168 Keyword Arguments
169 ~~~~~~~~~~~~~~~~~
170
171 run: The name of the run.
172
173 dir: The directory where the file 'dasha_results' is found. The default is the value of 'run'.
174 """
175
176
177 if self.__relax__.interpreter.intro:
178 text = sys.ps3 + "dasha.extract("
179 text = text + "run=" + `run`
180 text = text + ", dir=" + `dir` + ")"
181 print text
182
183
184 if type(run) != str:
185 raise RelaxStrError, ('run', run)
186
187
188 if dir != None:
189 if type(dir) != str:
190 raise RelaxNoneStrError, ('directory name', dir)
191
192
193 self.__relax__.generic.dasha.extract(run=run, dir=dir)
194