Author: bugman Date: Fri Sep 12 13:57:44 2014 New Revision: 25783 URL: http://svn.gna.org/viewcvs/relax?rev=25783&view=rev Log: Creation of the error_analysis.covariance_matrix user function. This is simply a code rearrangement. The relax_fit user function module was duplicated and relax_fit.rx_err_estimate renamed to error_analysis.covariance_matrix. References to the specific analysis have been removed. Added: trunk/user_functions/error_analysis.py - copied, changed from r25781, trunk/user_functions/relax_fit.py Modified: trunk/user_functions/__init__.py trunk/user_functions/relax_fit.py Modified: trunk/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/__init__.py?rev=25783&r1=25782&r2=25783&view=diff ============================================================================== --- trunk/user_functions/__init__.py (original) +++ trunk/user_functions/__init__.py Fri Sep 12 13:57:44 2014 @@ -45,6 +45,7 @@ 'domain', 'dx', 'eliminate', + 'error_analysis', 'fix', 'frame_order', 'grace', @@ -102,6 +103,7 @@ import user_functions.domain import user_functions.dx import user_functions.eliminate + import user_functions.error_analysis import user_functions.fix import user_functions.frame_order import user_functions.grace Copied: trunk/user_functions/error_analysis.py (from r25781, trunk/user_functions/relax_fit.py) URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/error_analysis.py?p2=trunk/user_functions/error_analysis.py&p1=trunk/user_functions/relax_fit.py&r1=25781&r2=25783&rev=25783&view=diff ============================================================================== --- trunk/user_functions/relax_fit.py (original) +++ trunk/user_functions/error_analysis.py Fri Sep 12 13:57:44 2014 @@ -20,68 +20,28 @@ ############################################################################### # Module docstring. -"""The relax_fit user function definitions.""" +"""The error_analysis user function definitions.""" # Python module imports. from os import sep # relax module imports. from graphics import ANALYSIS_IMAGE_PATH -from pipe_control import spectrum -from specific_analyses.relax_fit.uf import relax_time, select_model -from specific_analyses.relax_fit.estimate_rx_err import estimate_rx_err +from pipe_control.error_analysis import covariance_matrix from user_functions.data import Uf_info; uf_info = Uf_info() from user_functions.objects import Desc_container # The user function class. -uf_class = uf_info.add_class('relax_fit') +uf_class = uf_info.add_class('error_analysis') uf_class.title = "Class for relaxation curve fitting." -uf_class.menu_text = "&relax_fit" -uf_class.gui_icon = "relax.relax_fit" +uf_class.menu_text = "&error_analysis" -# The relax_fit.relax_time user function. -uf = uf_info.add_uf('relax_fit.relax_time') -uf.title = "Set the relaxation delay time associated with each spectrum." -uf.title_short = "Relaxation delay time setting." -uf.add_keyarg( - name = "time", - default = 0.0, - py_type = "num", - desc_short = "relaxation time", - desc = "The time, in seconds, of the relaxation period." -) -uf.add_keyarg( - name = "spectrum_id", - py_type = "str", - desc_short = "spectrum identification string", - desc = "The spectrum identification string.", - wiz_element_type = 'combo', - wiz_combo_iter = spectrum.get_ids, - wiz_read_only = True -) -# Description. -uf.desc.append(Desc_container()) -uf.desc[-1].add_paragraph("Peak intensities should be loaded before calling this user function via the spectrum.read_intensities user function. The intensity values will then be associated with a spectrum identifier. To associate each spectrum identifier with a time point in the relaxation curve prior to optimisation, this user function should be called.") -uf.backend = relax_time -uf.menu_text = "&relax_time" -uf.gui_icon = "oxygen.actions.chronometer" -uf.wizard_size = (700, 500) - - -# The relax_fit.rx_err_estimate user function. -uf = uf_info.add_uf('relax_fit.rx_err_estimate') -uf.title = "Estimate Rx errors by the Jacobian matrix." -uf.title_short = "Estimate Rx errors." -uf.add_keyarg( - name = "spin_id", - py_type = "str", - arg_type = "spin ID", - desc_short = "spin ID to restrict value setting to", - desc = "The spin ID string to restrict value setting to.", - can_be_none = True -) +# The error_analysis.covariance_matrix user function. +uf = uf_info.add_uf('error_analysis.covariance_matrix') +uf.title = "Parameter error estimation via the covariance matrix." +uf.title_short = "Covariance matrix parameter error estimation." uf.add_keyarg( name = "epsrel", py_type = "float", @@ -101,50 +61,13 @@ # Description. uf.desc.append(Desc_container()) uf.desc[-1].add_paragraph("This is a new experimental feature from version 3.3.") -uf.desc[-1].add_paragraph("This will estimate Rx errors by using the exponential decay Jacobian matrix 'J' to compute the covariance matrix of the best-fit parameters.") +uf.desc[-1].add_paragraph("This will estimate parameter errors by using the exponential decay Jacobian matrix 'J' to compute the covariance matrix of the best-fit parameters.") uf.desc[-1].add_paragraph("This can be used to for comparison to Monte-Carlo simulations.") uf.desc[-1].add_paragraph("This method is inspired from the GNU Scientific Library (GSL).") uf.desc[-1].add_paragraph("The covariance matrix is given by: covar = Qxx = (J^T.W.J)^-1, where the weight matrix W is constructed by the multiplication of an Identity matrix I and a weight array w. The weight array is 1/errors^2, which then gives W = I.w = I x 1/errors^2.") uf.desc[-1].add_paragraph("Qxx is computed by QR decomposition, J^T.W.J=QR, Qxx=R^-1. Q^T. The columns of R which satisfy: |R_{kk}| <= epsrel |R_{11}| are considered linearly-dependent and are excluded from the covariance matrix (the corresponding rows and columns of the covariance matrix are set to zero).") uf.desc[-1].add_paragraph("The parameter 'epsrel' is used to remove linear-dependent columns when J is rank deficient.") -uf.backend = estimate_rx_err -uf.menu_text = "&rx_err_estimate" -uf.gui_icon = "relax.relax_fit" +uf.backend = covariance_matrix +uf.menu_text = "&covariance_matrix" uf.wizard_size = (800, 800) uf.wizard_image = ANALYSIS_IMAGE_PATH + sep + 'blank_150x150.png' - - -# The relax_fit.select_model user function. -uf = uf_info.add_uf('relax_fit.select_model') -uf.title = "Select the relaxation curve type." -uf.title_short = "Relaxation curve type selection." -uf.display = True -uf.add_keyarg( - name = "model", - default = "exp", - py_type = "str", - desc_short = "model", - desc = "The type of relaxation curve to fit.", - wiz_element_type = "combo", - wiz_combo_choices = [ - "exp: [Rx, I0]", - "inv: [Rx, I0, Iinf]" - ], - wiz_combo_data = [ - "exp", - "inv" - ], - wiz_read_only = True -) -# Description. -uf.desc.append(Desc_container()) -uf.desc[-1].add_paragraph("The supported relaxation experiments include the default two parameter exponential fit, selected by setting the model type to 'exp', and the three parameter inversion recovery experiment in which the peak intensity limit is a non-zero value, selected by setting the model to 'inv'.") -uf.desc[-1].add_paragraph("The parameters of these two models are") -uf.desc[-1].add_item_list_element("'exp'", "[Rx, I0],") -uf.desc[-1].add_item_list_element("'inv'", "[Rx, I0, Iinf].") -uf.backend = select_model -uf.menu_text = "&select_model" -uf.gui_icon = "oxygen.actions.list-add" -uf.wizard_height_desc = 300 -uf.wizard_size = (800, 500) -uf.wizard_apply_button = False Modified: trunk/user_functions/relax_fit.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/relax_fit.py?rev=25783&r1=25782&r2=25783&view=diff ============================================================================== --- trunk/user_functions/relax_fit.py (original) +++ trunk/user_functions/relax_fit.py Fri Sep 12 13:57:44 2014 @@ -70,50 +70,6 @@ uf.wizard_size = (700, 500) -# The relax_fit.rx_err_estimate user function. -uf = uf_info.add_uf('relax_fit.rx_err_estimate') -uf.title = "Estimate Rx errors by the Jacobian matrix." -uf.title_short = "Estimate Rx errors." -uf.add_keyarg( - name = "spin_id", - py_type = "str", - arg_type = "spin ID", - desc_short = "spin ID to restrict value setting to", - desc = "The spin ID string to restrict value setting to.", - can_be_none = True -) -uf.add_keyarg( - name = "epsrel", - py_type = "float", - default = 0.0, - desc_short = "parameter to remove linear-dependent columns.", - desc = "The parameter to remove linear-dependent columns when J is rank deficient.", - can_be_none = False -) -uf.add_keyarg( - name = "verbosity", - default = 1, - py_type = "int", - desc_short = "amount of information to print.", - desc = "The higher the value, the greater the verbosity.", - can_be_none = False -) -# Description. -uf.desc.append(Desc_container()) -uf.desc[-1].add_paragraph("This is a new experimental feature from version 3.3.") -uf.desc[-1].add_paragraph("This will estimate Rx errors by using the exponential decay Jacobian matrix 'J' to compute the covariance matrix of the best-fit parameters.") -uf.desc[-1].add_paragraph("This can be used to for comparison to Monte-Carlo simulations.") -uf.desc[-1].add_paragraph("This method is inspired from the GNU Scientific Library (GSL).") -uf.desc[-1].add_paragraph("The covariance matrix is given by: covar = Qxx = (J^T.W.J)^-1, where the weight matrix W is constructed by the multiplication of an Identity matrix I and a weight array w. The weight array is 1/errors^2, which then gives W = I.w = I x 1/errors^2.") -uf.desc[-1].add_paragraph("Qxx is computed by QR decomposition, J^T.W.J=QR, Qxx=R^-1. Q^T. The columns of R which satisfy: |R_{kk}| <= epsrel |R_{11}| are considered linearly-dependent and are excluded from the covariance matrix (the corresponding rows and columns of the covariance matrix are set to zero).") -uf.desc[-1].add_paragraph("The parameter 'epsrel' is used to remove linear-dependent columns when J is rank deficient.") -uf.backend = estimate_rx_err -uf.menu_text = "&rx_err_estimate" -uf.gui_icon = "relax.relax_fit" -uf.wizard_size = (800, 800) -uf.wizard_image = ANALYSIS_IMAGE_PATH + sep + 'blank_150x150.png' - - # The relax_fit.select_model user function. uf = uf_info.add_uf('relax_fit.select_model') uf.title = "Select the relaxation curve type."