; plot_att $i $f
;
; plot a peak.
;
set mm = 2
set i = $_
set f = $_
if (exist("att[" // $i //"]")) then
   set l = $att[$i]
else
   error "Unknown peak"
endif

set f1 = (head($l)) set f2 = (head(tail($l)))
set f1i = (ptoi($f1,2,1))
set f2i = (ptoi($f2,2,2))

;print ("l "//$l)
set t = (tail(tail(tail($l))))
set u = (tolower(head($t))) 
set v = (tolower(head(tail($t)))) 
;if (tolower(head($t)) s! "unk" ) then
if (($u s! "unk" ) & ($v s! "unk" )) then
;   print ("t "//$t)
;   print (head(tail($t)))
   set s1 = ($spin[(head($t))])
   set s2 = ($spin[(head(tail($t)))])
   set t = (head(tail($s1)))
   set sys = (head(tail(tail($s1))))
   if ($sys s! "unk") then 
      set r1 = (head($sys[$sys]))
      set t = ($t // ":" // $r1)
   else
      set r1 = -10
      set t = ($t // "?")
   endif
   set t = ($t; "-"; head(tail($s2)))

   set sys = (head(tail(tail($s2))))
   if ($sys s! "unk") then 
      set r2 = (head($sys[$sys]))
      set t = ($t // ":" // $r2)
   else
      set r2 = -10
      set t = ($t // "?")
   endif

   plotlines ($f2i-$mm) ($f1i-$mm) ($f2i+$mm) ($f1i-$mm) $f
   plotlines ($f2i+$mm) ($f1i-$mm) ($f2i+$mm) ($f1i+$mm) $f
   plotlines ($f2i+$mm) ($f1i+$mm) ($f2i-$mm) ($f1i+$mm) $f
   plotlines ($f2i-$mm) ($f1i+$mm) ($f2i-$mm) ($f1i-$mm) $f

   plottexts $t ($f2i+$mm) ($f1i+$mm) $f
else
   plotlines ($f2i-$mm) $f1i ($f2i+$mm) $f1i $f
   plotlines $f2i ($f1i-$mm) $f2i ($f1i+$mm) $f

endif


