mailr11834 - /branches/peak_list_handling/generic_fns/monte_carlo.py


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

Header


Content

Posted by edward on December 15, 2010 - 18:33:
Author: bugman
Date: Wed Dec 15 18:33:44 2010
New Revision: 11834

URL: http://svn.gna.org/viewcvs/relax?rev=11834&view=rev
Log:
The Monte Carlo simulation code can now handle dictionary type data.


Modified:
    branches/peak_list_handling/generic_fns/monte_carlo.py

Modified: branches/peak_list_handling/generic_fns/monte_carlo.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/peak_list_handling/generic_fns/monte_carlo.py?rev=11834&r1=11833&r2=11834&view=diff
==============================================================================
--- branches/peak_list_handling/generic_fns/monte_carlo.py (original)
+++ branches/peak_list_handling/generic_fns/monte_carlo.py Wed Dec 15 
18:33:44 2010
@@ -75,19 +75,37 @@
         # Get the errors.
         error = return_error(data_index)
 
-        # Loop over the Monte Carlo simulations.
-        random = []
-        for j in xrange(cdp.sim_number):
-            # Randomise the data.
-            random.append([])
-            for k in xrange(len(data)):
-                # No data or errors.
-                if data[k] == None or error[k] == None:
-                    random[j].append(None)
-                    continue
-
-                # Gaussian randomisation.
-                random[j].append(gauss(data[k], error[k]))
+        # List type data.
+        if isinstance(data, list):
+            # Loop over the Monte Carlo simulations.
+            random = []
+            for j in xrange(cdp.sim_number):
+                # Randomise the data.
+                random.append([])
+                for k in xrange(len(data)):
+                    # No data or errors.
+                    if data[k] == None or error[k] == None:
+                        random[j].append(None)
+                        continue
+
+                    # Gaussian randomisation.
+                    random[j].append(gauss(data[k], error[k]))
+
+        # Dictionary type data.
+        if isinstance(data, dict):
+            # Loop over the Monte Carlo simulations.
+            random = []
+            for j in xrange(cdp.sim_number):
+                # Randomise the data.
+                random.append({})
+                for id in data.keys():
+                    # No data or errors.
+                    if data[id] == None or error[id] == None:
+                        random[j][id] = None
+                        continue
+
+                    # Gaussian randomisation.
+                    random[j][id] = gauss(data[id], error[id])
 
         # Pack the simulation data.
         pack_sim_data(data_index, random)




Related Messages


Powered by MHonArc, Updated Wed Dec 15 19:00:02 2010