mailr19951 - in /branches/relax_disp: auto_analyses/ specific_analyses/relax_disp/


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

Header


Content

Posted by edward on June 07, 2013 - 16:31:
Author: bugman
Date: Fri Jun  7 16:31:35 2013
New Revision: 19951

URL: http://svn.gna.org/viewcvs/relax?rev=19951&view=rev
Log:
Removed cdp.model as this makes no sense - a different model can be used per 
spin cluster.

Now the variable cdp.model_type is used to identify the 'R2eff' model.  For 
all other dispersion
models this variable is set to 'Disp'.


Modified:
    branches/relax_disp/auto_analyses/relax_disp.py
    branches/relax_disp/specific_analyses/relax_disp/__init__.py
    branches/relax_disp/specific_analyses/relax_disp/cpmgfit.py
    branches/relax_disp/specific_analyses/relax_disp/nessy.py
    branches/relax_disp/specific_analyses/relax_disp/parameters.py
    branches/relax_disp/specific_analyses/relax_disp/sherekhan.py

Modified: branches/relax_disp/auto_analyses/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/auto_analyses/relax_disp.py?rev=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/auto_analyses/relax_disp.py (original)
+++ branches/relax_disp/auto_analyses/relax_disp.py Fri Jun  7 16:31:35 2013
@@ -192,7 +192,7 @@
                 self.optimise()
 
             # Write out the results.
-            self.write_results(path=self.results_dir+sep+model)
+            self.write_results(path=self.results_dir+sep+model, model=model)
 
         # Perform model selection, writing out the final results.
         if len(model_pipes) >= 2:
@@ -204,7 +204,7 @@
             warn(RelaxWarning("Model selection in the dispersion 
auto-analysis has been skipped as only %s models have been optimised." % 
len(model_pipes)))
 
 
-    def write_results(self, path=None):
+    def write_results(self, path=None, model=None):
         """Create a set of results, text and Grace files for the current 
data pipe.
 
         @keyword path:  The directory to place the files into.
@@ -215,7 +215,7 @@
         self.interpreter.results.write(file='results', dir=path, force=True)
 
         # Exponential curves.
-        if cdp.model == MODEL_R2EFF and cdp.exp_type not in FIXED_TIME_EXP:
+        if cdp.model_type == 'R2eff' and cdp.exp_type not in FIXED_TIME_EXP:
             
self.interpreter.relax_disp.plot_exp_curves(file='intensities.agr', dir=path, 
force=True)    # Average peak intensities.
             
self.interpreter.relax_disp.plot_exp_curves(file='intensities_norm.agr', 
dir=path, force=True, norm=True)    # Average peak intensities (normalised).
 
@@ -223,20 +223,20 @@
         self.interpreter.relax_disp.plot_disp_curves(dir=path, force=True)
 
         # The R2eff parameter.
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             self.interpreter.value.write(param='r2eff', file='r2eff.out', 
dir=path, force=True)
             self.interpreter.grace.write(x_data_type='res_num', 
y_data_type='r2eff', file='r2eff.agr', dir=path, force=True)
 
         # The I0 parameter.
-        if cdp.model == MODEL_R2EFF and cdp.exp_type not in FIXED_TIME_EXP:
+        if cdp.model_type == 'R2eff' and cdp.exp_type not in FIXED_TIME_EXP:
             self.interpreter.value.write(param='i0', file='i0.out', 
dir=path, force=True)
             self.interpreter.grace.write(x_data_type='res_num', 
y_data_type='i0', file='i0.agr', dir=path, force=True)
 
         # The Phi_ex parameter.
-        if cdp.model in [MODEL_LM63]:
+        if model in [None, MODEL_LM63]:
             self.interpreter.value.write(param='phi_ex', file='phi_ex.out', 
dir=path, force=True)
             self.interpreter.grace.write(x_data_type='res_num', 
y_data_type='phi_ex', file='phi_ex.agr', dir=path, force=True)
 
         # Minimisation statistics.
-        if not (cdp.model == MODEL_R2EFF and cdp.exp_type in FIXED_TIME_EXP):
+        if not (cdp.model_type == 'R2eff' and cdp.exp_type in 
FIXED_TIME_EXP):
             self.interpreter.grace.write(y_data_type='chi2', 
file='chi2.agr', dir=path, force=True)

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=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/__init__.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/__init__.py Fri Jun  7 
16:31:35 2013
@@ -135,7 +135,7 @@
         values, errors, missing, frqs = return_r2eff_arrays(spins=[spin], 
spin_ids=[spin_id], fields=fields, field_count=field_count)
 
         # Initialise the relaxation dispersion fit functions.
-        model = Dispersion(model=cdp.model, 
num_params=param_num(spins=[spin]), num_spins=1, num_frq=field_count, 
num_disp_points=cdp.dispersion_points, values=values, errors=errors, 
missing=missing, frqs=frqs, cpmg_frqs=return_cpmg_frqs(ref_flag=False), 
spin_lock_nu1=return_spin_lock_nu1(ref_flag=False), 
scaling_matrix=scaling_matrix)
+        model = Dispersion(model=spin.model, 
num_params=param_num(spins=[spin]), num_spins=1, num_frq=field_count, 
num_disp_points=cdp.dispersion_points, values=values, errors=errors, 
missing=missing, frqs=frqs, cpmg_frqs=return_cpmg_frqs(ref_flag=False), 
spin_lock_nu1=return_spin_lock_nu1(ref_flag=False), 
scaling_matrix=scaling_matrix)
 
         # Make a single function call.  This will cause back calculation and 
the data will be stored in the class instance.
         model.func(param_vector)
@@ -356,7 +356,7 @@
             upper = []
 
             # The R2eff model.
-            if cdp.model == MODEL_R2EFF:
+            if cdp.model_type == 'R2eff':
                 for spin_index in range(len(spins)):
                     # Alias the spin.
                     spin = spins[spin_index]
@@ -588,15 +588,14 @@
         @type params:   list of str
         """
 
