blob: 65e066cf52dae0a0bbf7caa96854daf47e182cb5 (
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
# -*- coding: utf-8 -*-
#
# Quantify peak intensities
#
# Copyright © 2015-2017 Deutsches Elektronen-Synchrotron DESY,
# a research centre of the Helmholtz Association.
#
# Author:
# 2015-2017 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('{} 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))
|