aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/Makefile.am10
-rw-r--r--scripts/Makefile.in10
-rwxr-xr-xscripts/cell-please130
-rwxr-xr-xscripts/create-mtz7
-rwxr-xr-xscripts/hkl2hkl23
-rwxr-xr-xscripts/indexing-rate93
-rwxr-xr-xscripts/observed-peak-rate (renamed from scripts/hit-rate)0
7 files changed, 262 insertions, 11 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index f628d16a..1106df20 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,7 +1,9 @@
crystfeldir = $(docdir)/scripts
-crystfel_DATA = check-near-bragg double-hit hit-rate random-image stream-split \
+crystfel_DATA = check-near-bragg double-hit random-image stream-split \
wibbletron zone-axis create-mtz frequency i0-analysis mtz2hkl \
- sequence-image test-facetron zone-axes alternate-stream README
-EXTRA_DIST = check-near-bragg double-hit hit-rate random-image stream-split \
+ sequence-image test-facetron zone-axes alternate-stream README \
+ indexing-rate observed-peak-rate
+EXTRA_DIST = check-near-bragg double-hit random-image stream-split \
wibbletron zone-axis create-mtz frequency i0-analysis mtz2hkl \
- sequence-image test-facetron zone-axes alternate-stream README
+ sequence-image test-facetron zone-axes alternate-stream README \
+ indexing-rate observed-peak-rate
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 7646cb42..9fb269c2 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -166,13 +166,15 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
crystfeldir = $(docdir)/scripts
-crystfel_DATA = check-near-bragg double-hit hit-rate random-image stream-split \
+crystfel_DATA = check-near-bragg double-hit random-image stream-split \
wibbletron zone-axis create-mtz frequency i0-analysis mtz2hkl \
- sequence-image test-facetron zone-axes alternate-stream README
+ sequence-image test-facetron zone-axes alternate-stream README \
+ indexing-rate observed-peak-rate
-EXTRA_DIST = check-near-bragg double-hit hit-rate random-image stream-split \
+EXTRA_DIST = check-near-bragg double-hit random-image stream-split \
wibbletron zone-axis create-mtz frequency i0-analysis mtz2hkl \
- sequence-image test-facetron zone-axes alternate-stream README
+ sequence-image test-facetron zone-axes alternate-stream README \
+ indexing-rate observed-peak-rate
all: all-am
diff --git a/scripts/cell-please b/scripts/cell-please
new file mode 100755
index 00000000..bb8b70ce
--- /dev/null
+++ b/scripts/cell-please
@@ -0,0 +1,130 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Fcntl;
+use POSIX;
+use IO::Handle;
+
+open(FH, $ARGV[0]);
+
+open(GP, "| gnuplot");
+autoflush GP 1;
+print(GP "set term postscript enhanced font \"Helvetica,20\"\n");
+print(GP "set output \"unitcell.ps\"\n");
+print(GP "unset key\n");
+print(GP "set xtics nomirror out rotate by 0\n");
+print(GP "unset xdata\n");
+print(GP "set format x \"% g\"\n");
+print(GP "set ylabel \"Frequency\"\n");
+print(GP "unset key\n");
+print(GP "set border lw 2\n");
+print(GP "set xtics nomirror out rotate by -60\n");
+print(GP "set grid\n");
+
+my $a;
+my $b;
+my $c;
+my $al;
+my $be;
+my $ga;
+
+print(GP "set xlabel \"Axis length / nm\"\n");
+print(GP "set title \"a\"\n");
+$a = &find_max(*FH, "^Cell\ parameters\ ([0-9\.]+)\ [0-9\.]+\ [0-9\.]+", "[0:60]");
+print(GP "set title \"b\"\n");
+$b = &find_max(*FH, "^Cell\ parameters\ [0-9\.]+\ ([0-9\.]+)\ [0-9\.]+", "[0:60]");
+print(GP "set title \"c\"\n");
+$c = &find_max(*FH, "^Cell\ parameters\ [0-9\.]+\ [0-9\.]+\ ([0-9\.]+)", "[0:60]");
+
+print(GP "set xlabel \"Angle / deg\"\n");
+print(GP "set title \"alpha\"\n");
+$al = &find_max(*FH, "([0-9\.]+)\ [0-9\.]+\ [0-9\.]+ deg\$", "[0:180]");
+print(GP "set title \"beta\"\n");
+$be = &find_max(*FH, "[0-9\.]+\ ([0-9\.]+)\ [0-9\.]+ deg\$", "[0:180]");
+print(GP "set title \"gamma\"\n");
+$ga = &find_max(*FH, "[0-9\.]+\ [0-9\.]+\ ([0-9\.]+) deg\$", "[0:180]");
+
+close(FH);
+close(GP);
+
+printf("Axis lengths: %5.2f %5.2f %5.2f nm\n", $a, $b, $c);
+printf("Angles: %5.2f %5.2f %5.2f deg\n", $al, $be, $ga);
+
+exit(0);
+
+
+
+sub find_max()
+{
+ my $fh = shift;
+ my $exp = shift;
+ my $lims = shift;
+
+ my $line;
+ my $hsteps = 1000;
+ my @hist;
+ my $hmin;
+ my $hmax;
+ my $first = 1;
+
+ seek $fh, 0, SEEK_SET or die("Couldn't rewind input");
+ while ( $line = <$fh> ) {
+
+ chomp $line;
+
+ if ( $line =~ /$exp/ ) {
+
+ my $val = $1;
+
+ if ( $first ) {
+ $hmin = $val;
+ $hmax = $val;
+ $first = 0;
+ }
+
+ if ( $val > $hmax ) { $hmax = $val; }
+ if ( $val < $hmin ) { $hmin = $val; }
+ }
+
+ }
+
+ my $hrange = $hmax - $hmin;
+
+ my $hstep = ($hmax - $hmin)/$hsteps;
+ for ( my $i=0; $i<$hsteps; $i++ ) {
+ $hist[$i] = 0;
+ }
+ seek $fh, 0, SEEK_SET or die("Couldn't rewind input");
+ while ( $line = <$fh> ) {
+ chomp $line;
+ if ( $line =~ /$exp/ ) {
+
+ my $val;
+ my $bin;
+
+ $val = $1;
+ $bin = floor(($val-$hmin)/$hstep);
+ $hist[$bin]++;
+
+ }
+ }
+ open(OFH, "> histogram.minated");
+ for ( my $i=0; $i<$hsteps; $i++ ) {
+ printf(OFH "%f %f\n", $hmin+$hstep*$i+($hstep/2), $hist[$i]);
+ }
+ close(OFH);
+ print(GP "plot ".$lims." [] \"histogram.minated\" u 1:2 w histeps lw 5 lc 3\n");
+
+ my $max = 0;
+ my $mval = 0;
+ for ( my $bin=0; $bin<$hsteps; $bin++ ) {
+ if ( $hist[$bin] > $mval ) {
+ $mval = $hist[$bin];
+ $max = $bin;
+ }
+ }
+ sleep(1);
+ unlink("histogram.minated");
+
+ $hmin + $hstep*$max;
+}
diff --git a/scripts/create-mtz b/scripts/create-mtz
index c8852515..684914a8 100755
--- a/scripts/create-mtz
+++ b/scripts/create-mtz
@@ -23,13 +23,14 @@ if [ -e $TMPFILE -o -e $OUTFILE ]; then
fi
+# PS1: CELL 281 281 165.2 90 90 120
# Start by putting the CrystFEL intensities into an MTZ file
echo "Running 'f2mtz'..."
f2mtz HKLIN $1 HKLOUT $TMPFILE > out.html << EOF
TITLE Reflections from CrystFEL
NAME PROJECT wibble CRYSTAL wibble DATASET wibble
-CELL 281 281 165.2 90 90 120
-SYMM P63
+CELL 139 232 309 90 90 90
+SYMM P1
SKIP 1
LABOUT H K L IMEAN SIGIMEAN
CTYPE H H H J Q
@@ -37,7 +38,7 @@ FORMAT '(F3.0,1X,F3.0,1X,F3.0,1X,F10.2,10X,F10.2)'
EOF
if [ $? -ne 0 ]; then echo "Failed."; exit; fi
-
+exit 0
# Get the unit cell contents
echo "Running 'rwcontents'..."
diff --git a/scripts/hkl2hkl b/scripts/hkl2hkl
new file mode 100755
index 00000000..70757d50
--- /dev/null
+++ b/scripts/hkl2hkl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $line;
+
+printf(" h k l I phase sigma(I) 1/d(nm^-1) counts\n");
+
+while ( $line = <STDIN> ) {
+
+ if ( $line =~ /^\s*([\d\-]+)\s+([\d\-]+)\s+([\d\-]+)\s+([\d\.\-]+)\s+/ ) {
+
+ my $h = $1;
+ my $k = $2;
+ my $l = $3;
+ my $intensity = $4;
+
+ printf("%3i %3i %3i %10.2f %s %10.2f %10.2f %7i\n",
+ $h, $k, $l, $intensity, " -", 0.0, 0.0, 1);
+
+ }
+
+}
diff --git a/scripts/indexing-rate b/scripts/indexing-rate
new file mode 100755
index 00000000..6dc61f36
--- /dev/null
+++ b/scripts/indexing-rate
@@ -0,0 +1,93 @@
+#!/usr/bin/perl -w
+
+use strict;
+use File::Basename;
+
+open(FH, $ARGV[0]);
+open(HITRATE, "> hitrate.dat");
+
+my $line;
+my $year;
+my $month;
+my $day;
+my $hour;
+my $min = -1;
+my $sec = -1;
+my $nh = 0;
+
+while ( $line = <FH> ) {
+
+ chomp($line);
+
+ unless ( $line =~ /^Reflections\ from\ indexing\ in\ (.+)$/ ) {
+ next;
+ }
+
+ my $filename = basename($1);
+
+ if ( $filename ) {
+
+ unless ( $filename =~
+ /LCLS_(\d+)_([A-Za-z]+)(\d+)_r\d\d\d\d_(\d\d)(\d\d)(\d\d)_/ ) {
+ printf(STDERR "Wrong filename format '%s'!\n",
+ $filename);
+ exit(1);
+ }
+
+ my $new_year = $1;
+ my $new_month = $2;
+ my $new_day = $3;
+ my $new_hour = $4;
+ my $new_min = $5;
+ my $new_sec = $6;
+
+ if ( $new_min != $min ) {
+
+ # Not the first time
+ if ( $sec != -1 ) {
+ printf(HITRATE "%s/%s/%s-%s:%s:%s %i\n",
+ $year, $month, $day,
+ $hour, $min, $sec, $nh);
+ }
+
+ $year = $new_year;
+ $month = $new_month;
+ $day = $new_day;
+ $hour = $new_hour;
+ $min = $new_min;
+ $sec = $new_sec;
+ $nh = 0;
+
+ } else {
+
+ $nh++;
+
+ }
+
+ }
+
+}
+
+close(FH);
+close(HITRATE);
+
+#system("head -n 67 hitrate.dat > hitrate2.dat");
+system("tail -n 105 hitrate.dat > hitrate2.dat");
+
+open(GP, "| gnuplot");
+
+print(GP "set term postscript enhanced font \"Helvetica,20\"\n");
+print(GP "set output \"hitrate.ps\"\n");
+print(GP "set title \"Hit rate\"\n");
+print(GP "set xtics nomirror rotate by -60\n");
+print(GP "set xdata time\n");
+print(GP "set timefmt \"%Y/%b/%d-%H:%M:%S\"\n");
+print(GP "set format x \"%d/%b %H:%M\"\n");
+print(GP "set rmargin 6\n");
+print(GP "unset key\n");
+print(GP "plot [] [] \"hitrate2.dat\" u 1:2 w histeps lw 3 lc 3\n");
+close(GP);
+
+system("ps2pdf hitrate.ps");
+#unlink("hitrate.dat");
+unlink("hitrate.ps");
diff --git a/scripts/hit-rate b/scripts/observed-peak-rate
index 00e0ba4d..00e0ba4d 100755
--- a/scripts/hit-rate
+++ b/scripts/observed-peak-rate