Package prompt :: Module dasha
[hide private]
[frames] | no frames]

Source Code for Module prompt.dasha

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2005-2006 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  import sys 
 24   
 25  import help 
 26   
 27   
28 -class Dasha:
29 - def __init__(self, relax):
30 # Help. 31 self.__relax_help__ = \ 32 """Class for interfacing with the program Dasha.""" 33 34 # Add the generic help string. 35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help 36 37 # Place relax in the class namespace. 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 # Function intro text. 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 # The run argument. 86 if type(run) != str: 87 raise RelaxStrError, ('run', run) 88 89 # The algor argument. 90 if type(algor) != str: 91 raise RelaxStrError, ('optimisation algorithm', algor) 92 93 # Directory. 94 if dir != None: 95 if type(dir) != str: 96 raise RelaxNoneStrError, ('directory name', dir) 97 98 # The force flag. 99 if type(force) != int or (force != 0 and force != 1): 100 raise RelaxBinError, ('force flag', force) 101 102 # Execute the functional code. 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 # Function intro text. 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 # The run argument. 145 if type(run) != str: 146 raise RelaxStrError, ('run', run) 147 148 # Directory. 149 if dir != None: 150 if type(dir) != str: 151 raise RelaxNoneStrError, ('directory name', dir) 152 153 # The force flag. 154 if type(force) != int or (force != 0 and force != 1): 155 raise RelaxBinError, ('force flag', force) 156 157 # The Dasha executable file. 158 if type(binary) != str: 159 raise RelaxStrError, ('Dasha binary', binary) 160 161 # Execute the functional code. 162 self.__relax__.generic.dasha.execute(run=run, dir=dir, force=force, binary=binary)
163 164
165 - def extract(self, run=None, dir=None):
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 # Function intro text. 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 # The run argument. 184 if type(run) != str: 185 raise RelaxStrError, ('run', run) 186 187 # Directory. 188 if dir != None: 189 if type(dir) != str: 190 raise RelaxNoneStrError, ('directory name', dir) 191 192 # Execute the functional code. 193 self.__relax__.generic.dasha.extract(run=run, dir=dir)
194