! Support for 
!     SHOW SNR and VIEW SNR
! as given by first argument &1
!
! We have  the following files
!
!   CLEAN   : Sky brightness distribution
!   WEIGHT  : relative weights, not normalized
!
! We compute the following: NOISE and SNR image
!
! 1)  Obtain a uniform noise image
if .not.exist(sky) then
  message E SHOW "SKY image does not exist"
  mapping_error = yes
endif
if .not.exist(weight) then
  message E SHOW "WEIGHT image does not exist"
  mapping_error = yes
endif
if (mapping_error) return base
!
if (exist(snr)) delete /var snr
define image snr * real /like sky /global
let snr sky*sqrt(weight)  ! Weight is 1/(Sum(1/Primary^2))
let snr 0 /where sky.eq.sky%blank[1]  ! Avoid blanking ...
let snr% sky%             ! Copy the header
let snr%blank 0 0         ! modify the blanking
let snr%unit " "  
!
let snr snr/sky%noise     ! Assume the theoretical noise per field is correct
let snr%noise 1
!
! 2) Compute the extrema
compute snr%min min snr /blank 0 0
compute snr%max max snr /blank 0 0
!
! 3) Show it
define char str*12
let str &1 /lower
defin char*8 stype
let stype spacing[2] /upper
if (stype.eq."SIGMA").or.(stype.eq."NOISE") then
  @ p_'str'_map SNR
else
  def character*16 old_space[2]
  let old_space 'spacing[1]' 'spacing[2]'
  let spacing 3 
  @ p_'str'_map SNR
  let spacing 'old_space[1]' 'old_space[2]'
endif
!
