diff options
author | Thomas White <taw@physics.org> | 2013-09-16 10:16:02 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-09-16 10:16:18 +0200 |
commit | b94386e57353dbd6aba74e8c605647091dc85403 (patch) | |
tree | d2f63236cfad78738e300289d02ce1ec5e4c3c48 /scripts/clean-stream.py | |
parent | 9f5477e8e67748543ba7cf8131b1d1d41d616ee8 (diff) |
Add Rsplit_surface and clean-stream.py
Diffstat (limited to 'scripts/clean-stream.py')
-rw-r--r-- | scripts/clean-stream.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/scripts/clean-stream.py b/scripts/clean-stream.py new file mode 100644 index 00000000..0982f455 --- /dev/null +++ b/scripts/clean-stream.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# coding=utf-8 + +# clean-stream.py +# +# Remove non-indexed frames from a stream +# +# Copyright © 2013 Fedor Chervinskii +# +# Authors: +# 2013 Fedor Chervinskii <fedor.chervinskii@gmail.com> +# +# This file is part of CrystFEL. +# +# CrystFEL is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CrystFEL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CrystFEL. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import division +from itertools import islice +import sys +import re + + +infile_1 = open (sys.argv[1],'r') +infile_2 = open (sys.argv[1],'r') +outfile = open (sys.argv[2],'w') +Nfile = open ('N.dat','w') + +suited = False +counter1 = -1 +counter2 = 0 +start_index = 0 +n_patt = 0 +num_peaks = 0 +indexed = False +num_suited = 0 + +line = infile_1.readline() + +reg0 = re.compile('----- Begin chunk') +reg1 = re.compile('----- End chunk') +reg6 = re.compile('^indexed_by') +reg7 = re.compile('none') + +while (line != ''): + + counter1 += 1 + + if (reg6.match(line)): + indexed = ( False if reg7.search(line) else True) + + if (reg0.match(line)): + if (start_index == 0) : + while (counter2 < counter1) : + outline = infile_2.readline() + outfile.write(outline) + counter2 += 1 + start_index = counter1 + + if (reg1.match(line)): + n_patt += 1 + if indexed : + suited = True + if suited : + num_suited += 1 + while (counter2 <= counter1) : + outline = infile_2.readline() + if suited : + outfile.write(outline) + counter2 += 1 + suited = False + + line = infile_1.readline() + +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) |