1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-04 23:23:43 +02:00

usrp/sps/: added min/avg/max summary image

- range: generate min/avg/max data from FFT files
- vizr: plot the output of "range"
- row: make "viz" keep the FFT output and use it to generate the summary
This commit is contained in:
Werner Almesberger 2011-03-05 19:34:07 -03:00
parent 34722a54ef
commit bcd6e09189
3 changed files with 135 additions and 8 deletions

53
usrp/sps/range Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/perl
sub read
{
local ($n) = "$_[0].fft";
local (@f);
local $i = 0;
local $ym, $v;
open(FILE, $n) || die "$n: $!";
while (<FILE>) {
chop;
push(@f, $_);
$ym = $_ unless defined $ym && $ym > $_;
}
close FILE;
for (@f) {
$v = $_-$ym;
$min[$i] = $v unless defined $min[$i] && $min[$i] < $v;
$max[$i] = $v unless defined $max[$i] && $max[$i] > $v;
$sum[$i] += $v;
$i++;
}
}
sub usage
{
print STDERR "usage: $0\n";
exit(1);
}
&usage if @ARGV;
#
# @@@ for future study: use an x axis proportional to the center frequency,
# instead of an absolute frequency.
#
for ($f = 2405; $f <= 2480; $f += 5) {
&read($f);
&read($f+1);
$n += 2;
}
$mhz_per_bin = 100.0/16/@sum; # 100 MHz ADC, decimation 16
$, = " ";
for ($i = 0; $i != @sum; $i++) {
print $mhz_per_bin*($i-@sum/2)+0.5, "";
print $min[$i], $sum[$i]/$n, $max[$i], "\n";
}

View File

@ -23,35 +23,55 @@ for prefix in "$@"; do
color=' bgcolor="#a0e0ff"'
fi
last=$prefix
echo "<TR$color><TH>$prefix"
echo "<TR$color><TH>$prefix<TD align=\"center\">Offset"
f=2405
while [ $f -le 2480 ]; do
echo "<TD align="center">$f MHz"
echo "<TD align=\"center\">$f MHz"
f=`expr $f + 5`
done
echo "<TR><TD align="right">-0.5 MHz"
echo "<TR>"
echo "<TD><A href=\"$prefix.png\"><IMG src=\"$prefix-small.png\"></A>"
echo "<TD align="right">-0.5 MHz"
f=2405
while [ $f -le 2480 ]; do
./viz -f LiberationSans-Bold -p $prefix-$f.png $prefix $f
./viz -f LiberationSans-Bold -p $prefix-$f.png \
-o $f.fft $prefix $f
convert -resize '15%' $prefix-$f.png $prefix-$f-small.png
echo "<TD><A href=\"$prefix-$f.png\"><IMG src=\"$prefix-$f-small.png\"></A>"
f=`expr $f + 5`
done
echo "<TR><TD align="right">+0.5 MHz"
echo "<TR>"
echo "<TD>"
echo "<TD align="right">+0.5 MHz"
f=2405
while [ $f -le 2480 ]; do
f1=`expr $f + 1`
./viz -f LiberationSans-Bold -p $prefix-$f1.png $prefix $f1
./viz -f LiberationSans-Bold -p $prefix-$f1.png \
-o $f1.fft $prefix $f1
convert -resize '15%' $prefix-$f1.png $prefix-$f1-small.png
echo "<TD><A href=\"$prefix-$f1.png\"><IMG src=\"$prefix-$f1-small.png\"></A>"
f=`expr $f + 5`
done
done
ffts=`
f=2405
while [ $f -le 2480 ]; do
echo $f.fft
echo \`expr $f + 1\`.fft
f=\`expr $f + 5\`
done`
./range >_tmp
./vizr -f LiberationSans-Bold -p $prefix.png $prefix _tmp
rm -f $ffts _tmp
convert -resize '15%' $prefix.png $prefix-small.png
done
cat <<EOF
</TABLE>
EOF

54
usrp/sps/vizr Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
usage()
{
echo "usage: $0 [-f font] [-p png_file] prefix range_file" 1>&2
exit 1
}
font=
term=
output=
while true; do
case "$1" in
-f) [ "$2" ] || usage
shift
font=$1;;
-p) [ "$2" ] || usage
shift
term="set term png"
output="set output \"$1\"";;
-*) usage;;
*)
break;;
esac
shift
done
[ "$2" ] || usage
[ "$3" ] && usage
prefix=$3
file=$2
gnuplot -persist <<EOF
$term
$output
set label "$prefix" at graph 0.03, graph 0.93 font "$font,22"
set xrange [-2.5:2.5]
set yrange [-70:0]
set mxtics 10
set mytics 2
set grid
set xlabel "MHz from nominal frequency of test wave"
plot "$file" using 1:4 with lines title "max" lt 2, \
"$file" using 1:3 with lines title "avg" lt 3, \
"$file" using 1:2 with lines title "min" lt 1
EOF