function printsirhead(head,descrip,iaopt)
%
%   printsirhead(head,descrip,iaopt)
%
% prints information from the SIR file header info arrays from loadsir
%
% head:       scaled header information block
% descrip:    second header description string (optional)
% iaopt:      second header integer array (optional)
%

% version 2.0 header   written 19 March 1997 by DGL
%
%	header mapping (see code for scaling of <= variables)
%
%	head(1)	= nsx			! pixels in x direction
%	head(2) = nsy			! pixels in y direction
%       head(3) <= xdeg			! span of deg in x
%	head(4) <= ydeg			! span of deg in y
%	head(5) = nhtype                ! header type (old<15)
%	head(6) <= ascale               ! x scaling
%	head(7) <= bscale               ! y scaling
%	head(8) <= a0                   ! x (lon) origin
%         note: longitudes should be in the range -180 to 180
%	head(9) <= b0                   ! y (lat) origin
%	head(10) = ioff			! offset to be added to scaled val
%	head(11) = iscale		! scale factor ival=(val-ioff)/iscale
%	head(12) = iyear		! year for data used
%	head(13) = isday		! starting JD
%	head(14) = ismin		! time of day for first data (in min)
%	head(15) = ieday		! ending JD
%	head(16) = iemin		! time of day for last data (in min)
%	head(17) = iopt			! projection type
%					!  -1 = no projection, image only
%					!   0 = rectalinear lat/lon
%					!   1 = lambert equal area
%					!   2 = lambert equal area (local rad)
%					!   5 = polar stereographic
%					!  11 = EASE north equal area grid
%					!  12 = EASE south equal area grid
%					!  13 = EASE cylindrical grid
%	head(18) = iregion		! region id code
%	head(19) = itype		! image type code
%                                       ! standard values: 0=unknown or n/a
%                                       ! 1 = scatterometer A (dB)
%                                       ! 2 = scatterometer B (dB/deg)
%                                       ! 3 = radiometer Tb (K)
%                                       ! 9 = topography (m)
%	head(20:39) 40 chars of sensor
%       head(40) = 0 
%       head(41) = nhead                ! number of 512 byte header blocks
%       head(42) = ndes                 ! number of 512 byte blocks description
%       head(43) = ldes                 ! number of bytes of description
%       head(44) = nia                  ! number of optional integers
%       temp(45) = ipol                 ! polarization (0=n/a,1=H,2=V)
%       temp(46) = ifreqhm              ! frequency in GHz (0 if n/a)
%       temp(47) = ispare1              ! spare
%       head(48) = idatatype            ! data type code 0,2=i*2,1=i*1,4=f
%       the value of idata type determines how data is stored
%
%       if idatatype = 1 data is stored as bytes and minv=128
%       if idatatype = 2 data is stored as 2 byte integers and minv=32766
%       if idatatype = 4 data is stored as IEEE floating point
%
%       if idatatype = 1,2 anodata,vmin,vmax are stored as 2 byte integers
%         in head(49)..head(51)  minv, ioff and iscal used to convert
%         integers or bytes into floating point values
%         nodata, vmin, and vmax must be representable with ioff and iscale
%            head(*) = (value-ioff)*iscale-minv
%            value = float(head(*)+minv)/float(iscale)+ioff
%       idatatype=2 is considered the SIR standard format
%
%       if idatatype = f anodata,vmin,vmax are stored as floating points
%         in head(52)..head(57) and minv, ioff and iscale are ignored here
%         and when reading the file.
%         floating point numbers are NOT standard across platforms and
%         is not recommended
%
%       For matlab implementation, head(49:51) hold floating point
%       values.  head(52:57) not used
%
%       head(49) <= anodata            ! value representing no data
%       head(50) <= vmin               ! minimum useful value from creator prg
%       head(51) <= vmax               ! maximum useful value from creator prg
%       head(52:53) = anodata          ! IEEE floating value of no data
%       head(54:55) = vmin             ! IEEE floating minimum useful value
%       head(56:57) = vmax             ! IEEE floating maximum useful value
%
%	head(58:126) 138 chars of type
%       head(127) = 0 
%       head(128) = 0 
%	head(129:168) 80 chars of title
%       head(169) = 0 
%	head(170:189) 40 chars of tag
%       head(190) = 0 
%	head(191:240) 100 chars of crproc
%       head(241) = 0 
%	head(242:255) 28 chars of crtime
%       head(256) = 0 
%
%     optional header blocks:
%
%	ndes header blocks of 512 bytes: chars of description
%	nhead-ndes-1 header blocks of 512 bytes: values of iaopt
%       by convention, first value iaopt is a code telling how to interpret
%       the rest of the array if nia>0
%
%       remainder of file is image data in a multiple of 512 byte blocks
%       two byte integer and byte scaling is
%          intval = (fvalue-ioff)*iscale-minv
%          fvalue = float(intval+minv)/float(iscale)+ioff
%

nhtype=head(5);
nhead=head(41);
if nhtype == 1
  nhead = 1;
end;
ndes=head(42);
ldes=head(43);
nia=head(44);
idatatype=head(48);
iopt = head(17);		% transformation option
iscale=head(11);
ioff=head(10);
nsx = head(1);
nsy = head(2);
xdeg = head(3);
ydeg = head(4);
ascale = head(6);
bscale = head(7);
a0 = head(8);
b0 = head(9);

