Author: tlinnet Date: Fri Jun 13 13:03:20 2014 New Revision: 23932 URL: http://svn.gna.org/viewcvs/relax?rev=23932&view=rev Log: Fix for replacement of values with mask, when phi_ex is zero. This can be spin specific. Systemtest: Relax_disp.test_hansen_cpmg_data_to_lm63 starts to fail: Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion models for Clustered analysis. Modified: branches/disp_spin_speed/lib/dispersion/lm63.py Modified: branches/disp_spin_speed/lib/dispersion/lm63.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/lm63.py?rev=23932&r1=23931&r2=23932&view=diff ============================================================================== --- branches/disp_spin_speed/lib/dispersion/lm63.py (original) +++ branches/disp_spin_speed/lib/dispersion/lm63.py Fri Jun 13 13:03:20 2014 @@ -64,8 +64,8 @@ """ # Python module imports. -from numpy import any, array, isfinite, sum, tanh - +from numpy import any, array, isfinite, min, sum, tanh +from numpy.ma import fix_invalid, masked_where def r2eff_LM63(r20=None, phi_ex=None, kex=None, cpmg_frqs=None, back_calc=None): """Calculate the R2eff values for the LM63 model. @@ -85,6 +85,9 @@ @type back_calc: numpy float array of rank [NE][NS][[NM][NO][ND] """ + # Flag to tell if values should be replaced if phi_ex is zero. + t_phi_ex_zero = False + # Catch divide with zeros (to avoid pointless mathematical operations). if kex == 0.0: back_calc[:] = r20 @@ -92,9 +95,9 @@ # Catch zeros (to avoid pointless mathematical operations). # This will result in no exchange, returning flat lines. - if any(phi_ex) == 0.0: - back_calc[:] = r20 - return + if min(phi_ex) == 0.0: + t_phi_ex_zero = True + mask_phi_ex_zero = masked_where(phi_ex == 0.0, phi_ex) # Repetitive calculations (to speed up calculations). rex = phi_ex / kex @@ -103,6 +106,11 @@ # Calculate R2eff. back_calc[:] = r20 + rex * (1.0 - kex_4 * cpmg_frqs * tanh(kex / (4.0 * cpmg_frqs))) + # Replace data in array. + # If phi_ex is zero. + if t_phi_ex_zero: + back_calc[mask_phi_ex_zero.mask] = r20[mask_phi_ex_zero.mask] + # 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(back_calc)):