aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-10-15 11:38:04 +0200
committerThomas White <taw@physics.org>2015-10-15 11:38:04 +0200
commitdc7ef64b2699221d80cfbf447ab46b91fa9d0b79 (patch)
treebb6d61c553cdff39caa51868962b8f29658342a6 /scripts
parent75509bd121ef3cff9fbfd9c0aa4f4ff28262c010 (diff)
Improved scripts/plot-predict-refine
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/plot-predict-refine71
1 files changed, 62 insertions, 9 deletions
diff --git a/scripts/plot-predict-refine b/scripts/plot-predict-refine
index 68baffdc..04f6ffa8 100755
--- a/scripts/plot-predict-refine
+++ b/scripts/plot-predict-refine
@@ -1,11 +1,64 @@
-#!/bin/sh
+#!/usr/bin/env python
-INFILE=$1
+#
+# Visualise behaviour of prediction refinement
+#
+# Copyright (c) 2015 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2015 Thomas White <taw@physics.org>
+#
+
+import sys
+import os
+import re
+import matplotlib.pyplot as plt
+
+
+def show_frac(ratios, v):
+ n = len([x for x in ratios if x < v])
+ print "%4i (%.2f%%) new/old ratios are below %.2f" % (n, 100*float(n)/len(ratios), v)
+
+
+f = open(sys.argv[1], 'r')
+
+oldR = []
+newR = []
+
+prog1 = re.compile("^predict_refine/R\sold\s=\s([0-9\.\-]+)\snew\s=\s([0-9\.\-]+)\s")
+
+while True:
+
+ fline = f.readline()
+ if not fline:
+ break
+
+ match = prog1.match(fline)
+ if match:
+ old = float(match.group(1))
+ new = float(match.group(2))
+ oldR.append(old)
+ newR.append(new)
+
+f.close()
+
+mean_oldR = sum(oldR) / len(oldR)
+mean_newR = sum(newR) / len(newR)
+ratios = [new/old for new,old in zip(newR, oldR)];
+print 'Mean profile radius before: %.2e, after: %.2e nm^-1' % (mean_oldR,mean_newR)
+show_frac(ratios, 1.2)
+show_frac(ratios, 1.1)
+show_frac(ratios, 1.0)
+show_frac(ratios, 0.9)
+show_frac(ratios, 0.8)
+
+#plt.plot(oldR, newR, 'rx')
+plt.hist(ratios, 50)
+#plt.axis([-2,2,-2,2])
+plt.title('Profile radius before and after refinement')
+plt.xlabel('x shift / mm')
+plt.ylabel('y shift / mm')
+plt.grid(True)
+plt.show()
-grep "predict_refine/R" $INFILE > plotme.dat
-gnuplot -persist << EOF
-set xlabel "Profile radius before refinement / nm^-1"
-set ylabel "Profile radius after refinement / nm^-1"
-plot "plotme.dat" using 4:7
-replot x
-EOF