!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! p_axes.ima 
!   S.Guilloteau
!
! Define the type of box axes units and and legends
!
! &1 : Image Header
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
define character kind*1 legend*20
define integer iunit 
!
if exist(i_x) delet /var i_x
if exist(i_y) delet /var i_y
if exist(i_f) delet /var i_f
define integer i_x i_y i_f /global
let i_x &1%x_axis
let i_y &1%y_axis
let i_f &1%f_axis
if (i_x*i_y*i_f).ne.6 then
  let i_x 1
  let i_y 2
  let i_f 3
endif
!
! Define the projection even if wrong ordering, to get proper axes
if (i_x*i_y.ne.2).and.(&1%ptype.ne.0) then
  define char*12 projnam[11]
  !      'NONE         ',  &
  let projnam "GNOMONIC     "    "ORTHOGRAPHIC "    "AZIMUTHAL    " - 
    "STEREOGRAPHIC"    "LAMBERT      "   "AITOFF       " - 
    "RADIO        "    "SFL          "   "MOLLWEIDE    " - 
    "NCP          "    "CARTESIAN    "
  if (&1%system.eq."EQUATORIAL") then
    greg2\projection &1%a0*12/pi &1%d0*180/pi &1%angle*180/pi /type 'projnam[&1%ptype]'
  else
    greg2\projection &1%a0*180/pi &1%d0*180/pi &1%angle*180/pi /type 'projnam[&1%ptype]'
  endif
endif
!
@ d_box     ! Set the box label and units
let iunit max(angle_unit,0) ! 0 <==> ABSOLUTE
!
define character*12 cunitx cunity
let cunitx &1%unit'i_x' /format a12
let cunity &1%unit'i_y' /format a12
!
! X Legend and coordinate definitions
let kind 'box%bunit'
if (cunitx.eq."RA") then
  if (abs(&1%angle).gt.1E-5) then
    let legend "\Gdx "'box%gunit'
  else if (cunity.eq."DEC").and.iunit.eq.0 then
    let legend "R.A."
    let kind "ABS"
  else
    let legend "\GdR.A. "'box%gunit'
  endif
else if (cunitx.eq."DEC") then
  if (abs(&1%angle).gt.1E-5) then
    let legend "\Gdy "'box%gunit'
  else if (cunity.eq."RA").and.iunit.eq.0 then
    let legend "Dec"
    let kind "ABS"
  else
    let legend "\GdDec  "'box%gunit'
  endif
else if (cunitx.eq."ANGLE") then
  let legend "\Gdx "'box%gunit'
else
  let legend '&1%unit1'
  let kind "r" ! Other --> Radian, i.e. natural units, no conversion
endif
let box%kindx 'kind'
let box%legendx 'legend'
!
! Y Legend and coordinate definitions
let kind 'box%bunit'
if (cunity.eq."RA") then
  if (abs(&1%angle).gt.1E-5) then
    let legend "\Gdy "'box%gunit'
  else if (cunitx.eq."DEC").and.iunit.eq.0 then
    let legend "R.A."
    let kind "ABS" 
  else
    let legend "\GdR.A. "'box%gunit'
  endif
else if (cunity.eq."DEC") then
  if (abs(&1%angle).gt.1E-5) then
    let legend "\Gdy "'box%gunit'
  else if (cunitx.eq."RA").and.iunit.eq.0 then
    let legend "Dec"
    let kind "ABS"
  else
    let legend "\GdDec  "'box%gunit'
  endif
else if (cunity.eq."ANGLE") then
  let legend "\Gdy "'box%gunit'
else
  let legend '&1%unit2'
  let kind "r" ! Other
endif
let box%kindy 'kind'
let box%legendy 'legend'
!
