mailr6774 - in /1.3/data: mol_res_spin.py relax_xml.py


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

Header


Content

Posted by edward on July 06, 2008 - 02:23:
Author: bugman
Date: Sun Jul  6 01:35:04 2008
New Revision: 6774

URL: http://svn.gna.org/viewcvs/relax?rev=6774&view=rev
Log:
Modified the XML results files to store higher precision versions of the 
floats.

The float is stored as an IEEE-754 byte array in the XML attribute 
ieee_754_byte_array.


Modified:
    1.3/data/mol_res_spin.py
    1.3/data/relax_xml.py

Modified: 1.3/data/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=6774&r1=6773&r2=6774&view=diff
==============================================================================
--- 1.3/data/mol_res_spin.py (original)
+++ 1.3/data/mol_res_spin.py Sun Jul  6 01:35:04 2008
@@ -25,10 +25,12 @@
 
 # Python module imports.
 from copy import deepcopy
+import numpy
 from re import match
 
 # relax module imports.
 import data
+from float import floatAsByteArray
 from prototype import Prototype
 from relax_errors import RelaxError, RelaxFromXMLNotEmptyError
 from relax_xml import fill_object_contents, xml_to_object
@@ -265,8 +267,15 @@
                 if desc:
                     sub_element.setAttribute('desc', desc)
 
+                # Get the object.
+                object = getattr(self[i], name)
+
+                # Store floats as IEEE-754 byte arrays, for higher precision.
+                if type(object) == float or type(object) == numpy.float64:
+                    sub_element.setAttribute('ieee_754_byte_array', 
`floatAsByteArray(object)`)
+
                 # Add the text value to the sub element.
-                text_val = doc.createTextNode(`getattr(self[i], name)`)
+                text_val = doc.createTextNode(`object`)
                 sub_element.appendChild(text_val)
 
             # Add all simple python objects within the SpinContainer to the 
XML element.

Modified: 1.3/data/relax_xml.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/relax_xml.py?rev=6774&r1=6773&r2=6774&view=diff
==============================================================================
--- 1.3/data/relax_xml.py (original)
+++ 1.3/data/relax_xml.py Sun Jul  6 01:35:04 2008
@@ -24,9 +24,12 @@
 """Module containing generic fns for creation and parsing of XML 
representations of python objects."""
 
 # Python module imports.
-from numpy import array
+from numpy import array, float64
 from re import search
 from string import strip
+
+# relax module imports.
+from float import floatAsByteArray
 
 
 def fill_object_contents(doc, elem, object=None, blacklist=None):
@@ -60,8 +63,15 @@
         sub_elem = doc.createElement(name)
         elem.appendChild(sub_elem)
 
+        # Get the sub-object.
+        subobj = getattr(object, name)
+
+        # Store floats as IEEE-754 byte arrays, for higher precision.
+        if type(subobj) == float or type(subobj) == float64:
+            sub_elem.setAttribute('ieee_754_byte_array', 
`floatAsByteArray(subobj)`)
+
         # Add the text value to the sub element.
-        text_val = doc.createTextNode(`getattr(object, name)`)
+        text_val = doc.createTextNode(`subobj`)
         sub_elem.appendChild(text_val)
 
 




Related Messages


Powered by MHonArc, Updated Sun Jul 06 03:00:35 2008