Package lib :: Package curve_fit :: Module exponential
[hide private]
[frames] | no frames]

Source Code for Module lib.curve_fit.exponential

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2013 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program 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 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Module for exponential curve-fitting.""" 
24   
25  # Python module imports. 
26  from math import exp 
27   
28   
29 -def exponential_2param_neg(rate=None, i0=None, x=None, y=None):
30 """Calculate the data for a standard two parameter decreasing exponential. 31 32 The y-values will be calculated based on the x-values. 33 34 35 @keyword rate: The exponential rate. 36 @type rate: float 37 @keyword i0: The initial intensity. 38 @type i0: float 39 @keyword x: The x-values at which to calculate the y-values. 40 @type x: numpy rank-1 float array 41 @keyword y: The data structure to store the y-values in. 42 @type y: numpy rank-1 float array 43 """ 44 45 # Loop over the x-values. 46 for i in range(len(x)): 47 y[i] = i0 * exp(-rate*x[i])
48