mailr11296 - in /1.3: prompt/n_state_model.py specific_fns/n_state_model.py


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

Header


Content

Posted by edward on July 08, 2010 - 15:26:
Author: bugman
Date: Thu Jul  8 15:26:24 2010
New Revision: 11296

URL: http://svn.gna.org/viewcvs/relax?rev=11296&view=rev
Log:
Created the n_state_model.elim_no_prob() to remove structures with zero 
probability.


Modified:
    1.3/prompt/n_state_model.py
    1.3/specific_fns/n_state_model.py

Modified: 1.3/prompt/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/n_state_model.py?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- 1.3/prompt/n_state_model.py (original)
+++ 1.3/prompt/n_state_model.py Thu Jul  8 15:26:24 2010
@@ -163,6 +163,26 @@
         n_state_model_obj._cone_pdb(cone_type=cone_type, scale=scale, 
file=file, dir=dir, force=force)
 
 
+    def elim_no_prob(self):
+        """Eliminate the structures or states with no probability.
+
+        Examples
+        ~~~~~~~~
+
+        Simply type:
+
+        relax> n_state_model.elim_no_prob(N=8)
+        """
+
+        # Function intro text.
+        if self._exec_info.intro:
+            text = self._exec_info.ps3 + "n_state_model.elim_no_prob()"
+            print(text)
+
+        # Execute the functional code.
+        n_state_model_obj._elim_no_prob()
+
+
     def number_of_states(self, N=None):
         """Set the number of states in the N-state model.
 

Modified: 1.3/specific_fns/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/n_state_model.py?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- 1.3/specific_fns/n_state_model.py (original)
+++ 1.3/specific_fns/n_state_model.py Thu Jul  8 15:26:24 2010
@@ -542,6 +542,57 @@
             cdp.paramagnetic_centre[0] = param_vector[-3]
             cdp.paramagnetic_centre[1] = param_vector[-2]
             cdp.paramagnetic_centre[2] = param_vector[-1]
+
+
+    def _elim_no_prob(self):
+        """Remove all structures or states which have no probability."""
+
+        # Test if the current data pipe exists.
+        pipes.test()
+
+        # Test if the model is setup.
+        if not hasattr(cdp, 'model'):
+            raise RelaxNoModelError('N-state')
+
+        # Test if there are populations.
+        if not hasattr(cdp, 'probs'):
+            raise RelaxError("The N-state model populations do not exist.")
+
+        # Loop over the structures.
+        i = 0
+        while 1:
+            # End condition.
+            if i == cdp.N - 1:
+                break
+
+            # No probability.
+            if cdp.probs[i] < 1e-5:
+                # Remove the probability.
+                cdp.probs.pop(i)
+
+                # Remove the structure.
+                cdp.structure.structural_data.pop(i)
+
+                # Eliminate bond vectors.
+                for spin in spin_loop():
+                    # Position info.
+                    if hasattr(spin, 'pos'):
+                        spin.pos.pop(i)
+
+                    # Vector info.
+                    if hasattr(spin, 'xh_vect'):
+                        spin.xh_vect.pop(i)
+                    if hasattr(spin, 'bond_vect'):
+                        spin.bond_vect.pop(i)
+
+                # Update N.
+                cdp.N -= 1
+
+                # Start the loop again without incrementing i.
+                continue
+
+            # Increment i.
+            i += 1
 
 
     def _linear_constraints(self, data_types=None, scaling_matrix=None):




Related Messages


Powered by MHonArc, Updated Tue Jul 13 01:40:02 2010