clear all
close all

% choice which file to read
 filename=['G1to3/darwin_transect_surface_may.nc'];
%filename=['G1to3/darwin_transect_surface_allmonths.nc'];
%filename=['G1to3/darwin_transect_0to250m_may.nc'];
%filename=['G1to3/darwin_transect_0to250m_allmonths.nc'];
%
%filename=['G4to5NS/darwin_transect_surface_nov.nc'];
%filename=['G4to5NS/darwin_transect_surface_allmonths.nc'];
%filename=['G4to5NS/darwin_transect_0to250m_nov.nc'];
%filename=['G4to5NS/darwin_transect_0to250m_allmonths.nc'];

long=ncread(filename,'long');
lat=ncread(filename,'lat');
depth=ncread(filename,'depth');
month=ncread(filename,'month');
biomass=ncread(filename,'biomass');

ntim=length(month);
ndep=length(depth);


pltnt=1;
% plot all plankton at surface, each panel for a different group
if (pltnt==1),
for it=1:ntim
 figure
 for itype=1:7,
  if (itype==1), n1=1; n2=4; col=['g']; type=['pico']; end
  if (itype==2), n1=5; n2=9; col=['b']; type=['other nano']; end
  if (itype==3), n1=10; n2=14; col=['c']; type=['diazotroph']; end
  if (itype==4), n1=15; n2=23; col=['r']; type=['diatom']; end
  if (itype==5), n1=24; n2=31; col=['m']; type=['mixotroph']; end
  if (itype==6), n1=32; n2=47; col=['k']; type=['zooplankton']; end
  if (itype==7), n1=48; n2=50; col=['y']; type=['het bacteria']; end

  subplot(7,1,itype)
  for ip=n1:n2,
   if (ntim==1 & ndep==1), tmp=squeeze(biomass(ip,:)); end
   if (ntim>1 & ndep==1), tmp=squeeze(biomass(ip,:,it)); end
   if (ntim==1 & ndep>1), tmp=squeeze(biomass(ip,:,1)); end
   if (ntim>1 & ndep>1), tmp=squeeze(biomass(ip,:,1,it)); end
   plot(lat,tmp,[col,'-']);
   hold on
  end
  c=axis;
% axis([20 54 0 c(4)]);
  axis([20 54 0 4]);
  title(type);
  imon=month(it);
  if (itype==1), text(22,3,['month ',num2str(imon)]); end
  if (itype==3), ylabel('biomass (mgC/m3)'); end
  if (itype==7), xlabel('latitude'); end
 end % for itype
 orient tall,
 if (imon<10),
   eval(['print -dpng workshop_alltypes_surf_m0',num2str(imon),'.png']);
 else
   eval(['print -dpng workshop_alltypes_surf_m',num2str(imon),'.png']); 
 end % if
end % for it
end % pltnt

pltnt=1;
% plot group totals with depth each panel for a different group
if (pltnt==1),
if (ndep>1),
 for it=1:ntim
  figure
  for itype=1:7,
   if (itype==1), n1=1; n2=4; type=['pico']; end
   if (itype==2), n1=5; n2=9; type=['other nano']; end
   if (itype==3), n1=10; n2=14; type=['diazotroph']; end
   if (itype==4), n1=15; n2=23;  type=['diatom']; end
   if (itype==5), n1=24; n2=31;  type=['mixotroph']; end
   if (itype==6), n1=32; n2=47;  type=['zooplankton']; end
   if (itype==7), n1=48; n2=50;  type=['het bacteria']; end
 
   subplot(7,1,itype)
   if (ntim==1), tmp=squeeze(biomass(n1:n2,:,:)); end
   if (ntim>1), tmp=squeeze(biomass(n1:n2,:,:,it)); end
   tmp=squeeze(sum(tmp,1));
   pcolor(lat,depth,tmp'); shading flat, caxis([0 4]); colorbar
  axis([20 54 -250 0]);
  title(type);
  imon=month(it);
  if (itype==1), text(22,15,['month ',num2str(imon)]); end
  if (itype==3), ylabel('depth'); end
  if (itype==7), xlabel('latitude'); end
 end % for itype
 orient tall,
 if (imon<10),
   eval(['print -dpng workshop_groups_m0',num2str(imon),'.png']);
 else
   eval(['print -dpng workshop_groups_m',num2str(imon),'.png']);
 end %if
end % it
end % if ndep
end % pltnt
