aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-near-bragg
blob: c7d747a1b0eb6b24d810bd547276ab0773fec6c9 (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
48
49
50
51
#!/usr/bin/perl -w

use strict;
use File::Basename;

open(FH, $ARGV[0]);
open(TMP, "> list.tmp");

my $in_image = 0;
my $line;
my $filename;
while ( $line = <FH> ) {

	chomp $line;
	my $handled = 0;

	if ( $line =~ /^\s*[0-9\-]+\s+[0-9\-]+\s+[0-9\-]+\s+[0-9\.\-]+/ ) {
		printf(TMP "%s\n", $line);
		$handled = 1;
	}

	if ( $line =~ /^\s*[0-9\-\.]+\s+[0-9\-\.]+\s+[0-9\-\.]+\s+[0-9\.\-]+/ ) {
		printf(TMP "%s\n", $line);
		$handled = 1;
	}

	if ( $line =~ /^Reflections\ from\ indexing\ in\ (.+)$/ ) {
		$filename = $1;
		$handled = 1;
	}

	if ( $line =~ /^Peaks\ from\ peak search\ in\ (.+)$/ ) {
		$filename = $1;
		$handled = 1;
	}

	if ( $line =~ /^$/ ) {
		close(TMP);
		$filename = "images-old/".basename($filename);
		system("hdfsee ".$filename." --peak-overlay=list.tmp --binning=1 --int-boost=10");
		if ( $? != 0 ) { exit; }
		unlink("list.tmp");
		open(TMP, "> list.tmp");
		$handled = 1;
	}

	if ( !$handled ) {
		printf(STDERR "Unhandled: '%s'\n", $line);
	}

}