mailRe: r23227 - /branches/disp_speed/lib/dispersion/it99.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on May 19, 2014 - 10:54:
Hi Troels,

Awesome work with all these speed ups!!  If you are feeling really
adventurous, I'll soon place a hint about an ultimate solution for
speed in the thread at
http://thread.gmane.org/gmane.science.nmr.relax.devel/5726.  The
chi2_5D() function and missing data ideas there should already give
you some great speed ups as well.

Cheers,

Edward


On 19 May 2014 03:20,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Mon May 19 03:20:53 2014
New Revision: 23227

URL: http://svn.gna.org/viewcvs/relax?rev=23227&view=rev
Log:
Speed-up of model IT99.

task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models.

Change in speed is:
test_hansen_cpmg_data_auto_analysis
9.74s -> 8.330s

test_hansen_cpmg_data_to_it99
4.928s ->  3.138s

Modified:
    branches/disp_speed/lib/dispersion/it99.py

Modified: branches/disp_speed/lib/dispersion/it99.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/it99.py?rev=23227&r1=23226&r2=23227&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/it99.py  (original)
+++ branches/disp_speed/lib/dispersion/it99.py  Mon May 19 03:20:53 2014
@@ -73,7 +73,7 @@
 """

 # Python module imports.
-from math import sqrt
+from numpy import array, isfinite, sqrt, sum


 def r2eff_IT99(r20=None, pA=None, pB=None, dw=None, tex=None, 
cpmg_frqs=None, back_calc=None, num_points=None):
@@ -109,24 +109,21 @@
     # The numerator.
     numer = padw2 * pB * tex

-    # Loop over the time points, back calculating the R2eff values.
+    # The effective rotating frame field.
+    omega_1eff4 = 2304.0 * cpmg_frqs**4
+
+    # Denominator.
+    omega_a2 = sqrt(omega_1eff4 + pa2dw4)
+    denom = 1.0 + omega_a2 * tex2
+
+    # R2eff calculation.
+    R2eff = r20 + numer / denom
+
+    # Catch errors, taking a sum over array is the fastest way to check for
+    # +/- inf (infinity) and nan (not a number).
+    if not isfinite(sum(R2eff)):
+        R2eff = array([1e100]*num_points)
+
+    # Parse back the value to update the back_calc class object.
     for i in range(num_points):
-        # Catch zeros (to avoid pointless mathematical operations).
-        if numer == 0.0:
-            back_calc[i] = r20
-            continue
-
-        # The effective rotating frame field.
-        omega_1eff4 = 2304.0 * cpmg_frqs[i]**4
-
-        # Denominator.
-        omega_a2 = sqrt(omega_1eff4 + pa2dw4)
-        denom = 1.0 + omega_a2 * tex2
-
-        # Avoid divide by zero.
-        if denom == 0.0:
-            back_calc[i] = 1e100
-            continue
-
-        # R2eff calculation.
-        back_calc[i] = r20 + numer / denom
+        back_calc[i] = R2eff[i]


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Tue May 20 10:40:13 2014