Permalink
Browse files

Modified version of process.py that also collects similar fits togeth…

…er in summary table
  • Loading branch information...
1 parent 063437b commit 5d232132d879554e489a6d00606befd0f2353a04 @cameronneylon committed Apr 10, 2012
Showing with 42 additions and 12 deletions.
  1. +42 −12 model_data/bags/process.py
View
@@ -2,11 +2,30 @@
import os
import os.path
+def compare_chi2(first_fit, second_fit):
+ diff = first_fit[0]*1e10 - second_fit[0]*1e10
+ if diff < 0: # Put chi2 as first parameter
+ return -1
+ elif diff == 0:
+ return 0
+
+ else:
+ return 1
+
+def approx_equal(x, y, tol=1e-18, rel=1e-7):
+ if tol is rel is None:
+ raise TypeError('cannot specify both absolute and relative errors are None')
+ tests = []
+ if tol is not None: tests.append(tol)
+ if rel is not None: tests.append(rel*abs(x))
+ assert tests
+ return abs(x - y) <= max(tests)
+
directory = raw_input("Path to data?")
fit_list = []
-params = ['chi2', 'length', 'radius', 'sldCyl', 'sldSolv', 'background']
+params = ['chi2', 'length', 'radius', 'sldCyl', 'sldSolv', 'background', 'scale']
for file in os.listdir(directory):
fit = []
@@ -29,19 +48,30 @@
fit_list.append(fit)
-def compare_chi2(first_fit, second_fit):
- diff = first_fit[0]*1e10 - second_fit[0]*1e10
- if diff < 0: # Put chi2 as first parameter
- return -1
- elif diff == 0:
- return 0
+fit_list.sort(compare_chi2)
+print params
+for fit in fit_list:
+ print fit
+concatenated = []
+count = 1
+i=0
+while i < len(fit_list)-1:
+ if approx_equal(fit_list[i][0], fit_list[i+1][0], rel=1e-6):
+ count+=1
else:
- return 1
+ fit_list[i].append(count)
+ concatenated.append(fit_list[i])
+ count = 1
+ i+=1
+
+print params
+for fit in concatenated:
+ print fit
+
+
+
-fit_list.sort(compare_chi2)
-print params
-for fit in fit_list:
- print fit
+

0 comments on commit 5d23213

Please sign in to comment.