Root/usrp/sps/viz

Source at commit 49e7c83796bc04941e9dbcec69bc0751563ff4d4 created 2 years 3 months ago.
By Werner Almesberger, atusb/: use ""VDD" symbol from kicad-libs
1#!/bin/sh
2
3PATH=..:$PATH
4
5usage()
6{
7    echo "usage: $0 [-f font] [-m] [-o fft_file] [-p png_file] prefix \
8frequency" 1>&2
9    exit 1
10}
11
12
13font=
14term=
15output=
16show_max=false
17out=
18
19while true; do
20    case "$1" in
21    -f) [ "$2" ] || usage
22        shift
23        font=$1;;
24    -m) show_max=true;;
25    -o) [ "$2" ] || usage
26        shift
27        out=$1;;
28    -p) [ "$2" ] || usage
29        shift
30        term="set term png"
31        output="set output \"$1\"";;
32    -*) usage;;
33    *)
34        break;;
35    esac
36    shift
37done
38
39[ "$2" ] || usage
40[ "$3" ] && usage
41
42tmp=${out:-_tmp}
43prefix=$1
44f=$2
45
46fft -s 100 -d -w hamming 100 <$prefix-$f >$tmp
47set `norm $tmp`
48
49xm=$1.0 # sample number of y peak
50ym=$2 # magnitude of y peak
51n=$3 # total number of samples
52span=6.25 # ADC sample rate in MHz / decimation (100 MHz/16)
53
54if [ ${ym#-} = $ym ]; then
55    ymbar=-$ym
56    ymbarlt=2
57else
58    ymbar=$ym
59    ymbarlt=1
60fi
61
62gnuplot -persist <<EOF
63$term
64$output
65
66set label "$prefix" at graph 0.03, graph 0.93 font "$font,22"
67set label sprintf("%+.1f dB", $ym) at graph 0.03, graph 0.82 font "$font,18"
68
69set label sprintf("%.1f MHz", $f-0.5) \
70  at graph 0.97, graph 0.93 right font "$font,22"
71set label sprintf("%+.1f ppm", (($xm/$n-0.5)*$span+0.5)/($f-0.5)*1000000) \
72  at graph 0.97, graph 0.82 right font "$font,18"
73
74set xrange [-2.5:2.5]
75set yrange [-70:0]
76
77set mxtics 10
78set mytics 2
79set grid
80
81set xlabel "MHz from nominal frequency of test wave"
82
83set style fill solid 1
84plot "$tmp" using ((\$0/$n-0.5)*$span+0.5):(\$1-$ym) with lines notitle, \
85  "<echo -0.9 $ymbar 0.2" with boxes lt $ymbarlt notitle
86EOF
87
88[ "$out" ] || rm -f $tmp
89$show_max && echo $ym
90

Archive Download this file



interactive