Package user_functions :: Module relax_fit
[hide private]
[frames] | no frames]

Source Code for Module user_functions.relax_fit

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004,2006,2008-2009,2012,2014 Edward d'Auvergne               # 
  4  # Copyright (C) 2008 Sebastien Morin                                          # 
  5  # Copyright (C) 2014 Troels E. Linnet                                         # 
  6  #                                                                             # 
  7  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  8  #                                                                             # 
  9  # This program is free software: you can redistribute it and/or modify        # 
 10  # it under the terms of the GNU General Public License as published by        # 
 11  # the Free Software Foundation, either version 3 of the License, or           # 
 12  # (at your option) any later version.                                         # 
 13  #                                                                             # 
 14  # This program is distributed in the hope that it will be useful,             # 
 15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 17  # GNU General Public License for more details.                                # 
 18  #                                                                             # 
 19  # You should have received a copy of the GNU General Public License           # 
 20  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Module docstring. 
 25  """The relax_fit user function definitions.""" 
 26   
 27  # relax module imports. 
 28  from graphics import ANALYSIS_IMAGE_PATH 
 29  from lib.text.gui import i0, iinf, rx 
 30  from pipe_control import spectrum 
 31  from specific_analyses.relax_fit.uf import relax_time, select_model 
 32  from user_functions.data import Uf_info; uf_info = Uf_info() 
 33  from user_functions.objects import Desc_container 
 34   
 35   
 36  # The user function class. 
 37  uf_class = uf_info.add_class('relax_fit') 
 38  uf_class.title = "Class for relaxation curve fitting." 
 39  uf_class.menu_text = "&relax_fit" 
 40  uf_class.gui_icon = "relax.relax_fit" 
 41   
 42   
 43  # The relax_fit.relax_time user function. 
 44  uf = uf_info.add_uf('relax_fit.relax_time') 
 45  uf.title = "Set the relaxation delay time associated with each spectrum." 
 46  uf.title_short = "Relaxation delay time setting." 
 47  uf.add_keyarg( 
 48      name = "time", 
 49      default = 0.0, 
 50      basic_types = ["number"], 
 51      desc_short = "relaxation time", 
 52      desc = "The time, in seconds, of the relaxation period." 
 53  ) 
 54  uf.add_keyarg( 
 55      name = "spectrum_id", 
 56      basic_types = ["str"], 
 57      desc_short = "spectrum identification string", 
 58      desc = "The spectrum identification string.", 
 59      wiz_element_type = 'combo', 
 60      wiz_combo_iter = spectrum.get_ids, 
 61      wiz_read_only = True 
 62  ) 
 63  # Description. 
 64  uf.desc.append(Desc_container()) 
 65  uf.desc[-1].add_paragraph("Peak intensities should be loaded before calling this user function via the spectrum.read_intensities user function.  The intensity values will then be associated with a spectrum identifier.  To associate each spectrum identifier with a time point in the relaxation curve prior to optimisation, this user function should be called.") 
 66  uf.backend = relax_time 
 67  uf.menu_text = "&relax_time" 
 68  uf.gui_icon = "oxygen.actions.chronometer" 
 69  uf.wizard_size = (700, 500) 
 70  uf.wizard_image = ANALYSIS_IMAGE_PATH + 'r1_200x200.png' 
 71   
 72   
 73  # The relax_fit.select_model user function. 
 74  uf = uf_info.add_uf('relax_fit.select_model') 
 75  uf.title = "Select the relaxation curve type." 
 76  uf.title_short = "Relaxation curve type selection." 
 77  uf.display = True 
 78  uf.add_keyarg( 
 79      name = "model", 
 80      default = "exp", 
 81      basic_types = ["str"], 
 82      desc_short = "model", 
 83      desc = "The type of relaxation curve to fit.", 
 84      wiz_element_type = "combo", 
 85      wiz_combo_choices = [ 
 86          "Two parameter exponential fit: [%s, %s]" % (rx, i0), 
 87          "Inversion recovery: [%s, %s, %s]" % (rx, i0, iinf), 
 88          "Saturation recovery: [%s, %s]" % (rx, iinf) 
 89      ], 
 90      wiz_combo_data = [ 
 91          "exp", 
 92          "inv", 
 93          "sat" 
 94      ], 
 95      wiz_read_only = True 
 96  ) 
 97  # Description. 
 98  uf.desc.append(Desc_container()) 
 99  uf.desc[-1].add_paragraph("A number of relaxation experiments are supported and include:") 
100  uf.desc[-1].add_paragraph("The 'exp' model.  This is the default two parameter exponential fit.  The magnetisation starts at I0 and decays to zero.  The parameters are [Rx, I0] and the equation is I(t) = I0*exp(-Rx*t).") 
101  uf.desc[-1].add_paragraph("The 'inv' model.  This is the inversion recovery experiment (IR).  The magnetisation starts at a negative value at -I0 and relaxes to a positive Iinf value.  The parameters are [Rx, I0, Iinf] and the equation is I(t) = Iinf - I0*exp(-Rx*t).") 
102  uf.desc[-1].add_paragraph("The 'sat' model.  This is the saturation recovery experiment (SR).  The magnetisation starts at zero and relaxes to a positive Iinf value.  The parameters are [Rx, Iinf] and the equation is I(t) = Iinf*(1 - exp(-Rx*t)).") 
103  uf.backend = select_model 
104  uf.menu_text = "&select_model" 
105  uf.gui_icon = "oxygen.actions.list-add" 
106  uf.wizard_height_desc = 500 
107  uf.wizard_size = (900, 600) 
108  uf.wizard_apply_button = False 
109  uf.wizard_image = ANALYSIS_IMAGE_PATH + 'r1_200x200.png' 
110