Author: bugman Date: Thu May 29 13:56:16 2014 New Revision: 23593 URL: http://svn.gna.org/viewcvs/relax?rev=23593&view=rev Log: Merged revisions 23240 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/disp_speed ........ r23240 | tlinnet | 2014-05-19 14:44:12 +0200 (Mon, 19 May 2014) | 10 lines 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: trunk/ (props changed) trunk/lib/dispersion/cr72.py trunk/target_functions/relax_disp.py Propchange: trunk/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Thu May 29 13:56:16 2014 @@ -1 +1 @@ -/branches/disp_speed:1-23214,23216-23229,23239 +/branches/disp_speed:1-23214,23216-23229,23239-23240 Modified: trunk/lib/dispersion/cr72.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/cr72.py?rev=23593&r1=23592&r2=23593&view=diff ============================================================================== --- trunk/lib/dispersion/cr72.py (original) +++ trunk/lib/dispersion/cr72.py Thu May 29 13:56:16 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: trunk/target_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_disp.py?rev=23593&r1=23592&r2=23593&view=diff ============================================================================== --- trunk/target_functions/relax_disp.py (original) +++ trunk/target_functions/relax_disp.py Thu May 29 13:56:16 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]):