aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-07-06 17:22:11 +0200
committerThomas White <taw@physics.org>2017-07-06 17:24:59 +0200
commit5292f57d4434c7267e8d945871513d742ff42427 (patch)
treed460aa5cef5a501516876850ef243cfc27313d5a /scripts
parent48d4a6b8e82cce81222ec58fdfb488ed79ce0bcf (diff)
parentdc3395900fc3ce0d3961757628ff83ad6456be19 (diff)
Merge branch 'master' into taketwo
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Rsplit_surface.py16
-rwxr-xr-xscripts/add-beam-params14
-rwxr-xr-xscripts/ave-resolution15
-rw-r--r--scripts/clean-stream.py4
-rwxr-xr-xscripts/crystal-frame-number13
-rwxr-xr-xscripts/detector-shift16
-rwxr-xr-xscripts/find-pairs37
-rwxr-xr-xscripts/gaincal-to-saturation-map9
-rwxr-xr-xscripts/move-entire-detector16
-rwxr-xr-xscripts/peak-intensity16
-rwxr-xr-xscripts/peakogram-stream8
-rwxr-xr-xscripts/split-by-mask12
-rwxr-xr-xscripts/sum-peaks47
-rwxr-xr-xscripts/truncate-stream14
-rw-r--r--scripts/turbo-index-lsf (renamed from scripts/turbo-index)5
-rwxr-xr-xscripts/turbo-index-slurm85
16 files changed, 235 insertions, 92 deletions
diff --git a/scripts/Rsplit_surface.py b/scripts/Rsplit_surface.py
index ca68a92e..63a72cd8 100644
--- a/scripts/Rsplit_surface.py
+++ b/scripts/Rsplit_surface.py
@@ -1,13 +1,5 @@
#!/usr/bin/python
-# coding=utf-8
-
-from __future__ import division
-from array import array
-from numpy import *
-
-import matplotlib
-
-# Rsplit_surface.py
+# -*- coding: utf-8 -*-
#
# Plot Rsplit as a contour map
#
@@ -32,6 +24,12 @@ import matplotlib
# along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import division
+from array import array
+from numpy import *
+
+import matplotlib
+
"""there could be problems with dependencies, in this case, """
#matplotlib.use('PS')
diff --git a/scripts/add-beam-params b/scripts/add-beam-params
index 23c9caaf..e4e38f70 100755
--- a/scripts/add-beam-params
+++ b/scripts/add-beam-params
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
#
# Add beam parameters to stream
#
-# Copyright (c) 2014 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2014 Thomas White <taw@physics.org>
+# 2014,2017 Thomas White <taw@physics.org>
#
import sys
@@ -66,7 +66,7 @@ def count_crystals(f, g, start_after, stop_after):
in_crystal = 0
need_end_chunk = 1
- print "Wrote %i crystals to %s" % (n_crystals_written, opt.ofn)
+ print("Wrote {} crystals to {}".format(n_crystals_written, opt.ofn))
def count_chunks(f, g, start_after, stop_after):
n_chunks_seen = 0
@@ -95,7 +95,7 @@ def count_chunks(f, g, start_after, stop_after):
if n_chunks_written == stop_after:
break
- print "Wrote %i chunks to %s" % (n_chunks_written, opt.ofn)
+ print("Wrote {} chunks to {}".format(n_chunks_written, opt.ofn))
op = optparse.OptionParser()
op.add_option('', '--input', action='store', type='string', dest='ifn',
@@ -111,7 +111,7 @@ op.add_option('', '--chunks', action='store_true', dest='chunks',
opt,arg = op.parse_args(sys.argv)
if not (opt.ifn and opt.ofn):
- print "You need at least --input and --output"
+ print("You need at least --input and --output")
exit(1)
f = open(opt.ifn, 'r')
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')
diff --git a/scripts/clean-stream.py b/scripts/clean-stream.py
index 1e906e54..57c0ed93 100644
--- a/scripts/clean-stream.py
+++ b/scripts/clean-stream.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# coding=utf-8
-
+#
# clean-stream.py
#
# Remove non-indexed frames from a stream
@@ -86,5 +86,5 @@ while (line != ''):
line = infile_1.readline()
-print '%d suited of %d patterns have been extracted and saved as %s' % (num_suited, n_patt, sys.argv[2])
+print('%d suited of %d patterns have been extracted and saved as %s' % (num_suited, n_patt, sys.argv[2]))
Nfile.write('%d' % num_suited)
diff --git a/scripts/crystal-frame-number b/scripts/crystal-frame-number
index b3ed3f1f..883abb81 100755
--- a/scripts/crystal-frame-number
+++ b/scripts/crystal-frame-number
@@ -1,6 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
+#
+# Show sequence numbers of crystals and frames
+#
+# Copyright © 2015-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2015-2017 Thomas White <taw@physics.org>
import sys
@@ -16,9 +23,9 @@ while True:
if fline.find("Image filename") != -1:
frame_number += 1
fn = fline.split(': ')[1].split(' ')[0].rstrip("\r\n")
- print 'Frame %i: %s' % (frame_number, fn)
+ print('Frame {}: {}'.format(frame_number, fn))
if fline.find("diffraction_resolution_limit") != -1:
crystal_number += 1
- print ' Crystal %i: %s' % (crystal_number, fline.rstrip("\r\n"))
+ print(' Crystal {}: {}'.format(crystal_number, fline.rstrip("\r\n")))
f.close()
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
diff --git a/scripts/find-pairs b/scripts/find-pairs
index 4629767d..8c3b69d0 100755
--- a/scripts/find-pairs
+++ b/scripts/find-pairs
@@ -1,14 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
#
# Find pairs of observations from the same pattern
#
-# Copyright © 2014 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2014 Thomas White <taw@physics.org>
+# 2014-2017 Thomas White <taw@physics.org>
#
import re as regexp
@@ -41,33 +40,33 @@ def find_405(f):
f = open(fn1, 'r')
flines = find_405(f)
-print len(flines),"measurements in",fn1
+print("{} measurements in {}".format(len(flines),fn1))
g = open(fn2, 'r')
glines = find_405(g)
-print len(glines),"measurements in",fn2
+print("{} measurements in {}".format(len(glines),fn2))
-print "\nThe common measurements:\n"
+print("\nThe common measurements:\n")
for fn in flines.keys():
if fn in glines:
- print fn
- print flines[fn].rstrip("\r\n")
- print glines[fn]
- print
+ print(fn)
+ print(flines[fn].rstrip("\r\n"))
+ print(glines[fn])
+ print()
del flines[fn]
del glines[fn]
-print "\nThe measurements only in",fn1,":\n"
+print("\nThe measurements only in {}:\n".format(fn1))
for fn in flines.keys():
- print fn
- print flines[fn].rstrip("\r\n")
- print
+ print(fn)
+ print(flines[fn].rstrip("\r\n"))
+ print()
-print "\nThe measurements only in",fn2,":\n"
+print("\nThe measurements only in {}:\n".format(fn2))
for fn in glines.keys():
- print fn
- print glines[fn].rstrip("\r\n")
- print
+ print(fn)
+ print(glines[fn].rstrip("\r\n"))
+ print("")
diff --git a/scripts/gaincal-to-saturation-map b/scripts/gaincal-to-saturation-map
index 8a803526..eac8883c 100755
--- a/scripts/gaincal-to-saturation-map
+++ b/scripts/gaincal-to-saturation-map
@@ -1,4 +1,13 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Convert gain map to saturation map
+#
+# Copyright © 2016-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2016-2017 Thomas White <taw@physics.org>
import numpy as np
import h5py
diff --git a/scripts/move-entire-detector b/scripts/move-entire-detector
index 79ce5a5c..3d06c408 100755
--- a/scripts/move-entire-detector
+++ b/scripts/move-entire-detector
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
#
# Shift the detector by a given amount
#
-# Copyright (c) 2016 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2016-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2016 Thomas White <taw@physics.org>
+# 2016-2017 Thomas White <taw@physics.org>
#
import sys
@@ -58,8 +58,8 @@ if args.beam:
else:
bm = 'detector'
-print 'Input filename %s\nOutput filename %s' % (args.ifn,out)
-print 'Shifting %s by %f,%f %s' % (bm, args.xshift, args.yshift, units)
+print('Input filename {}\nOutput filename {}'.format(args.ifn,out))
+print('Shifting {} by {},{} {}'.format(bm, args.xshift, args.yshift, units))
if args.beam:
args.xshift = -args.xshift
@@ -104,7 +104,7 @@ while True:
else:
res = default_res
if not args.px:
- print 'Using default resolution (%f px/m) for panel %s' % (res, panel)
+ print('Using default resolution ({} px/m) for panel {}'.format(res, panel))
if args.px:
h.write('%s/corner_x = %f\n' % (panel,panel_cnx+args.xshift))
else:
@@ -120,7 +120,7 @@ while True:
else:
res = default_res
if not args.px:
- print 'Using default resolution (%f px/m) for panel %s' % (res, panel)
+ print('Using default resolution ({} px/m) for panel {}'.format(res, panel))
if args.px:
h.write('%s/corner_y = %f\n' % (panel,panel_cny+args.yshift))
else:
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 <taw@physics.org>
+# 2015-2017 Thomas White <taw@physics.org>
#
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))
diff --git a/scripts/peakogram-stream b/scripts/peakogram-stream
index 209e7e95..1f67b39c 100755
--- a/scripts/peakogram-stream
+++ b/scripts/peakogram-stream
@@ -1,16 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
-# peakogram-stream
#
# Check a stream for saturation
#
-# Copyright © 2016 Deutsches Elektronen-Synchrotron DESY,
+# Copyright © 2016-2017 Deutsches Elektronen-Synchrotron DESY,
# a research centre of the Helmholtz Association.
# Copyright © 2016 The Research Foundation for SUNY
#
# Authors:
-# 2016 Thomas White <taw@physics.org>
+# 2016-2017 Thomas White <taw@physics.org>
# 2014-2016 Thomas Grant <tgrant@hwi.buffalo.edu>
#
# This file is part of CrystFEL.
@@ -120,7 +118,7 @@ data = np.asarray(data,dtype=float)
sys.stdout.write("\r%i peaks found" % n)
sys.stdout.flush()
-print ""
+print("")
x = data[:,0]
y = data[:,1]
diff --git a/scripts/split-by-mask b/scripts/split-by-mask
index aede3f43..18b672e4 100755
--- a/scripts/split-by-mask
+++ b/scripts/split-by-mask
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
#
# Split stream according to an external mask
#
-# Copyright (c) 2014-2016 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2014-2016 Thomas White <taw@physics.org>
+# 2014-2017 Thomas White <taw@physics.org>
#
import sys
@@ -21,7 +21,7 @@ prog = re.compile("^\s+([\d-]+)\s+([\d-]+)\s+([\d-]+)\s+[\d\.\-]+\s+[\d\.\-]+\s+
def process_refln(fline, g, h, mask):
match = prog.match(fline)
if not match:
- print 'Line not understood, WTF? %s' % fline
+ print('Line not understood, WTF? {}'.format(fline))
return
fs = int(round(float(match.group(4))))
ss = int(round(float(match.group(5))))
@@ -48,7 +48,7 @@ op.add_option('', '--mask', action='store', type='string', dest='mask_fn',
opt,arg = op.parse_args(sys.argv)
if not opt.ifn:
- print "You need at least --input"
+ print("You need at least --input")
exit(1)
f = open(opt.ifn, 'r')
diff --git a/scripts/sum-peaks b/scripts/sum-peaks
new file mode 100755
index 00000000..eccb9fc6
--- /dev/null
+++ b/scripts/sum-peaks
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Generate "peak powder" from CrystFEL stream
+#
+# Copyright © 2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2017 Thomas White <taw@physics.org>
+#
+
+import numpy as np
+import h5py
+import sys
+import re
+
+f = open(sys.argv[1], 'r')
+powder = np.zeros((512,1024), dtype=float)
+peaks = []
+
+prog1 = re.compile("^\s*([\d\-\.]+)\s+([\d\-\.]+)\s+[\d\-\.]+\s+([\d\-\.]+)\s+\S+$")
+
+while True:
+
+ fline = f.readline()
+ if not fline:
+ break
+
+ if fline == '----- End chunk -----\n':
+ if len(peaks) > 10:
+ for p in peaks:
+ powder[p[1],p[0]] += p[2]
+ peaks = []
+
+ match = prog1.match(fline)
+ if match:
+ fs = int(float(match.group(1)))
+ ss = int(float(match.group(2)))
+ intensity = float(match.group(3))
+ peaks.append((fs,ss,intensity))
+
+f.close()
+
+fh = h5py.File("summed-peaks.h5", "w")
+fh.create_dataset("/data", (512,1024), data=powder)
+fh.close()
diff --git a/scripts/truncate-stream b/scripts/truncate-stream
index 1725082a..60679d30 100755
--- a/scripts/truncate-stream
+++ b/scripts/truncate-stream
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
#
# Chop chunks or crystals from one or both ends of a stream
#
-# Copyright (c) 2014 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2014 Thomas White <taw@physics.org>
+# 2014-2017 Thomas White <taw@physics.org>
#
import sys
@@ -66,7 +66,7 @@ def count_crystals(f, g, start_after, stop_after):
in_crystal = 0
need_end_chunk = 1
- print "Wrote %i crystals to %s" % (n_crystals_written, opt.ofn)
+ print("Wrote {} crystals to {}".format(n_crystals_written, opt.ofn))
def count_chunks(f, g, start_after, stop_after):
n_chunks_seen = 0
@@ -95,7 +95,7 @@ def count_chunks(f, g, start_after, stop_after):
if n_chunks_written == stop_after:
break
- print "Wrote %i chunks to %s" % (n_chunks_written, opt.ofn)
+ print("Wrote {} chunks to {}".format(n_chunks_written, opt.ofn))
op = optparse.OptionParser()
op.add_option('', '--input', action='store', type='string', dest='ifn',
@@ -111,7 +111,7 @@ op.add_option('', '--chunks', action='store_true', dest='chunks',
opt,arg = op.parse_args(sys.argv)
if not (opt.ifn and opt.ofn):
- print "You need at least --input and --output"
+ print("You need at least --input and --output")
exit(1)
f = open(opt.ifn, 'r')
diff --git a/scripts/turbo-index b/scripts/turbo-index-lsf
index c11f521e..00e4ec15 100644
--- a/scripts/turbo-index
+++ b/scripts/turbo-index-lsf
@@ -3,9 +3,9 @@
RUN=$1
NOSAMPLE=`echo $RUN | sed -e 's/\-.*$//'`
-GEOM=<name of geometry file>
+GEOM=my.geom # Name of your geometry file
-find <path to CXI files>/$RUN -name '*.cxi' > files-${RUN}.lst
+find /path/to/CXI/files/$RUN -name '*.cxi' > files-${RUN}.lst # Set location of files
list_events -i files-${RUN}.lst -g $GEOM -o events-${RUN}.lst
wc -l events-${RUN}.lst
rm -f split-events-${RUN}.lst files-${RUN}.lst
@@ -18,6 +18,7 @@ for FILE in split-events-${RUN}.lst*; do
NAME=`echo $FILE | sed -e "s/split-events-${RUN}.lst/${NOSAMPLE}-/"`
echo "$NAME: $FILE ---> $STREAM"
+ # Set indexing parameters here
bsub -q psanaq -o $NAME.log -J $NAME -n 12 -R "span[hosts=1]" \
indexamajig \
-i $FILE -o $STREAM -j 32 -g $GEOM --peaks=cxi
diff --git a/scripts/turbo-index-slurm b/scripts/turbo-index-slurm
new file mode 100755
index 00000000..a0f1bec5
--- /dev/null
+++ b/scripts/turbo-index-slurm
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# Split a large indexing job into many small tasks and submit using SLURM
+
+# ./turbo-index my-files.lst label my.geom /location/for/streams
+
+# Copyright © 2016-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Authors:
+# 2016 Steve Aplin <steve.aplin@desy.de>
+# 2016-2017 Thomas White <taw@physics.org>
+
+SPLIT=1000 # Size of job chunks
+MAIL=you@example.org # Email address for SLURM notifications
+
+INPUT=$1
+RUN=$2
+GEOM=$3
+STREAMDIR=$4
+
+# Set up environment here if necessary
+#source /path/to/crystfel/setup.sh
+
+# Generate event list from file above
+list_events -i $INPUT -g $GEOM -o events-${RUN}.lst
+if [ $? != 0 ]; then
+ echo "list_events failed"
+ exit 1
+fi
+# If you are using single-event files instead of multi-event ("CXI") ones,
+# comment out the above lines and uncomment the following one:
+#cp $INPUT events-${RUN}.lst
+
+# Count total number of events
+wc -l events-${RUN}.lst
+
+# Split the events up, will create files with $SPLIT lines
+split -a 3 -d -l $SPLIT events-${RUN}.lst split-events-${RUN}.lst
+
+# Clean up
+rm -f events-${RUN}.lst
+
+# Loop over the event list files, and submit a batch job for each of them
+for FILE in split-events-${RUN}.lst*; do
+
+ # Stream file is the output of crystfel
+ STREAM=`echo $FILE | sed -e "s/split-events-${RUN}.lst/${RUN}.stream/"`
+
+ # Job name
+ NAME=`echo $FILE | sed -e "s/split-events-${RUN}.lst/${RUN}-/"`
+
+ echo "$NAME: $FILE ---> $STREAM"
+
+ SLURMFILE="${NAME}.sh"
+
+ echo "#!/bin/sh" > $SLURMFILE
+ echo >> $SLURMFILE
+
+ echo "#SBATCH --partition=mypartition" >> $SLURMFILE # Set your partition here
+ echo "#SBATCH --time=01:00:00" >> $SLURMFILE
+ echo "#SBATCH --nodes=1" >> $SLURMFILE
+ echo "#SBATCH --nice=100" >> $SLURMFILE # Set priority very low to allow other jobs through
+ echo >> $SLURMFILE
+
+ echo "#SBATCH --workdir $PWD" >> $SLURMFILE
+ echo "#SBATCH --job-name $NAME" >> $SLURMFILE
+ echo "#SBATCH --output $NAME-%N-%j.out" >> $SLURMFILE
+ echo "#SBATCH --error $NAME-%N-%j.err" >> $SLURMFILE
+ echo "#SBATCH --mail-type END" >> $SLURMFILE
+ echo "#SBATCH --mail-user $MAIL" >> $SLURMFILE
+ echo >> $SLURMFILE
+
+ echo "#source /path/to/crystfel/setup.sh" >> $SLURMFILE # Set up environment here (again) if necessary
+ echo >> $SLURMFILE
+
+ command="indexamajig -i $FILE -o $STREAMDIR/$STREAM"
+ command="$command -j \`nproc\` -g $GEOM"
+ #command="$command --peaks=zaef" # Indexing parameters here
+
+ echo $command >> $SLURMFILE
+
+ sbatch $SLURMFILE
+
+done