!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
begin procedure show-moments-header
  g\set expand 1.0
  @ l-header-def cubego%show
  @ l-header-load 'name'":*moment,area,signal*" cubego%show
  pane 1 1.5
  draw text -4 0 'cubego%show%id'" "'cubego%show%family'" &1" 5 90 /char 4
  panel 2 2
  @ l-header-draw-desc cubego%show 0 2.0 5 0 8
end procedure show-moments-header
!  
begin procedure show-moments-one
  define integer ix iy
  let ix &1
  let iy &2
  define character cubeid*256 scaling*3 scale*1 title*32
  let title "&3"
  let cubeid 'name'":*moment,&4,&5*"
  let scaling "&6"
  let scale "&7"
  !
  load 'cubeid' /shape /into n
  panel 'ix' 'iy' /aspect n%l/n%m
  if (scale.ne."=") then 
     load 'cubeid' /extrema /into ext global
     define real ext%rmin ext%rmax /global
     let ext%rmin 'ext%min%val'
     let ext%rmax 'ext%max%val'
  endif
  load 'cubeid' /first image /into image
  limits /rg
  if (scaling.eq."lin") then
     plot /scaling lin 'ext%min%val' 'ext%max%val'
  else if (scaling.eq."log") then
     if (ext%rmax.le.0) then
        let ext%rmin 1
        let ext%rmax 1
     else if (ext%rmin.le.0) then
        load 'name'":*moment,&4,noise*" /extrema /into noiext
        let ext%rmin 'noiext%min%val'
     endif
     plot /scaling log 'ext%rmin' 'ext%rmax'
!!$     if (ext%rmin.lt.0.1) then
!!$        plot /scaling log 0.5 'ext%rmax'
!!$     else
!!$        plot /scaling log 'ext%rmin' 'ext%rmax'
!!$     endif
  else
     return base
  endif
  if ((ix.eq.1).and.(iy.eq.1)) then
     box /unit sec
     g\label "\gdR.A." /x
     g\label "\gdDec" /y 3.5
  else if (ix.eq.1) then
     box n o /unit sec
     g\label "\gdDec" /y 3.5
  else if (iy.eq.1) then
     box p n /unit sec
     g\label "\gdR.A." /x
  else
     box n n /unit sec
  endif
  wedge right 0.3
  draw text 0 1 'title' 6 0 /char 7
  load 'cubeid' /unit /into unit
  draw text 0 1 "["'unit'"]" 6 0 /char 9
end procedure show-moments-one
! 
begin procedure show-moments-all
  define character kind*12
  let kind "&1"
  if (kind.eq." ") then
     let kind "signal"
  else if ((kind.ne."signal").and.(kind.ne."noise").and.(kind.ne."snr")) then
     message e show-moments "Usage @ show-moments [signal|noise|snr]"
     return base
  endif
  define character scaling*3 scale*1
  if (kind.eq."signal") then
     let scale "="
     let scaling "lin"
  else
     let scale ""
     let scaling "log"
  endif
  !
  clear
  ! *** JP: inter should be customized depending on the aspect ratio.
!  panel /def /nxy 3 2 /inter 0.4 0.15
  panel /def /nxy 3 2 /inter 0.3 0.2
  g\set expand 0.6
  @ blank-color black
  !
  @ show-moments-one 1 2 "Peak Temperature"           peak,brightness   'kind' log
  @ show-moments-one 1 1 "Line Integrated Profile"    area              'kind' log
  !
  @ show-moments-one 2 2 "Peak Velocity"              peak,velocity     'kind' 'scaling'
  @ show-moments-one 2 1 "Centroid Velocity"          centroid,velocity 'kind' 'scaling' 'scale'
  !
  @ show-moments-one 3 2 "Equivalent Width"           equivalent,width  'kind' log
  @ show-moments-one 3 1 "Full Width at Half Maximum" fwhm,width        'kind' log 'scale'
  !
  @ show-moments-header 'kind'
end procedure show-moments-all
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
@ l-header.cube
@ show-moments-all &1
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