-        # Set the model.
-        cdp.model = model
+        # The model group.
+        if model == MODEL_R2EFF:
+            cdp.model_type = 'R2eff'
+        else:
+            cdp.model_type = 'disp'
 
         # Loop over the sequence.
-        for spin in spin_loop():
-            # Skip deselected spins.
-            if not spin.select:
-                continue
-
+        for spin in spin_loop(skip_desel=True):
             # The model and parameter names.
             spin.model = model
             spin.params = params
@@ -930,7 +929,7 @@
         """
 
         # The R2eff model data (the base data is peak intensities).
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             # Loop over the sequence.
             for spin in spin_loop():
                 # Skip deselected spins.
@@ -984,7 +983,7 @@
             raise RelaxError("The relaxation dispersion experiment type has 
not been specified.")
 
         # Test if the model has been set.
-        if not hasattr(cdp, 'model'):
+        if not hasattr(cdp, 'model_type'):
             raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
         # Test if the curve count exists.
@@ -1070,7 +1069,7 @@
         """
 
         # The R2eff model (with peak intensity base data).
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             # Unpack the data.
             spin, frq, point = data_id
 
@@ -1115,7 +1114,11 @@
         # Duplicate all non-sequence specific data.
         for data_name in dir(dp_from):
             # Skip the container objects.
-            if data_name in ['mol', 'interatomic', 'structure', 'exp_info']:
+            if data_name in ['mol', 'interatomic', 'structure', 'exp_info', 
'result_files']:
+                continue
+
+            # Skip dispersion specific parameters.
+            if data_name in ['model']:
                 continue
 
             # Skip special objects.
