mailr10071 - in /1.3: generic_fns/pcs.py prompt/pcs.py


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

Header


Content

Posted by edward on December 08, 2009 - 15:44:
Author: bugman
Date: Tue Dec  8 15:44:24 2009
New Revision: 10071

URL: http://svn.gna.org/viewcvs/relax?rev=10071&view=rev
Log:
The atomic position can now be directly supplied to pcs.centre().


Modified:
    1.3/generic_fns/pcs.py
    1.3/prompt/pcs.py

Modified: 1.3/generic_fns/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pcs.py?rev=10071&r1=10070&r2=10071&view=diff
==============================================================================
--- 1.3/generic_fns/pcs.py (original)
+++ 1.3/generic_fns/pcs.py Tue Dec  8 15:44:24 2009
@@ -135,9 +135,11 @@
         spin.relax_sim_data.append(values)
 
 
-def centre(atom_id=None, pipe=None, ave_pos=False):
+def centre(pos=None, atom_id=None, pipe=None, ave_pos=False):
     """Specify the atom in the loaded structure corresponding to the 
paramagnetic centre.
 
+    @keyword pos:       The atomic position.  If set, the atom_id string 
will be ignored.
+    @type pos:          list of float
     @keyword atom_id:   The atom identification string.
     @type atom_id:      str
     @keyword pipe:      An alternative data pipe to extract the paramagnetic 
centre from.
@@ -165,30 +167,38 @@
     if hasattr(cdp, 'paramagnetic_centre'):
         raise RelaxError("The paramagnetic centre has already been set to 
the coordinates " + repr(cdp.paramagnetic_centre) + ".")
 
-    # Get the positions.
-    centre = zeros(3, float64)
-    full_pos_list = []
-    num_pos = 0
-    for spin, spin_id in spin_loop(atom_id, pipe=pipe, return_id=True):
-        # No atomic positions.
-        if not hasattr(spin, 'pos'):
-            continue
-
-        # Spin position list.
-        if isinstance(spin.pos[0], float) or isinstance(spin.pos[0], 
float64):
-            pos_list = [spin.pos]
-        else:
-            pos_list = spin.pos
-
-        # Loop over the model positions.
-        for pos in pos_list:
-            full_pos_list.append(pos)
-            centre = centre + array(pos)
-            num_pos = num_pos + 1
-
-    # No positional information!
-    if not num_pos:
-        raise RelaxError("No positional information could be found for the 
spin '%s'." % atom_id)
+    # Position is supplied.
+    if pos:
+        centre = array(pos)
+        num_pos = 1
+        full_pos_list = []
+
+    # Position from a loaded structure.
+    else:
+        # Get the positions.
+        centre = zeros(3, float64)
+        full_pos_list = []
+        num_pos = 0
+        for spin, spin_id in spin_loop(atom_id, pipe=pipe, return_id=True):
+            # No atomic positions.
+            if not hasattr(spin, 'pos'):
+                continue
+    
+            # Spin position list.
+            if isinstance(spin.pos[0], float) or isinstance(spin.pos[0], 
float64):
+                pos_list = [spin.pos]
+            else:
+                pos_list = spin.pos
+    
+            # Loop over the model positions.
+            for pos in pos_list:
+                full_pos_list.append(pos)
+                centre = centre + array(pos)
+                num_pos = num_pos + 1
+    
+        # No positional information!
+        if not num_pos:
+            raise RelaxError("No positional information could be found for 
the spin '%s'." % atom_id)
 
     # Averaging.
     centre = centre / float(num_pos)

Modified: 1.3/prompt/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/pcs.py?rev=10071&r1=10070&r2=10071&view=diff
==============================================================================
--- 1.3/prompt/pcs.py (original)
+++ 1.3/prompt/pcs.py Tue Dec  8 15:44:24 2009
@@ -59,11 +59,13 @@
         pcs.back_calc(align_id=align_id)
 
 
-    def centre(self, atom_id=None, pipe=None, ave_pos=True):
+    def centre(self, pos=None, atom_id=None, pipe=None, ave_pos=True):
         """Specify which atom is the paramagnetic centre.
 
         Keyword Arguments
         ~~~~~~~~~~~~~~~~~
+
+        pos:  The atomic position.
 
         atom_id:  The atom ID string.
 
@@ -103,23 +105,30 @@
         centre, then type:
 
         relax> pcs.centre(':4@C1')
+        
+        To state that the Dy3+ atomic position is [0.136, 12.543, 4.356], 
type one of:
+
+        relax> pcs.centre([0.136, 12.543, 4.356])
+        relax> pcs.centre(pos=[0.136, 12.543, 4.356])
         """
 
         # Function intro text.
         if self.__relax__.interpreter.intro:
             text = sys.ps3 + "pcs.centre("
-            text = text + "atom_id=" + repr(atom_id)
+            text = text + "pos=" + repr(pos)
+            text = text + ", atom_id=" + repr(atom_id)
             text = text + ", pipe=" + repr(pipe)
             text = text + ", ave_pos=" + repr(ave_pos) + ")"
             print(text)
 
         # The argument checks.
-        arg_check.is_str(atom_id, 'atom ID string')
+        arg_check.is_num_list(pos, 'atomic position', can_be_none=True)
+        arg_check.is_str(atom_id, 'atom ID string', can_be_none=True)
         arg_check.is_str(pipe, 'data pipe', can_be_none=True)
         arg_check.is_bool(ave_pos, 'average position flag')
 
         # Execute the functional code.
-        pcs.centre(atom_id=atom_id, pipe=pipe, ave_pos=ave_pos)
+        pcs.centre(pos=pos, atom_id=atom_id, pipe=pipe, ave_pos=ave_pos)
 
 
     def copy(self, pipe_from=None, pipe_to=None, align_id=None):




Related Messages


Powered by MHonArc, Updated Tue Dec 08 17:00:02 2009