diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-06-12 09:57:55 -0700 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2010-06-12 09:57:55 -0700 |
commit | 03bf040e4b377c3434bf2704527326f78e76e77c (patch) | |
tree | 72d17bbbf1ab86df3b42435b7216812d90a9cfbe | |
parent | 4ab3f17756453521edd647678e8bae1c1640b415 (diff) |
scripts/hitrate: Show actual hit rate
-rwxr-xr-x | scripts/hit-rate | 102 |
1 files changed, 77 insertions, 25 deletions
diff --git a/scripts/hit-rate b/scripts/hit-rate index 14a75d9f..00e0ba4d 100755 --- a/scripts/hit-rate +++ b/scripts/hit-rate @@ -4,65 +4,117 @@ use strict; use File::Basename; open(FH, $ARGV[0]); -open(OFH, "> hitrate.dat"); +open(HITRATE, "> hitrate.dat"); +open(NPEAKS, "> npeaks.dat"); my $line; my $filename = ""; my $full_filename; my $np; +my $year; +my $month; +my $day; +my $hour; +my $min; +my $sec = -1; +my $nh = 0; +my $ns = 0; while ( $line = <FH> ) { chomp($line); - if ( $line =~ /^Peaks\ from\ peak\ search\ in\ (.+)$/ ) { + if ( $line =~ /^\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+$/ ) { + $np++; + } - $full_filename = $1; + unless ( $line =~ /^Peaks\ from\ peak\ search\ in\ (.+)$/ ) { + next; + } - # Process last image - if ( $filename ) { + $full_filename = $1; + + # Process last image + if ( $filename ) { + + unless ( $filename =~ + /LCLS_(\d+)_([A-Za-z]+)(\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_sec != $sec ) { + + if ( $ns > 0 ) { + + printf(HITRATE "%s/%s/%s-%s:%s:%s %f\n", + $year, $month, $day, + $hour, $min, $sec, + $nh); - unless ( $filename =~ /LCLS_(\d+)_([A-Za-z]+)(\d+)_(\d\d)(\d\d)(\d\d)_/ ) { - printf(STDERR "Wrong filename format '%s'!\n", $filename); - exit(1); } - my $year = $1; - my $month = $2; - my $day = $3; - my $hour = $4; - my $min = $5; - my $sec = $6; - - printf(OFH "%s/%s/%s-%s:%s:%s %f\n", $year, $month, $day, - $hour, $min, $sec, - $np); - printf("%s: %i peaks\n", $filename, $np); + + $year = $new_year; + $month = $new_month; + $day = $new_day; + $hour = $new_hour; + $min = $new_min; + $sec = $new_sec; + + $nh = 0; + $ns = 0; } - $filename = basename($full_filename); - $np = 0; + printf(NPEAKS "%s/%s/%s-%s:%s:%s %f\n", + $year, $month, $day, $hour, $min, $sec, $np); - } + printf("%s: %i peaks\n", $filename, $np); + if ( $np > 10 ) { + $nh++; + } + $ns++; - if ( $line =~ /^\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+\s+[0-9\.]+$/ ) { - $np++; } + $filename = basename($full_filename); + $np = 0; + } close(FH); -close(OFH); +close(HITRATE); +close(NPEAKS); 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 [] [] \"hitrate.dat\" u 1:2 w points\n"); + +print(GP "set xtics nomirror rotate by -60\n"); +print(GP "set title \"Number of Peaks per Image\"\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 "unset key\n"); +print(GP "plot [] [] \"npeaks.dat\" u 1:2 w points\n"); + close(GP); system("ps2pdf hitrate.ps"); |