aboutsummaryrefslogtreecommitdiff
path: root/scripts/peak-intensity
blob: 53610b73b5346acad55afa8824f5473f5f2455bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python

#
# Quantify peak intensities
#
# 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

f = open(sys.argv[1], 'r')

prog1 = re.compile("^\s*[\d\-\.]+\s+[\d\-\.]+\s+[\d\-\.]+\s+([\d\-\.]+)\s+.+$")

n_peaks = 0
n_patt = 0
total_intens = 0.0

while True:

    fline = f.readline()
    if not fline:
        break

    if fline == '----- Begin chunk -----\n':
        n_patt += 1

    match = prog1.match(fline)
    if match:
        intens = float(match.group(1))
        total_intens += intens
        n_peaks += 1


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)