clear 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);

for ityp=1:9
  if (ityp==1), n1=1; n2=1; namestr=['Pro']; end
  if (ityp==2), n1=2; n2=2; namestr=['Syn']; end
  if (ityp==3), n1=3; n2=4; namestr=['PicoEuk']; end
  if (ityp==4), n1=5; n2=9; namestr=['OtherNano']; end
  if (ityp==5), n1=10; n2=14; namestr=['Diazotrophs']; end
  if (ityp==6), n1=15; n2=23; namestr=['Diatom']; end
  if (ityp==7), n1=24; n2=31; namestr=['Mixo']; end
  if (ityp==8), n1=32; n2=47; namestr=['Zoo']; end
  if (ityp==9), n1=48; n2=50; namestr=['HetBact']; end
  if (ntim==1 & ndep==1), group(ityp,:)=squeeze(sum(biomass(n1:n2,:),1)); end
  if (ntim==1 & ndep>1), group(ityp,:,:)=squeeze(sum(biomass(n1:n2,:,:),1)); end
  if (ntim>1 & ndep==1), group(ityp,:,:)=squeeze(sum(biomass(n1:n2,:,:),1)); end
  if (ntim>1 & ndep>1), group(ityp,:,:,:)=squeeze(sum(biomass(n1:n2,:,:,:),1)); end
end % for itype
