mailr19753 - in /branches/relax_disp: specific_analyses/relax_disp/__init__.py user_functions/relax_disp.py


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

Header


Content

Posted by edward on May 28, 2013 - 11:37:
Author: bugman
Date: Tue May 28 11:37:19 2013
New Revision: 19753

URL: http://svn.gna.org/viewcvs/relax?rev=19753&view=rev
Log:
Created the relax_disp.r2eff_setup user function.

This is required to set the number of Bootstrapping simulations to use in the 
calc user function.
It replaces the hardcoded variable.


Modified:
    branches/relax_disp/specific_analyses/relax_disp/__init__.py
    branches/relax_disp/user_functions/relax_disp.py

Modified: branches/relax_disp/specific_analyses/relax_disp/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/__init__.py?rev=19753&r1=19752&r2=19753&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/__init__.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/__init__.py Tue May 28 
11:37:19 2013
@@ -685,6 +685,17 @@
         add_result_file(type='grace', label='Grace', file=file_path)
 
 
+    def _r2eff_setup(self, sim_num=100000):
+        """Setup the R2eff/R1rho model.
+
+        @keyword sim_num:   The number of Bootstrapping simulations for 
error propagation for the fixed relaxation time period experiments.
+        @type sim_num:      int
+        """
+
+        # Set the value.
+        cdp.bootstrap_sim_num = sim_num
+
+
     def _select_model(self, model=MODEL_R2EFF):
         """Set up the model for the relaxation dispersion analysis.
 
@@ -820,12 +831,13 @@
         if cdp.exp_type not in FIXED_TIME_EXP:
             raise RelaxError("The experiment '%s' is not of the fixed 
relaxation time period data type, the R2eff/R1rho values cannot be directly 
calculated." % cdp.exp_type)
 
-        # FIXME: Simulation number hardcoded variable.
-        sim_num = 100000
+        # Check the simulation number.
+        if not hasattr(cdp, 'bootstrap_sim_num'):
+            raise RelaxError("The Bootstrapping simulation number has not 
been specified, please use the R2eff/R1rho setup user function first.")
 
         # Printouts.
         print("Calculating the R2eff/R1rho values for fixed relaxation time 
period data.")
-        print("Error propagation using Bootstrapping with %i simulations." % 
sim_num)
+        print("Error propagation using Bootstrapping with %i simulations." % 
cdp.bootstrap_sim_num)
 
         # Loop over the spins.
         for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
@@ -841,7 +853,7 @@
                 spin.r2eff = {}
             if not hasattr(spin, 'r2eff_sim'):
                 spin.r2eff_sim = []
-                for i in range(sim_num):
+                for i in range(cdp.bootstrap_sim_num):
                     spin.r2eff_sim.append({})
             if not hasattr(spin, 'r2eff_err'):
                 spin.r2eff_err = {}
@@ -877,7 +889,7 @@
 
                 # Bootstrapping error propagation.
                 values = []
-                for i in range(sim_num):
+                for i in range(cdp.bootstrap_sim_num):
                     # Randomise the data.
                     I_ref = gauss(ref_intensity, ref_intensity_err)
                     I = gauss(intensity, intensity_err)

Modified: branches/relax_disp/user_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=19753&r1=19752&r2=19753&view=diff
==============================================================================
--- branches/relax_disp/user_functions/relax_disp.py (original)
+++ branches/relax_disp/user_functions/relax_disp.py Tue May 28 11:37:19 2013
@@ -311,6 +311,30 @@
 uf.gui_icon = "oxygen.actions.document-save"
 uf.wizard_size = (800, 600)
 uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png'
+
+
+# The relax_disp.r2eff_setup user function.
+uf = uf_info.add_uf('relax_disp.r2eff_setup')
+uf.title = "Setup for the R2eff/R1rho model."
+uf.title_short = "R2eff/R1rho model setup."
+uf.add_keyarg(
+    name = "sim_num",
+    default = 100000,
+    min = 3,
+    max = 1000000000,
+    py_type = "int",
+    desc_short = "Bootstrapping simulation number",
+    desc = "The number of Bootstrapping simulations for error propagation."
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("This is used to setup the variables required for 
the calculation of the R2eff/R1rho values.  Currently only the number of 
Bootstrapping simulations for error propagation needs to be given.  This is 
only required for calculating the R2eff/R1rho values for fixed relaxation 
time period data, if full relaxation curves have been collected then this 
value will be ignored.")
+uf.backend = relax_disp_obj._r2eff_setup
+uf.menu_text = "&r2eff_setup"
+uf.gui_icon = "oxygen.actions.edit-rename"
+uf.wizard_size = (800, 500)
+uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png'
+uf.wizard_apply_button = False
 
 
 # The relax_disp.relax_time user function.




Related Messages


Powered by MHonArc, Updated Tue May 28 12:00:04 2013