%
% test m_loadsir for various .sir file projections
%

% Lambert
figure(1)
S=m_loadsir('/auto/archive/sir/data/greeni.sir','show');
m_gshhs_l('color','k'); % add low res coastline overlay
disp(S);
drawnow

% polar stereographic
figure(2) 
subplot(1,2,1)
S=m_loadsir('/auto/archive/sir/data/queh-a-Arc99-201-201.sir','show');
m_gshhs_c('color','k'); % add coarse res coastline overlay
subplot(1,2,2)
S=m_loadsir('/auto/archive/sir/data/queh-a-Ant99-201-201.sir','show');
m_gshhs_c('color','r');             % add coarse coastline overlay
printsirhead(S.head);
disp(S);
drawnow

% rectalinear lat/lon grid
figure(3)
S=m_loadsir('/auto/archive/sir/data/a_worldv.sir','show');
m_gshhs_c('color','k'); % add coarse res coastline overlay
disp(S);
drawnow

% Lambert
S=m_loadsir('/auto/archive/sir/data/nscv-a-NAm96-312-317.sir');
disp(S);
figure(4)
subplot(2,1,1)
% default map size is set by max corners
m_pcolor(S.lon,S.lat,S.im); shading flat; % plot
m_gshhs_l('color','k');             % add low res coastline overlay
m_grid('linewi',2,'tickdir','out'); % add grid
m_northarrow(-65,30,5,'type',1,'linewi',0.5); % add northarrow
h=colorbar;
set(get(h,'ylabel'),'String','\sigma^o(40^o) (dB)');
title(S.title);
subplot(2,1,2)
% Lambert reduced map coverage area
m_proj(S.proj,'lon',[-130,-60],'lat',[24,50],'clon',S.clon,'ell',S.ell);
S.im(S.im<-31.5)=nan;               % remove ocean
m_pcolor(S.lon,S.lat,S.im); shading flat; % plot
m_gshhs_l('color','k');             % add low res coastline overlay
%m_grid('tickdir','out');           % add normal grid
m_grid('box','fancy','tickdir','in'); % add fancy grid box
m_northarrow(-65,30,5,'type',1,'linewi',0.5); % add northarrow
m_ruler(-0.25,[.5 1]);              % add scale ruler 
h=colorbar;
set(get(h,'ylabel'),'String','\sigma^o(40^o) (dB)');
title(S.title);
drawnow

%%%%%%%%%%%%%
% note: EASE2 images are often very large and take LOTS of memory
figure(6)
S=m_loadsir('/auto/archive/sir/data/queh-a-E2N04-10-10.sir','show');
m_gshhs_c('color','k');             % add coarse coastline overlay

figure(7)
% Note: for southern hemisphere, need to set xaxislocation to top
S=m_loadsir('/auto/archive/sir/data/queh-a-E2S04-10-10.sir');
m_pcolor(S.lon,S.lat,S.im); shading flat; % plot
m_gshhs_c('color','r');             % add coarse coastline overlay
m_grid('tickdir','out','xaxislocation','top'); % add grid
colorbar;
title(S.title);
drawnow

if 0
  % EASE2-G is often exceptionally large, so don't use default m_pcolor
  figure(6)
  S=m_loadsir('/auto/archive/sir/data/queh-a-E2T04-10-10.sir','show');
  %m_gshhs_c('color','k'); % add coarse coastline overlay
  disp(S);
  drawnow
else % use m_image instead of m_pcolor (only for cylindrical projections)
  figure(6)
  S=m_loadsir('/auto/archive/sir/data/queh-a-E2T04-10-10.sir');
  rlon=S.lon(1,:);
  rlat=S.lat(:,1);
  S.lon=[]; S.lat=[]; % optionally save space
  m_image(rlon(:),rlat(:),S.im);
  % add fancy grid and decorations
  m_grid('box','fancy','tickdir','in');
  m_northarrow(-160,-25,40,'type',1);
  m_gshhs_c('color','k'); % add coarse coastline overlay
  disp(S);
  drawnow  
end
