mailr19777 - 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 29, 2013 - 17:53:
Author: bugman
Date: Wed May 29 17:53:30 2013
New Revision: 19777

URL: http://svn.gna.org/viewcvs/relax?rev=19777&view=rev
Log:
Implemented a basic graph for the relax_disp.plot_disp_curves user function.

This simply plots out the nu_CPMG value or spin-lock field verses the 
R2eff/R1rho values from the
experiment.  The graph of the back calculated R2eff/R1rho values from the 
model fit is still to be
added.


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=19777&r1=19776&r2=19777&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/__init__.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/__init__.py Wed May 29 
17:53:30 2013
@@ -604,6 +604,86 @@
             self.data_init(spin)
 
 
+    def _plot_disp_curves(self, dir=None, force=None):
+        """Custom 2D Grace plotting function for the dispersion curves.
+
+        One file will be created per spin system.
+
+
+        @keyword dir:           The optional directory to place the file 
into.
+        @type dir:              str
+        @param force:           Boolean argument which if True causes the 
files to be overwritten if it already exists.
+        @type force:            bool
+        """
+
+        # Test if the current pipe exists.
+        pipes.test()
+
+        # Test if the sequence data is loaded.
+        if not exists_mol_res_spin_data():
+            raise RelaxNoSequenceError
+
+        # Loop over each spin.
+        for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
+            # Open the file for writing.
+            file_name = "disp_%s.agr" % spin_id
+            file_path = get_file_path(file_name, dir)
+            file = open_write_file(file_name, dir, force)
+
+            # Initialise some data structures.
+            data = []
+            set_labels = []
+            x_err_flag = False
+            y_err_flag = False
+
+            # Add a new set for the measured data.
+            data.append([])
+
+            # Loop over the spectrometer frequencies.
+            graph_index = 0
+            err = False
+            for frq in loop_frq():
+                # Loop over the dispersion points.
+                for disp_point in loop_point():
+                    # The data key.
+                    key = return_param_key_from_data(frq=frq, 
point=disp_point)
+
+                    # No data present.
+                    if key not in spin.r2eff:
+                        continue
+
+                    # Add the data.
+                    data[-1].append([disp_point, spin.r2eff[key]])
+
+                    # Add the error.
+                    if hasattr(spin, 'r2eff_err') and key in spin.r2eff_err:
+                        err = True
+                        data[-1][-1].append(spin.r2eff_err[key])
+
+            # FIXME:  Add the back-calculated data as a second set.
+
+            # The axis labels.
+            if cdp.exp_type == 'CPMG':
+                axis_labels = ['\\qCPMG pulse train frequency (Hz)\\Q', 
'\\qR\\s2,eff\\N\\Q (rad.s\\S-1\\N)']
+            else:
+                axis_labels = ['\\qSpin-lock field strength (Hz)\\Q', 
'\\qR\\s1\\xr\\B\\N\\Q (rad.s\\S-1\\N)']
+
+            # Write the header.
+            write_xy_header(sets=len(data), file=file, set_names=set_labels, 
axis_labels=axis_labels)
+
+            # Write the data.
+            graph_type = 'xy'
+            if err:
+                graph_type = 'xydy'
+            write_xy_data([data], file=file, graph_type=graph_type)
+
+            # Close the file.
+            file.close()
+
+            # Add the file to the results file list.
+            add_result_file(type='grace', label='Grace', file=file_path)
+
+
     def _plot_exp_curves(self, file=None, dir=None, force=None, norm=None):
         """Custom 2D Grace plotting function for the exponential curves.
 
@@ -625,7 +705,6 @@
             raise RelaxNoSequenceError
 
         # Open the file for writing.
-
         file_path = get_file_path(file, dir)
         file = open_write_file(file, dir, force)
 

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=19777&r1=19776&r2=19777&view=diff
==============================================================================
--- branches/relax_disp/user_functions/relax_disp.py (original)
+++ branches/relax_disp/user_functions/relax_disp.py Wed May 29 17:53:30 2013
@@ -303,6 +303,36 @@
 uf.wizard_size = (800, 600)
 uf.wizard_apply_button = False
 uf.wizard_image = WIZARD_IMAGE_PATH + 'nessy.png'
+
+
+# The relax_disp.plot_disp_curves user function.
+uf = uf_info.add_uf('relax_disp.plot_disp_curves')
+uf.title = "Create 2D Grace plots of the dispersion curves for each spin 
system."
+uf.title_short = "Dispersion curve plotting."
+uf.add_keyarg(
+    name = "dir",
+    default = "grace",
+    py_type = "str",
+    arg_type = "dir",
+    desc_short = "directory name",
+    desc = "The directory name to place all of the spin system files into.",
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "force",
+    default = False,
+    py_type = "bool",
+    desc_short = "force flag",
+    desc = "A flag which, if set to True, will cause the files to be 
overwritten."
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("This is used to created 2D Grace plots of the 
dispersion curves of the spin-lock field strength or nu_CPMG frequencies 
verses R2eff/R1rho.  One file will be created per spin system with the name 
'disp_x.agr', where x is the spin ID string.")
+uf.backend = relax_disp_obj._plot_disp_curves
+uf.menu_text = "&plot_disp_curves"
+uf.gui_icon = "oxygen.actions.document-save"
+uf.wizard_size = (700, 500)
+uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png'
 
 
 # The relax_disp.plot_exp_curves user function.




Related Messages


Powered by MHonArc, Updated Wed May 29 18:20:02 2013