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

Source Code for Module prompt.dasha

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2005 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 minisation, 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):
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 # Function intro text. 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 # The run argument. 140 if type(run) != str: 141 raise RelaxStrError, ('run', run) 142 143 # Directory. 144 if dir != None: 145 if type(dir) != str: 146 raise RelaxNoneStrError, ('directory name', dir) 147 148 # The force flag. 149 if type(force) != int or (force != 0 and force != 1): 150 raise RelaxBinError, ('force flag', force) 151 152 # Execute the functional code. 153 self.__relax__.generic.dasha.execute(run=run, dir=dir, force=force)
154 155
156 - def extract(self, run=None, dir=None):
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 # Function intro text. 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 # The run argument. 175 if type(run) != str: 176 raise RelaxStrError, ('run', run) 177 178 # Directory. 179 if dir != None: 180 if type(dir) != str: 181 raise RelaxNoneStrError, ('directory name', dir) 182 183 # Execute the functional code. 184 self.__relax__.generic.dasha.extract(run=run, dir=dir)
185