aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-04-07 22:12:02 +0200
committerThomas White <taw@physics.org>2010-04-07 22:12:30 +0200
commitefc6fb696354026c611de129d30a9d41ac400967 (patch)
tree547739a18a304d1a111487a5e9652922fb16012c /scripts
parenta3dd78f5bfb3dc91eb78eec465f79853263eb994 (diff)
Add scripts/frequency and scripts/histogram
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/frequency51
-rwxr-xr-xscripts/histogram15
2 files changed, 66 insertions, 0 deletions
diff --git a/scripts/frequency b/scripts/frequency
new file mode 100755
index 00000000..1f9c66e6
--- /dev/null
+++ b/scripts/frequency
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $bins = 200;
+open(FH, $ARGV[0]);
+
+my $min = 99999999999999999999.0;
+my $max = 0.0;
+my $line;
+
+while ( $line = <FH> ) {
+
+ chomp($line);
+ if ( $line < $min ) {
+ $min = $line;
+ }
+ if ( $line > $max ) {
+ $max = $line;
+ }
+
+}
+
+printf("%f -> %f\n", $min, $max);
+
+seek(FH, 0, 0);
+
+my $binsize = ($max+1-$min)/$bins;
+my @hist;
+my $i;
+
+for ( $i=0; $i<$bins; $i++ ) {
+ $hist[$i] = 0;
+}
+
+while ( $line = <FH> ) {
+
+ my $bin;
+
+ chomp($line);
+
+ $bin = int(($line-$min)/$binsize);
+ $hist[$bin]++;
+
+}
+
+for ( $i=0; $i<$bins; $i++ ) {
+ printf("%f\t%i\n", $min+(($i+0.5)*$binsize), $hist[$i]);
+}
+
+close(FH);
diff --git a/scripts/histogram b/scripts/histogram
new file mode 100755
index 00000000..329b775e
--- /dev/null
+++ b/scripts/histogram
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+./frequency.pl 103.hist > hist.dat
+
+gnuplot << EOF
+set term postscript enhanced font "Helvetica,20"
+set output "histo.ps"
+
+plot [-2000:60000] "hist.dat" u 1:2 w l t "103 reflection"
+EOF
+
+ps2pdf histo.ps
+rm -f histo.ps hist.dat
+
+evince histo.pdf