chiark / gitweb /
put tick marks in the right places
[trains.git] / detpic / display-nmra
1 #!/bin/sh
2 set -ex
3
4 xpixels=1024
5 ypixels=768
6 ypersamp=8
7 fsd=0.3
8
9 perl -e <t.nmra.dat '
10         for (;;) {
11                 @l= ();
12                 $ticks= "";
13                 undef $tickat;
14                 print "\n"x3;
15                 for ($x=0; $x<'$xpixels'; $x++) {
16                         $_= <>;
17                         last unless length;
18                         next if m/^\;/;
19                         m/^\s*([-e0-9.]+)\s+([-0-9.]+)\s*$/ or die;
20                         ($t,$samp)=($1,$2);
21                         $h= sprintf "%d",
22                                 ($samp/(2.0*'$fsd') + 0.5) * ('$ypersamp'-1);
23                         for ($y=0, $l=0; $y<'$ypersamp'; $y+=2, $l++) {
24                                 $c= $h==$y ? "_" : $h==$y+1 ? "~" : " ";
25                                 $l[$l] .= $c;
26                         }
27                         if (!defined $tickat && $samp > 0 && $lastsamp < 0) {
28                                 $tickat= $t;
29                         }
30                         if (defined $tickat && $t >= $tickat) {
31                                 $ticks.= ".";
32                                 $tickat += 58e-6 * 2;
33                         } else {
34                                 $ticks.= " ";
35                         }
36                         $lastsamp= $samp if $samp < 0 || $samp > 0;
37                 }
38                 foreach $l (reverse @l) {
39                         print $l, "\n" or die $!;
40                 }
41                 print "\n"x2, $ticks, "\n"x6 or die $!;
42                 last unless length;
43         }
44 ' >t.nmra.ptxt
45
46 xterm -fn nil2 \
47         -geometry ${xpixels}x$(($ypixels * ($ypsersamp+1)/2)) \
48         -e less -sS t.nmra$rate.ptxt
49
50 exit 0