mailRe: r24945 - /branches/R1_fitting/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 August 18, 2014 - 11:57:
Hi,

Do you have a user case scenario you can imagine where it would be
useful for the user to select between the different behaviours?  Note
that the current behaviour of having three 'No Rex' models will
require significant changes to multiple sections in the relaxation
dispersion chapter of the relax manual.  The 'implemented models'
section would need the new models added, the dispersion model table
expanded, the section for no chemical exchange subdivided into
subsections for each of these, the software comparison table expanded,
etc.  It would be much less work to unify the models via a function
which determines the behaviour for the user
(http://thread.gmane.org/gmane.science.nmr.relax.scm/22680/focus=6632).

Cheers,

Edward



On 18 August 2014 11:22, Troels Emtekær Linnet <tlinnet@xxxxxxxxxxxxx> wrote:
Hi Edward.

I don't think such things should be modified in the back-end code, but
rather it the front-end code,
helping selecting the right model.

Using scripting, it should be possible to do access all parts of the code.
Even if it does not give any sense.

A better functionality, would be to implement a function, which go
through the self.models, and suggest the correct models
to use instead.

Best
Troels


2014-08-18 11:02 GMT+02:00 Edward d'Auvergne <edward@xxxxxxxxxxxxx>:
Hi,

If all the 'No Rex' models are merged into a single model, then the
methods here would remain identical.  However the logic of the "if
model == MODEL_NOREX:" block would be modified to select the correct
target function based on the data that the user input.  Or even
simpler, the logic could be placed higher up in a function in the
specific_analyses.relax_disp.data module, and then a new argument
added to the target function class for choosing between the target
functions.  Note that a 4th target function will probably be added in
the future when off-resonance CPMG data is handled, to allow R1 to be
optimised with this data.

Cheers,

Edward



On 4 August 2014 19:22,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Mon Aug  4 19:22:10 2014
New Revision: 24945

URL: http://svn.gna.org/viewcvs/relax?rev=24945&view=rev
Log:
Implemented target and calculation function for MODEL_NOREX_R1RHO, 
MODEL_NOREX_R1RHO_FIT_R1.

bug #22440(https://gna.org/bugs/?22440): The "NOREX" model is not 
covering R1rho models.
sr #3135(https://gna.org/support/?3135): Optimisation of the R1 
relaxation rate for the off-resonance R1rho relaxation dispersion models.

Modified:
    branches/R1_fitting/target_functions/relax_disp.py

Modified: branches/R1_fitting/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/R1_fitting/target_functions/relax_disp.py?rev=24945&r1=24944&r2=24945&view=diff
==============================================================================
--- branches/R1_fitting/target_functions/relax_disp.py  (original)
+++ branches/R1_fitting/target_functions/relax_disp.py  Mon Aug  4 
19:22:10 2014
@@ -55,7 +55,7 @@
 from lib.errors import RelaxError
 from lib.float import isNaN
 from target_functions.chi2 import chi2_rankN
-from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, 
EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, 
EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_LIST_CPMG, EXP_TYPE_R1RHO, 
MODEL_B14, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, 
MODEL_DPL94_FIT_R1, MODEL_IT99, MODEL_LIST_CPMG, MODEL_LIST_FULL, 
MODEL_LIST_MMQ, MODEL_LIST_MQ_CPMG, MODEL_LIST_NUMERIC, MODEL_LIST_R1RHO, 
MODEL_LIST_R1RHO_FULL, MODEL_LIST_R1RHO_FIT_R1, MODEL_LM63, 
MODEL_LM63_3SITE, MODEL_M61, MODEL_M61B, MODEL_MP05, MODEL_MMQ_CR72, 
MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, 
MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR, 
MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE, 
MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE, 
MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_PARAM_DW_MIX_DOUBLE, 
MODEL_PARAM_DW_MIX_QUADRUPLE, MODEL_PARAM_INV_RELAX_TIMES, 
MODEL_PARAM_R20B, MODEL_TAP03, MODEL_TP02, MODEL_TSMFK01
+from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, 
EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, 
EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_LIST_CPMG, EXP_TYPE_R1RHO, 
MODEL_B14, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, 
MODEL_DPL94_FIT_R1, MODEL_IT99, MODEL_LIST_CPMG, MODEL_LIST_FULL, 
MODEL_LIST_MMQ, MODEL_LIST_MQ_CPMG, MODEL_LIST_NUMERIC, MODEL_LIST_R1RHO, 
MODEL_LIST_R1RHO_FULL, MODEL_LIST_R1RHO_FIT_R1, MODEL_LM63, 
MODEL_LM63_3SITE, MODEL_M61, MODEL_M61B, MODEL_MP05, MODEL_MMQ_CR72, 
MODEL_NOREX, MODEL_NOREX_R1RHO, MODEL_NOREX_R1RHO_FIT_R1, 
MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, 
MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR, 
MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE, 
MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE, 
MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_PARAM_DW_MIX_DOUBLE, 
MODEL_PARAM_DW_MIX_QUADRUPLE, MODEL_PARAM_INV_RELAX_TIMES, 
MODEL_PARAM_R20B, MODEL_TAP03, MODEL_TP02, MODEL_TSMFK01


 class Dispersion:
@@ -482,6 +482,10 @@
         # Set up the model.
         if model == MODEL_NOREX:
             self.func = self.func_NOREX
+        if model == MODEL_NOREX_R1RHO:
+            self.func = self.func_NOREX_R1RHO
+        if model == MODEL_NOREX_R1RHO_FIT_R1:
+            self.func = self.func_NOREX_R1RHO_FIT_R1
         if model == MODEL_LM63:
             self.func = self.func_LM63
         if model == MODEL_LM63_3SITE:
@@ -653,6 +657,35 @@
         return chi2_rankN(self.values, self.back_calc, self.errors)


+    def calc_NOREX_R1RHO(self, R1=None, r1rho_prime=None):
+        """Calculation function for no exchange, for R1rho off resonance 
models.
+
+        @keyword R1:            The R1 value.
+        @type R1:               list of float
+        @keyword r1rho_prime:   The R1rho value for all states in the 
absence of exchange.
+        @type r1rho_prime:      list of float
+        @return:                The chi-squared value.
+        @rtype:                 float
+        """
+
+        # Reshape r1rho_prime to per experiment, spin and frequency.
+        self.r1rho_prime_struct[:] = multiply.outer( 
r1rho_prime.reshape(self.NE, self.NS, self.NM), self.no_nd_ones )
+
+        # Make back calculation.
+        self.back_calc[:] = R1 * cos(self.tilt_angles)**2 + 
self.r1rho_prime_struct * sin(self.tilt_angles)**2
+
+        # Clean the data for all values, which is left over at the end 
of arrays.
+        self.back_calc = self.back_calc*self.disp_struct
+
+        # 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:
+            # Replace with values.
+            self.back_calc[self.mask_replace_blank.mask] = 
self.values[self.mask_replace_blank.mask]
+
+        # Return the total chi-squared value.
+        return chi2_rankN(self.values, self.back_calc, self.errors)
+
+
     def calc_ns_cpmg_2site_3D_chi2(self, R20A=None, R20B=None, dw=None, 
pA=None, kex=None):
         """Calculate the chi-squared value of the 'NS CPMG 2-site' 
models.

@@ -1395,6 +1428,50 @@
         return chi2_rankN(self.values, self.back_calc, self.errors)


+    def func_NOREX_R1RHO(self, params):
+        """Target function for no exchange, for R1rho off resonance 
models.
+
+        @param params:  The vector of parameter values.
+        @type params:   numpy rank-1 float array
+        @return:        The chi-squared value.
+        @rtype:         float
+        """
+
+        # Scaling.
+        if self.scaling_flag:
+            params = dot(params, self.scaling_matrix)
+
+        # Unpack the parameter values.
+        r1rho_prime = params
+
+        # Calculate and return the chi-squared value.
+        return self.calc_NOREX_R1RHO(R1=self.r1, r1rho_prime=r1rho_prime)
+
+
+    def func_NOREX_R1RHO_FIT_R1(self, params):
+        """Target function for no exchange, for R1rho off resonance 
models, where R1 is fitted.
+
+        @param params:  The vector of parameter values.
+        @type params:   numpy rank-1 float array
+        @return:        The chi-squared value.
+        @rtype:         float
+        """
+
+        # Scaling.
+        if self.scaling_flag:
+            params = dot(params, self.scaling_matrix)
+
+        # Unpack the parameter values.
+        r1 = params[:self.end_index[0]]
+        r1rho_prime = params[self.end_index[0]:self.end_index[1]]
+
+        # Reshape R1 to per experiment, spin and frequency.
+        self.r1_struct[:] = multiply.outer( r1.reshape(self.NE, self.NS, 
self.NM), self.no_nd_ones )
+
+        # Calculate and return the chi-squared value.
+        return self.calc_NOREX_R1RHO(R1=self.r1_struct, 
r1rho_prime=r1rho_prime)
+
+
     def func_ns_cpmg_2site_3D(self, params):
         """Target function for the reduced numerical solution for the 
2-site Bloch-McConnell equations.



_______________________________________________
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

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
relax-devel@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-devel



Related Messages


Powered by MHonArc, Updated Mon Aug 18 12:40:13 2014