From 690666e32643302970b1f54bbaa0efe83aac7e86 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 12 May 2017 15:51:33 +0200 Subject: 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. --- scripts/peak-intensity | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'scripts/peak-intensity') diff --git a/scripts/peak-intensity b/scripts/peak-intensity index 53610b73..65e066cf 100755 --- a/scripts/peak-intensity +++ b/scripts/peak-intensity @@ -1,13 +1,13 @@ #!/usr/bin/env python - +# -*- coding: utf-8 -*- # # Quantify peak intensities # -# Copyright (c) 2015 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 Thomas White +# 2015-2017 Thomas White # import sys @@ -40,8 +40,8 @@ while True: f.close() -print '%i patterns, %i peaks' % (n_patt,n_peaks) -print 'Mean %.2f peaks per pattern' % (n_peaks/n_patt) -print 'Mean %.2f ADU per peak' % (total_intens/n_peaks) -print 'Mean %.2f ADU total per pattern' % (total_intens/n_patt) +print('{} patterns, %i peaks'.format(n_patt,n_peaks)) +print('Mean {:.2f} peaks per pattern'.format(n_peaks/float(n_patt))) +print('Mean {:.2f} ADU per peak'.format(total_intens/float(n_peaks))) +print('Mean {:.2f} ADU total per pattern'.format(total_intens/n_patt)) -- cgit v1.2.3