mailr17754 - /branches/tensor_data/data/diff_tensor.py


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

Header


Content

Posted by edward on October 08, 2012 - 18:27:
Author: bugman
Date: Mon Oct  8 18:27:08 2012
New Revision: 17754

URL: http://svn.gna.org/viewcvs/relax?rev=17754&view=rev
Log:
Converted the diffusion tensor data structure from_xml() method to the new 
tensor design.


Modified:
    branches/tensor_data/data/diff_tensor.py

Modified: branches/tensor_data/data/diff_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/tensor_data/data/diff_tensor.py?rev=17754&r1=17753&r2=17754&view=diff
==============================================================================
--- branches/tensor_data/data/diff_tensor.py (original)
+++ branches/tensor_data/data/diff_tensor.py Mon Oct  8 18:27:08 2012
@@ -960,10 +960,50 @@
         """
 
         # First set the diffusion type.  Doing this first is essential for 
the proper reconstruction of the object.
-        setattr(self, 'type', str(diff_tensor_node.getAttribute('type')))
-
-        # Recreate all the other data structures.
-        xml_to_object(diff_tensor_node, self, file_version=file_version)
+        self.__dict__['type'] = str(diff_tensor_node.getAttribute('type'))
+
+        # A temporary object to pack the structures from the XML data into.
+        temp_obj = Element()
+
+        # Recreate all the other data structures (into the temporary object).
+        xml_to_object(diff_tensor_node, temp_obj, file_version=file_version)
+
+        # Loop over all modifiable objects in the temporary object and make 
soft copies of them.
+        for name in self._mod_attr:
+            # Skip if missing from the object.
+            if not hasattr(temp_obj, name):
+                continue
+
+            # The category.
+            if search('_err$', name):
+                category = 'err'
+                param = name.replace('_err', '')
+            elif search('_sim$', name):
+                category = 'sim'
+                param = name.replace('_sim', '')
+            else:
+                category = 'val'
+                param = name
+
+            # Get the object.
+            value = getattr(temp_obj, name)
+
+            # Normal parameters.
+            if category == 'val':
+                self.set(param=param, value=value)
+
+            # Errors.
+            elif category == 'err':
+                self.set(param=param, value=value, category='err')
+
+            # Simulation objects objects.
+            else:
+                # Recreate the list elements.
+                for i in range(len(value)):
+                    self.set(param=param, value=value[i], category='sim', 
sim_index=i)
+
+        # Delete the temporary object.
+        del temp_obj
 
 
     def set(self, param=None, value=None, category='val', sim_index=None):




Related Messages


Powered by MHonArc, Updated Mon Oct 08 19:00:01 2012