aboutsummaryrefslogtreecommitdiff
path: root/scripts/ave-resolution
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-05-12 15:51:33 +0200
committerThomas White <taw@physics.org>2017-05-12 15:51:33 +0200
commit690666e32643302970b1f54bbaa0efe83aac7e86 (patch)
treecd4e9b32b46160649a1fa4f5c1786b1cbf614356 /scripts/ave-resolution
parent4227f0b190b08ecc50a49875e86dbb9b14714bdd (diff)
Make all Python scripts compatible with Python 2 and 3
It would be nice to upgrade completely to Python 3, but this may create problems at SLAC because psana only supports Python 2 (Python 3 is available, but means that users have to jump through hoops to run a simple CrystFEL script). None of our scripts do anything complicated, so they can all be compatible with both so far. If anyone adds a script which requires a particular version, make sure to specify the version in the first line, consistent with PEP 394.
Diffstat (limited to 'scripts/ave-resolution')
-rwxr-xr-xscripts/ave-resolution15
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/ave-resolution b/scripts/ave-resolution
index a69c456e..69c21195 100755
--- a/scripts/ave-resolution
+++ b/scripts/ave-resolution
@@ -1,14 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
#
# Find mean diffracting resolution
#
-# Copyright © 2014-2015 Deutsches Elektronen-Synchrotron DESY,
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
# a research centre of the Helmholtz Association.
#
# Author:
-# 2014-2015 Thomas White <taw@physics.org>
+# 2014-2017 Thomas White <taw@physics.org>
#
import sys
@@ -24,16 +23,16 @@ while True:
break
if fline.find("diffraction_resolution_limit") != -1:
res = float(fline.split('= ')[1].split(' ')[0].rstrip("\r\n"))
- a.append(res)
+ a.append(res)
continue
f.close()
b = numpy.array(a)
-print " Mean: %.2f nm^-1 = %.2f A" % (numpy.mean(b),10.0/numpy.mean(b))
-print " Best: %.2f nm^-1 = %.2f A" % (numpy.max(b),10.0/numpy.max(b))
-print "Worst: %.2f nm^-1 = %.2f A" % (numpy.min(b),10.0/numpy.min(b))
-print "Std deviation: %.2f nm^-1" % (numpy.std(b))
+print(" Mean: {:.2} nm^-1 = {:.2} A".format(numpy.mean(b),10.0/numpy.mean(b)))
+print(" Best: {:.2} nm^-1 = {:.2} A".format(numpy.max(b),10.0/numpy.max(b)))
+print("Worst: {:.2} nm^-1 = {:.2} A".format(numpy.min(b),10.0/numpy.min(b)))
+print("Std deviation: {:.2} nm^-1".format(numpy.std(b)))
plt.hist(a,bins=30)
plt.title('Resolution based on indexing results')