mailr23844 - /branches/disp_spin_speed/target_functions/relax_disp.py


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

Header


Content

Posted by tlinnet on June 11, 2014 - 16:43:
Author: tlinnet
Date: Wed Jun 11 16:43:17 2014
New Revision: 23844

URL: http://svn.gna.org/viewcvs/relax?rev=23844&view=rev
Log:
Replaced the multiplcation with the disp structure, to a replacement with a 
mask.

My timings are varying at my computer, so results are within the very same 
timing.

But for reading the code, having two masks, is essential better.

Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion 
models for Clustered analysis.

Modified:
    branches/disp_spin_speed/target_functions/relax_disp.py

Modified: branches/disp_spin_speed/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/target_functions/relax_disp.py?rev=23844&r1=23843&r2=23844&view=diff
==============================================================================
--- branches/disp_spin_speed/target_functions/relax_disp.py     (original)
+++ branches/disp_spin_speed/target_functions/relax_disp.py     Wed Jun 11 
16:43:17 2014
@@ -29,7 +29,6 @@
 from math import pi
 from numpy import add, array, asarray, complex64, dot, float64, int16, max, 
multiply, ones, sqrt, sum, tile, zeros
 from numpy.ma import masked_equal
-from numpy import multiply
 
 # relax module imports.
 from lib.dispersion.b14 import r2eff_B14
@@ -433,7 +432,7 @@
             self.num_disp_points_a = deepcopy(zeros_a)
 
             self.frqs_a = deepcopy(zeros_a)
-            self.disp_struct = deepcopy(zeros_a)
+            disp_struct = deepcopy(zeros_a)
             self.has_missing = False
 
             # Create special numpy structures.
@@ -469,7 +468,7 @@
                             self.frqs_a[ei][si][mi][oi][:num_disp_points] = 
self.frqs[ei][si][mi]
                             
                             # Make a spin 1/0 file.
-                            
self.disp_struct[ei][si][mi][oi][:num_disp_points] = ones(num_disp_points)
+                            disp_struct[ei][si][mi][oi][:num_disp_points] = 
ones(num_disp_points)
 
                             for di in 
range(self.num_disp_points[ei][si][mi][oi]):
                                 if self.missing[ei][si][mi][oi][di]:
@@ -480,10 +479,13 @@
             self.back_calc_a = deepcopy(self.values_a)
 
             # Pre calculate frqs structure
-            self.frqs_struct = self.frqs_a * self.disp_struct
+            self.frqs_struct = self.frqs_a * disp_struct
 
             # Find the numpy mask, which tells where values should be 
replaced.
             self.mask_replace_blank = masked_equal(missing_a, 1.0)
+
+            # Find the numpy mask, which tells where values should be set to 
zero.
+            self.mask_set_blank = masked_equal(disp_struct, 0.0)
 
 
     def calc_B14_chi2(self, R20A=None, R20B=None, dw=None, pA=None, 
kex=None):
@@ -573,7 +575,7 @@
         r2eff_CR72(r20a=self.r20a_struct, r20b=self.r20b_struct, pA=pA, 
dw=self.dw_struct, kex=kex, cpmg_frqs=self.cpmg_frqs_a, 
back_calc=self.back_calc_a, num_points=self.num_disp_points_a)
 
         # Clean the data for all values, which is left over at the end of 
arrays.
-        self.back_calc_a = self.back_calc_a*self.disp_struct
+        self.back_calc_a[self.mask_set_blank.mask] = 0.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.
         if self.has_missing:




Related Messages


Powered by MHonArc, Updated Wed Jun 11 17:20:03 2014