aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-near-bragg
blob: 10a7549b4d977a81fe4ec66f84ab643bddd94256 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl -w

use strict;
use File::Basename;

my $args = join(" ", splice(@ARGV, 1, scalar(@ARGV)-1));
if ( !($args eq "") ) {
        printf("Extra arguments for hdfsee: %s\n", $args);
} else {
        # Default arguments - feel free to override!
        $args = "--binning=2 --int-boost=10";
        printf("Using default arguments for hdfsee: %s\n", $args);
}

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

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

	chomp $line;
	my $handled = 0;

	if ( $in_image ) {
		printf(TMP "%s\n", $line);
		$handled = 1;
	}

	if ( $line =~ /^Reflections\ measured\ after\ indexing$/ ) {
		$in_image = 1;
		$handled = 1;
	}

	if ( $line =~ /^Image\ filename:\ (.+)$/ ) {
		$filename = $1;
		$handled = 1;
	}

	if ( $line =~ /^End\ of\ reflections$/ ) {

		close(TMP);

		# Example of how to do "basename" and "prefix":
		# $filename = "images-old/".basename($filename);

		my $ev;
		my $evr;
		if ( $event eq "" ) {
			$ev = "";
			$evr = "";
		} else {
			$ev = " --event=".$event;
			$evr = ", event ".$event;
		}
		printf(STDERR "Viewing %s%s\n", $filename, $evr);
		system("hdfsee ".$filename.$ev.
		       " --peak-overlay=list.tmp ".$args);
		if ( $? != 0 ) { exit; }
		unlink("list.tmp");
		open(TMP, "> list.tmp");
		$handled = 1;
		$in_image = 0;
		$event = "";

	}

}