if iopt == -1				% image only
  disp(['Image only form ' num2str(nhtype)]);
  disp(['  x,y scale:   ' num2str(ascale) ', ' num2str(ascale)]);
  disp(['  x,y offsets: ' num2str(a0) ', ' num2str(b0)]);
  disp(['  x,y span:    ' num2str(xdeg) ', ' num2str(ydeg)]);
elseif iopt == 0			% rectalinear
  disp(['Lat/Long Rectangular form ' num2str(nhtype)]);
  disp(['  x,y scale: (pix/deg) ' num2str(ascale) ', ' num2str(ascale)]);
  disp(['  x,y offsets: (deg)   ' num2str(a0) ', ' num2str(b0)]);
  disp(['  x,y span: (deg)      ' num2str(xdeg) ', ' num2str(ydeg)]);
elseif (iopt == 1) | (iopt == 2) 	% lambert
  if (iopt == 1)
    disp(['Lambert form (global radius) ' num2str(nhtype)]);
  else
    disp(['Lambert form (local radius) ' num2str(nhtype)]);
  end;
  disp(['  x,y scale: (km/pix) ' num2str(ascale) ', ' num2str(ascale)]);
  disp(['  x,y corner: (km)    ' num2str(a0) ', ' num2str(b0)]);
  disp(['  x,y span: (deg)     ' num2str(xdeg) ', ' num2str(ydeg)]);
elseif iopt ==5			% polar stereographic
  disp(['Polar Stereographic form ' num2str(nhtype)]);
  disp(['  x,y scale: (km/pix) ' num2str(ascale) ', ' num2str(ascale)]);
  disp(['  x,y offsets: (km)   ' num2str(a0) ', ' num2str(b0)]);
  disp(['  Center: (lon,lat)   ' num2str(xdeg) ', ' num2str(ydeg)]);
elseif (iopt == 11) | (iopt == 12) | (iopt == 13) % EASE grid
  disp(['EASE form ' num2str(nhtype)]);
  disp(['  Scale: (c,r)  ' num2str(ascale) ', ' num2str(ascale)]);
  disp(['  Origin: (c,r) ' num2str(a0) ', ' num2str(b0)]);
  disp(['  Center: (c,r) ' num2str(xdeg) ', ' num2str(ydeg)]);
else
  disp('*** Unrecognized SIR option in loadsir ***');
end;

disp(['  Pixels:  ' num2str(nsx) ' by ' num2str(nsy)]);
disp(['  Year: ' num2str(head(12)) '  Start Day: ' num2str(head(13)) ...
      '  Min: '  num2str(head(14))]);
disp(['  End Day: ' num2str(head(15)) '   Min: ' num2str(head(16))]);
disp(['  Region: ' num2str(head(18))  '  Type: ' num2str(head(19)) ...
      '  Htype: ' num2str(head(5))  '  Nhead: ' num2str(nhead)]);
disp(['  Frequency: ',num2str(head(46)),'  Pol: ',num2str(head(45))]);
disp(['  Nodata value: ' num2str(head(49))  '  Vmin: ' ...
      num2str(head(50)) '  Vmax: ' num2str(head(51))]);

if idatatype == 4
  disp(['  Datatype: float']);
elseif idatatype == 1
  disp(['  Datatype: byte']);
else
  disp(['  Datatype: short']);
end;

sensor(40)=0;
for i=1:20
  j=(i-1)*2+1;
  sensor(j)=(mod(head(i+19),256));
  sensor(j+1)=floor(head(i+19)/256);
end;
disp(['  Sensor: ',deblank(setstr(sensor))]);
title(80)=0;
for i=1:40
  j=(i-1)*2+1;
  title(j)=(mod(head(i+128),256));
  title(j+1)=floor(head(i+128)/256);
end;
disp(['  Title: "',deblank(setstr(title)),'"']);
if (nhtype > 1)
  type(138)=0;
  for i=1:69
    j=(i-1)*2+1;
    type(j)=(mod(head(i+57),256));
    type(j+1)=floor(head(i+57)/256);
  end;
  disp(['  Type:  "',deblank(setstr(type)),'"']);
  tag(40)=0;
  for i=1:20
    j=(i-1)*2+1;
    tag(j)=(mod(head(i+169),256));
    tag(j+1)=floor(head(i+169)/256);
  end;
  disp(['  Tag:   "',deblank(setstr(tag)),'"']);
  crp1(100)=0;
  for i=1:50
    j=(i-1)*2+1;
    crp1(j)=(mod(head(i+190),256));
    crp1(j+1)=floor(head(i+190)/256);
  end;
  disp(['  Creator: "',deblank(setstr(crp1)),'"']);
  crt1(28)=0;
  for i=1:14
    j=(i-1)*2+1;
    crt1(j)=(mod(head(i+241),256));
    crt1(j+1)=floor(head(i+241)/256);
  end;
  disp(['  Created: ',deblank(setstr(crt1))]);
end;

if nhead > 1
  if ndes > 0
    if (exist('descrip') == 1)
      disp(['  Extra Description: ' setstr(descrip)])
    else
      disp(['  Extra desription characters: ' num2str(ldes)]);
    end;
  end;
  if nia > 0
    disp(['  Extra integers: ' num2str(nia) ]);
%    iaopt'
  end;
end;




