aboutsummaryrefslogtreecommitdiff
path: root/scripts/detector-shift
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/detector-shift
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/detector-shift')
-rwxr-xr-xscripts/detector-shift16
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/detector-shift b/scripts/detector-shift
index a348e3c9..24cbb504 100755
--- a/scripts/detector-shift
+++ b/scripts/detector-shift
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
#
# Determine mean detector shift based on prediction refinement results
#
-# Copyright (c) 2015-2016 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2015-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2015-2016 Thomas White <taw@physics.org>
+# 2015-2017 Thomas White <taw@physics.org>
# 2016 Marmoru Suzuki <mamoru.suzuki@protein.osaka-u.ac.jp>
#
@@ -54,13 +54,13 @@ f.close()
mean_x = sum(x_shifts) / len(x_shifts)
mean_y = sum(y_shifts) / len(y_shifts)
-print 'Mean shifts: dx = %.2f mm, dy = %.2f mm' % (mean_x,mean_y)
+print('Mean shifts: dx = {:.2} mm, dy = {:.2} mm'.format(mean_x,mean_y))
# Apply shifts to geometry
if have_geom:
out = os.path.splitext(geom)[0]+'-predrefine.geom'
- print 'Applying corrections to %s, output filename %s' % (geom,out)
+ print('Applying corrections to {}, output filename {}'.format(geom,out))
g = open(geom, 'r')
h = open(out, 'w')
panel_resolutions = {}
@@ -99,7 +99,7 @@ if have_geom:
res = panel_resolutions[panel]
else:
res = default_res
- print 'Using default resolution (%f px/m) for panel %s' % (res, panel)
+ print('Using default resolution ({} px/m) for panel {}'.format(res, panel))
h.write('%s/corner_x = %f\n' % (panel,panel_cnx+(mean_x*res*1e-3)))
continue
@@ -111,7 +111,7 @@ if have_geom:
res = panel_resolutions[panel]
else:
res = default_res
- print 'Using default resolution (%f px/m) for panel %s' % (res, panel)
+ print('Using default resolution ({} px/m) for panel {}'.format(res, panel))
h.write('%s/corner_y = %f\n' % (panel,panel_cny+(mean_y*res*1e-3)))
continue