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

Source Code for Module prompt.dasha

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2005-2010 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  # Module docstring. 
 24  """Module containing the 'dasha' user function class for controlling the Dasha model-free software.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # Python module imports. 
 28   
 29  # relax module imports. 
 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 # Function intro text. 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 # The argument checks. 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 # Execute the functional code. 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 # Function intro text. 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 # The argument checks. 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 # Execute the functional code. 129 dasha.execute(dir=dir, force=force, binary=binary)
130 131
132 - def extract(self, dir=None):
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 # Function intro text. 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 # The argument checks. 148 arg_check.is_str(dir, 'directory name', can_be_none=True) 149 150 # Execute the functional code. 151 dasha.extract(dir=dir)
152