Hi, For reference, as missing data is quite common in real analyses, a much, much faster implementation for handling missing data is described in:
http://article.gmane.org/gmane.science.nmr.relax.devel/5726 This would be orders of magnitude faster for this component. Regards, Edward On 8 June 2014 22:22, <[email protected]> wrote: > Author: tlinnet > Date: Sun Jun 8 22:22:24 2014 > New Revision: 23741 > > URL: http://svn.gna.org/viewcvs/relax?rev=23741&view=rev > Log: > Added self.has_missing keyword in initialization of the Dispersion class. > > This is to test once, per spin or cluster. > This saves a looping over the dipsersion points, when collection the data. > > 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=23741&r1=23740&r2=23741&view=diff > ============================================================================== > --- branches/disp_spin_speed/target_functions/relax_disp.py (original) > +++ branches/disp_spin_speed/target_functions/relax_disp.py Sun Jun 8 > 22:22:24 2014 > @@ -417,6 +417,7 @@ > self.cpmg_frqs_a = np.ones(back_calc_shape + > [self.max_num_disp_points]) > self.num_disp_points_a = np.ones(back_calc_shape + > [self.max_num_disp_points]) > self.back_calc_a = np.ones(back_calc_shape + > [self.max_num_disp_points]) > + self.has_missing = False > > # Loop over the experiment types. > for ei in range(self.num_exp): > @@ -433,6 +434,10 @@ > > self.cpmg_frqs_a[ei][si][mi][oi][:num_disp_points] = > self.cpmg_frqs[ei][mi][oi] > > self.num_disp_points_a[ei][si][mi][oi][:num_disp_points] = > self.num_disp_points[ei][si][mi][oi] > > + for di in > range(self.num_disp_points[ei][si][mi][oi]): > + if self.missing[ei][si][mi][oi][di]: > + self.has_missing = True > + > > def calc_B14_chi2(self, R20A=None, R20B=None, dw=None, pA=None, > kex=None): > """Calculate the chi-squared value of the Baldwin (2014) 2-site > exact solution model for all time scales. > @@ -541,7 +546,6 @@ > chi2_sum = 0.0 > > # Now return the values back to the structure of self.back_calc > object. > - ## 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. > # Loop over the spins. > for si in range(self.num_spins): > # Loop over the spectrometer frequencies. > @@ -551,10 +555,11 @@ > > self.back_calc[0][si][mi][0] = > self.back_calc_a[0][si][mi][0][:num_disp_points] > > - > - for di in range(self.num_disp_points[0][si][mi][0]): > - if self.missing[0][si][mi][0][di]: > - self.back_calc[0][si][mi][0][di] = > self.values[0][si][mi][0][di] > + ## 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: > + for di in range(self.num_disp_points[0][si][mi][0]): > + if self.missing[0][si][mi][0][di]: > + self.back_calc[0][si][mi][0][di] = > self.values[0][si][mi][0][di] > > ## Calculate and return the chi-squared value. > chi2_sum += chi2(self.values[0][si][mi][0], > self.back_calc[0][si][mi][0], self.errors[0][si][mi][0]) > > > _______________________________________________ > relax (http://www.nmr-relax.com) > > This is the relax-commits mailing list > [email protected] > > 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 _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-devel mailing list [email protected] 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-devel

