%N fndaxnum %F $MIR/src/subs/fndaxnum.for
%D Find the axis of a certain type
%P bpw
%: utilities
%B
      subroutine fndaxnum( tinp, type, axisname, axisnr )

      integer          tinp
      character*(*)    type
      character*1      axisname
      integer          axisnr

 This figures out which axis of a dataset is the 'lon', 'lat', 'freq'
 or 'stokes' axis. The output variables axisname and axisnr will
 contain the name and number of this axis.

 'lon' axes are all axes for which the ctype keyword starts with
 'ra', 'lon' or 'glon'. On return axisname='x', axisnr=1.
 'lat' axes are all axes for which the ctype keyword starts with
 'dec', 'lat' or 'glat'. On return axisname='y', axisnr=2.
 'freq' axes are all axes for which the ctype keyword starts with
 'velo', 'felo' or 'freq'. On return axisname='z', axisnr=3.
 'stokes' axes are all axes for which the ctype keyword starts with
 'stok'. On return axisname='a', axisnr=4.
 For example, requesting to know which axis is the 'lon' axis for a
 vel-ra-dec gives as result axisname='y' and axisnr=2.

 The 'type' input variable can also have one of the values 'x', 'y',
 'z', 'a' ... . In that case fndaxnum checks whether that axis is
 present in the dataset, and converts it to an axisnr. axisname is set
 equal to type on output.

 axisname is both input and output.
 On input it gives the default axisname to return if the axis of the
 specified type is not found. I.e.: if the axis is not found, it is
 not changed. The only allowed inputs are ' ', 'x', 'y', ... ,'d'.
 If the axis-type is found, axisname and axisnr are used to return
 the result.

 Input:
    tinp        Handle of dataset to check
    type        Axis to check (possible values are 'lon', 'lat',
                 'freq' and 'stokes')
    axisname    On input: default axisname if axis not found
    axisnr      On input: default axisnr if axis not found

 Output:
    axisname    On output: name of the axis found ( 'x', 'y', ... )
    axisnr      On output: Index of the axis found ( 1, 2, ... )
