mailRe: r23240 - in /branches/disp_speed: lib/dispersion/cr72.py target_functions/relax_disp.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 20, 2014 - 10:23:
Hi Troels,

For good repository management, you should try to keep separate ideas
in separate commits.  In this commit you actually have two separate
concepts in one commit - the change of the target_functions.relax_disp
to lib.dispersion API, and handling of numpy.cosh() overflows.  These
should really be in two commits.  This is important if in the future a
better solution is found for the API and we would like to revert one
of the two changes.

Cheers,

Edward




On 19 May 2014 14:44,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Mon May 19 14:44:12 2014
New Revision: 23240

URL: http://svn.gna.org/viewcvs/relax?rev=23240&view=rev
Log:
Math-domain catching for model CR72.

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

This is to implement catching of math domain errors, before they occur.
These can be found via the --numpy-raise function to the systemtests.

To make the code look clean, the class object "back_calc" is no longer
being updated per time point, but is updated in the relax_disp target 
function in
one go.

Modified:
    branches/disp_speed/lib/dispersion/cr72.py
    branches/disp_speed/target_functions/relax_disp.py

Modified: branches/disp_speed/lib/dispersion/cr72.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/cr72.py?rev=23240&r1=23239&r2=23240&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/cr72.py  (original)
+++ branches/disp_speed/lib/dispersion/cr72.py  Mon May 19 14:44:12 2014
@@ -92,12 +92,12 @@
 """

 # Python module imports.
-from numpy import arccosh, array, cos, cosh, isfinite, sqrt, sum
+from numpy import arccosh, array, cos, cosh, isfinite, max, sqrt, sum

 # Repetitive calculations (to speed up calculations).
 eta_scale = 2.0**(-3.0/2.0)

-def r2eff_CR72(r20a=None, r20b=None, pA=None, dw=None, kex=None, 
cpmg_frqs=None, back_calc=None, num_points=None):
+def r2eff_CR72(r20a=None, r20b=None, pA=None, dw=None, kex=None, 
cpmg_frqs=None, num_points=None):
     """Calculate the R2eff values for the CR72 model.

     See the module docstring for details.
@@ -115,9 +115,7 @@
     @type kex:              float
     @keyword cpmg_frqs:     The CPMG nu1 frequencies.
     @type cpmg_frqs:        numpy rank-1 float array
-    @keyword back_calc:     The array for holding the back calculated 
R2eff values.  Each element corresponds to one of the CPMG nu1 frequencies.
-    @type back_calc:        numpy rank-1 float array
-    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs and back_calc arguments.
+    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs.
     @type num_points:       int
     """

@@ -151,6 +149,14 @@
     etapos = eta_scale * sqrt(Psi + sqrt_psi2_zeta2) / cpmg_frqs
     etaneg = eta_scale * sqrt(-Psi + sqrt_psi2_zeta2) / cpmg_frqs

+    # Catch math domain error of cosh(val > 710).
+    # This is when etapos > 710.
+    if num_points > 0:
+        if max(etapos) > 700:
+            R2eff = array([1e100]*num_points)
+
+            return R2eff
+
     # Calculate R2eff.
     R2eff = r20_kex - cpmg_frqs * arccosh( Dpos * cosh(etapos) - Dneg * 
cos(etaneg) )

@@ -159,6 +165,4 @@
     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):
-        back_calc[i] = R2eff[i]
+    return R2eff

Modified: branches/disp_speed/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/target_functions/relax_disp.py?rev=23240&r1=23239&r2=23240&view=diff
==============================================================================
--- branches/disp_speed/target_functions/relax_disp.py  (original)
+++ branches/disp_speed/target_functions/relax_disp.py  Mon May 19 14:44:12 
2014
@@ -484,7 +484,7 @@
                 dw_frq = dw[si] * self.frqs[0][si][mi]

                 # Back calculate the R2eff values.
-                r2eff_CR72(r20a=R20A[r20_index], r20b=R20B[r20_index], 
pA=pA, dw=dw_frq, kex=kex, cpmg_frqs=self.cpmg_frqs[0][mi][0], 
back_calc=self.back_calc[0][si][mi][0], 
num_points=self.num_disp_points[0][si][mi][0])
+                self.back_calc[0][si][mi][0] = 
r2eff_CR72(r20a=R20A[r20_index], r20b=R20B[r20_index], pA=pA, dw=dw_frq, 
kex=kex, cpmg_frqs=self.cpmg_frqs[0][mi][0], 
num_points=self.num_disp_points[0][si][mi][0])

                 # For all missing data points, set the back-calculated 
value to the measured values so that it has no effect on the chi-squared 
value.
                 for di in range(self.num_disp_points[0][si][mi][0]):


_______________________________________________
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