1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the 'dasha' user function class for controlling the Dasha model-free software."""
25 __docformat__ = 'plaintext'
26
27
28
29
30 from base_class import User_fn_class
31 import arg_check
32 from generic_fns import dasha
33
34
35 -class Dasha(User_fn_class):
36 """Class for interfacing with the program Dasha."""
37
38 - def create(self, algor='LM', dir=None, force=False):
39 """Function for creating the Dasha script.
40
41 Keyword Arguments
42 ~~~~~~~~~~~~~~~~~
43
44 algor: The minimisation algorithm.
45
46 dir: The directory to place the files.
47
48 force: A flag which if set to True will cause the results file to be overwritten if it
49 already exists.
50
51
52 Description
53 ~~~~~~~~~~~
54
55 The script file created is called 'dir/dasha_script'.
56
57
58 Optimisation algorithms
59 ~~~~~~~~~~~~~~~~~~~~~~~
60
61 The two minimisation algorithms within Dasha are accessible through the algor argument which
62 can be set to:
63
64 'LM' - The Levenberg-Marquardt algorithm.
65 'NR' - Newton-Raphson algorithm.
66
67 For Levenberg-Marquardt minimisation, the function 'lmin' will be called, while for Newton
68 -Raphson, the function 'min' will be executed.
69 """
70
71
72 if self._exec_info.intro:
73 text = self._exec_info.ps3 + "dasha.create("
74 text = text + "algor=" + repr(algor)
75 text = text + ", dir=" + repr(dir)
76 text = text + ", force=" + repr(force) + ")"
77 print(text)
78
79
80 arg_check.is_str(algor, 'optimisation algorithm')
81 arg_check.is_str(dir, 'directory name', can_be_none=True)
82 arg_check.is_bool(force, 'force flag')
83
84
85 dasha.create(algor=algor, dir=dir, force=force)
86
87
88 - def execute(self, dir=None, force=False, binary='dasha'):
89 """Function for executing Dasha.
90
91 Keyword Arguments
92 ~~~~~~~~~~~~~~~~~
93
94 dir: The directory to place the files.
95
96 force: A flag which if set to True will cause the results file to be overwritten if it
97 already exists.
98
99 binary: The name of the executable Dasha program file.
100
101
102 Execution
103 ~~~~~~~~~
104
105 Dasha will be executed as
106
107 $ dasha < dasha_script | tee dasha_results
108
109
110 If you would like to use a different Dasha executable file, change the keyword argument
111 'binary' to the appropriate file name. If the file is not located within the environment's
112 path, include the full path in front of the binary file name.
113 """
114
115
116 if self._exec_info.intro:
117 text = self._exec_info.ps3 + "dasha.execute("
118 text = text + "dir=" + repr(dir)
119 text = text + ", force=" + repr(force)
120 text = text + ", binary=" + repr(binary) + ")"
121 print(text)
122
123
124 arg_check.is_str(dir, 'directory name', can_be_none=True)
125 arg_check.is_bool(force, 'force flag')
126 arg_check.is_str(binary, 'Dasha executable file')
127
128
129 dasha.execute(dir=dir, force=force, binary=binary)
130
131
133 """Function for extracting data from the Dasha results file.
134
135 Keyword Arguments
136 ~~~~~~~~~~~~~~~~~
137
138 dir: The directory where the file 'dasha_results' is found.
139 """
140
141
142 if self._exec_info.intro:
143 text = self._exec_info.ps3 + "dasha.extract("
144 text = text + "dir=" + repr(dir) + ")"
145 print(text)
146
147
148 arg_check.is_str(dir, 'directory name', can_be_none=True)
149
150
151 dasha.extract(dir=dir)
152