@@ -1230,7 +1233,7 @@
             raise RelaxError("The relaxation dispersion experiment type has 
not been specified.")
 
         # Test if the model has been set.
-        if not hasattr(cdp, 'model'):
+        if not hasattr(cdp, 'model_type'):
             raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
         # Test if the curve count exists.
@@ -1240,10 +1243,6 @@
             elif cdp.exp_type == 'r1rho':
                 raise RelaxError("The spin-lock field strengths have not 
been set up.")
 
-        # Test if the spectrometer frequencies have been set.
-        if cdp.model in [MODEL_LM63, MODEL_CR72, MODEL_M61] and not 
hasattr(cdp, 'spectrometer_frq'):
-            raise RelaxError("The spectrometer frequency information has not 
been specified.")
-
         # Initialise some empty data pipe structures so that the target 
function set up does not fail.
         if not hasattr(cdp, 'cpmg_frqs_list'):
             cdp.cpmg_frqs_list = []
@@ -1251,7 +1250,7 @@
             cdp.spin_lock_nu1_list = []
 
         # Special exponential curve-fitting for the 'R2eff' model.
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             # Sanity checks.
             if cdp.exp_type in FIXED_TIME_EXP:
                 raise RelaxError("The R2eff model with the fixed time period 
CPMG experiment cannot be optimised.")
@@ -1278,6 +1277,10 @@
         for spin_ids in self.model_loop():
             # The spin containers.
             spins = spin_ids_to_containers(spin_ids)
+
+            # Test if the spectrometer frequencies have been set.
+            if spins[0].model in [MODEL_LM63, MODEL_CR72, MODEL_M61] and not 
hasattr(cdp, 'spectrometer_frq'):
+                raise RelaxError("The spectrometer frequency information has 
not been specified.")
 
             # The R2eff/R1rho data.
             values, errors, missing, frqs = return_r2eff_arrays(spins=spins, 
spin_ids=spin_ids, fields=fields, field_count=field_count)
@@ -1313,7 +1316,7 @@
                     print("Unconstrained grid search size: %s (constraints 
may decrease this size).\n" % grid_size)
 
             # Initialise the function to minimise.
-            model = Dispersion(model=cdp.model, 
num_params=param_num(spins=spins), num_spins=len(spins), num_frq=field_count, 
num_disp_points=cdp.dispersion_points, values=values, errors=errors, 
missing=missing, frqs=frqs, cpmg_frqs=return_cpmg_frqs(ref_flag=False), 
spin_lock_nu1=return_spin_lock_nu1(ref_flag=False), 
scaling_matrix=scaling_matrix)
+            model = Dispersion(model=spins[0].model, 
num_params=param_num(spins=spins), num_spins=len(spins), num_frq=field_count, 
num_disp_points=cdp.dispersion_points, values=values, errors=errors, 
missing=missing, frqs=frqs, cpmg_frqs=return_cpmg_frqs(ref_flag=False), 
spin_lock_nu1=return_spin_lock_nu1(ref_flag=False), 
scaling_matrix=scaling_matrix)
 
             # Grid search.
             if search('^[Gg]rid', min_algor):
@@ -1543,7 +1546,7 @@
         """
 
         # The R2eff model.
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             # Unpack the data.
             spin, frq, point = data_id
 
@@ -1632,7 +1635,7 @@
         """
 
         # The R2eff model (with peak intensity base data).
-        if cdp.model == MODEL_R2EFF:
+        if cdp.model_type == 'R2eff':
             # Unpack the data.
             spin, frq, point = data_id
 

Modified: branches/relax_disp/specific_analyses/relax_disp/cpmgfit.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/cpmgfit.py?rev=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/cpmgfit.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/cpmgfit.py Fri Jun  7 
16:31:35 2013
@@ -67,20 +67,18 @@
         raise RelaxError("The relaxation dispersion experiment type has not 
been specified.")
 
     # Test if the model has been set.
-    if not hasattr(cdp, 'model'):
+    if not hasattr(cdp, 'model_type'):
         raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
-    # Translate the model.
-    function = translate_model()
-
     # The directory.
-    if dir == None:
-        dir = cdp.model.lower()
-    if not access(dir, F_OK):
+    if dir != None and not access(dir, F_OK):
         raise RelaxDirError('CPMGFit', dir)
 
     # Loop over each spin.
     for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
+        # Translate the model.
+        function = translate_model(spin.model)
+
         # The spin input file name.
         file_in = dir + sep + spin_file_name(spin_id=spin_id)
         if not access(file_in, F_OK):
@@ -144,16 +142,12 @@
         raise RelaxError("The relaxation dispersion experiment type has not 
been specified.")
 
     # Test if the model has been set.
-    if not hasattr(cdp, 'model'):
+    if not hasattr(cdp, 'model_type'):
         raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
-    # Translate the model.
-    function = translate_model()
-
     # Directory creation.
-    if dir == None:
-        dir = cdp.model.lower()
-    mkdir_nofail(dir, verbosity=0)
+    if dir != None:
+        mkdir_nofail(dir, verbosity=0)
 
     # The 'run.sh' script.
     batch = open_write_file('batch_run.sh', dir, force)
@@ -161,6 +155,9 @@
 
     # Generate the input files for each spin.
     for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
+        # Translate the model.
+        function = translate_model(spin.model)
+
         # Create the input file.
         file_in = create_spin_input(function=function, spin=spin, 
spin_id=spin_id, dir=dir)
 
@@ -279,7 +276,7 @@
     return name
 
 
-def translate_model():
+def translate_model(model):
     """Translate the dispersion model from relax notation to CPMGFit 
notation.
 
     @return:    The CPMGFit model name.
@@ -293,11 +290,11 @@
     }
 
     # No translation, so fail.
-    if cdp.model not in translation:
-        raise RelaxError("The conversion of the relax model '%s' to a 
CPMGFit model is not supported." % cdp.model)
+    if model not in translation:
+        raise RelaxError("The conversion of the relax model '%s' to a 
CPMGFit model is not supported." % model)
 
     # Printout.
-    print("Translating the relax '%s' model to the CPMGFit '%s' model." % 
(cdp.model, translation[cdp.model]))
+    print("Translating the relax '%s' model to the CPMGFit '%s' model." % 
(model, translation[model]))
 
     # Return the translated name.
-    return translation[cdp.model]
+    return translation[model]

Modified: branches/relax_disp/specific_analyses/relax_disp/nessy.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/nessy.py?rev=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/nessy.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/nessy.py Fri Jun  7 
16:31:35 2013
@@ -60,7 +60,7 @@
         raise RelaxError("The relaxation dispersion experiment type has not 
been specified.")
 
     # Test if the model has been set.
-    if not hasattr(cdp, 'model'):
+    if not hasattr(cdp, 'model_type'):
         raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
     # Directory creation.

Modified: branches/relax_disp/specific_analyses/relax_disp/parameters.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/parameters.py?rev=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/parameters.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/parameters.py Fri Jun  7 
16:31:35 2013
@@ -51,7 +51,7 @@
     param_vector = []
 
     # The R2eff model parameters.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         for spin_index in range(len(spins)):
             # Alias the spin.
             spin = spins[spin_index]
@@ -197,7 +197,7 @@
         return scaling_matrix
 
     # The R2eff model.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         for spin_index in range(len(spins)):
             # Alias the spin.
             spin = spins[spin_index]
@@ -272,7 +272,7 @@
     param_index = 0
 
     # The R2eff model.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         for spin_index in range(len(spins)):
             # Alias the spin.
             spin = spins[spin_index]
@@ -454,7 +454,7 @@
     j = 0
 
     # The R2eff model.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         # Only use the parameters of the first spin of the cluster.
         spin = spins[0]
         for i in range(n):
@@ -549,7 +549,7 @@
     spin_index = 0
 
     # The R2eff model.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         # The number of spin specific parameters (R2eff and I0 per spin).
         num = len(spins) * 2
 
@@ -582,7 +582,7 @@
     """
 
     # The R2eff model.
-    if cdp.model == MODEL_R2EFF:
+    if cdp.model_type == 'R2eff':
         # Exponential curves (with clustering).
         if cdp.exp_type in VAR_TIME_EXP:
             return 2 * len(spins)

Modified: branches/relax_disp/specific_analyses/relax_disp/sherekhan.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/sherekhan.py?rev=19951&r1=19950&r2=19951&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/sherekhan.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/sherekhan.py Fri Jun  7 
16:31:35 2013
@@ -64,7 +64,7 @@
         raise RelaxError("The relaxation dispersion experiment type has not 
been specified.")
 
     # Test if the model has been set.
-    if not hasattr(cdp, 'model'):
+    if not hasattr(cdp, 'model_type'):
         raise RelaxError("The relaxation dispersion model has not been 
specified.")
 
     # Test that this is a fixed time period experiment.




Related Messages


Powered by MHonArc, Updated Fri Jun 07 17:20:02 2013