Reading data form John Lehrter's xls file

Contents

Prim_Prod_2005-2007_for_Katja_Fennel_vertically_binned.xls

First the file has to be simplified because Matlab can't handle an xls file with multiple worksheets and certain features. I saved sheets as individual files.

Sheet 1: vertically integrated data

Read the data and organize in a structure.

fn = 'Prim_Prod_2005-2007_for_Katja_Fennel_vertically_binned_sheet1.xls';
[num,txt,raw] = xlsread(fn);
%
id = num(:,1);
for i=1:length(id)
  data.id(i) = id(i);
  data.cruise(i) = raw(i+1,2);
  data.stn{i} = raw{i+1,3};
  data.lat(i) = raw{i+1,4};
  data.lon(i) = raw{i+1,5};
  data.date(i) = X2mdate(raw{i+1,6}); % converts to Matlab's numdate format
  data.bott_depth(i) = raw{i+1,8};
  data.mld(i) = raw{i+1,9};
  data.salt(i) = raw{i+1,10};
  data.temp(i) = raw{i+1,11};
  data.Kd(i) = raw{i+1,12};
  data.I(i) = raw{i+1,13};
  data.surf_chl(i) = raw{i+1,14};
  data.int_chl(i) = raw{i+1,15};
  data.int_PP(i) = raw{i+1,16};
  data.PP_bel_mld(i) = raw{i+1,18};
  data.growth_rate(i) = raw{i+1,19};
end
Warning: XLSREAD has limited import functionality on non-Windows platforms
or in basic mode.  Refer to HELP XLSREAD for more information. 

Plot data from Sheet 1

Overview plot

figure
subplot(2,1,1)
hist(data.date,50)
datetick('x')
set(gca,'PlotBoxAspectRatio',[3 1.14335 1])
ylabel('# of stations')
%set(gca,'XMinorTick','on')
%set(gca,'XMinorGrid','on')
%
%figure
subplot(2,1,2)
plot(data.lon,data.lat,'.')
pnc

Then plot variables in space looping over time periods and setting global color-limits for each variable so all plots can be compared easily.

timelimits = [data.date(1)-1 datenum(2005,4,1) datenum(2005,10,30) ...
    datenum(2006,4,30) datenum(2006,6,30) datenum(2006,9,30) ...
    datenum(2007,5,30) datenum(2007,8,30)];
timestr = {'March 2005' 'Oct 2005' 'April 2006' 'June 2006' 'Sept 2006' ...
    'May 2007' 'Aug 2007'};
vars = {'surf_chl' 'int_chl' 'int_PP' 'growth_rate' 'Kd'};
vartitles = {' : surface chl (mg chl m^{-3}) ' ...
    ' : vertically integrated chl (mg chl m^{-2})' ...
    ' : vertically integrated pp (gC m^{-2} d^{-1})' ...
    ' : estimated growth rate (d^{-1})' ...
    ' : average vertical attenuation (m^{-1})' };
%varclimits = { [0 50] [0 350] [0 10] };
%set limits automatically
for v=1:length(vars)
  eval(['varclimits{v} = [0 3*median_nan(data.' vars{v} '(:))];'])
end
%
% Loop over cruises
for cr=1:length(timestr)
  ind = find(data.date>timelimits(cr) & data.date<timelimits(cr+1));
  for v=1:length(vars)
    eval(['nonnandata = sum(~isnan(data.' vars{v} '(ind)));'])
    if  nonnandata > 1
      figure
      eval(['colourplot(data.lon(ind),data.lat(ind),data.' vars{v} '(ind))'])
      caxis(varclimits{v})
      box on
      pnc
      colorbar
      title(strcat(timestr(cr),vartitles{v}))
    end
  end
end

Sheet 2: Chl-a profiles

Read the data and add to structure.

fn = 'Prim_Prod_2005-2007_for_Katja_Fennel_vertically_binned_sheet2.xls';
[num,txt,raw] = xlsread(fn);
%
depths = num(2,2:end);
chl = num(3:end,2:end);
id = num(3:end,1);
%
for i=1:length(id)
  % match id with data.id
  ind = find(data.id==id(i));
  % pull out meaningful part of the profile (i.e. above the bottom)
  bott_ind = find(depths<=data.bott_depth(ind));
  % add to structure
  data.chl_prof{i} = chl(i,bott_ind);
  data.depth_prof{i} = depths(bott_ind);
end
Warning: XLSREAD has limited import functionality on non-Windows platforms
or in basic mode.  Refer to HELP XLSREAD for more information. 

Plot chl profiles looping over cruises

for cr=1:length(timestr)
  ind = find(data.date>timelimits(cr) & data.date<timelimits(cr+1));
  figure
  subplot(1,2,1)
  plot(data.chl_prof{ind(1)},-data.depth_prof{ind(1)},'-')
  hold on
  for i=2:length(ind)
    plot(data.chl_prof{ind(i)},-data.depth_prof{ind(i)},'-')
  end
  title(timestr{cr})
  ylabel('depth (m)')
  xlabel('chl (mg m^{-3})')
  % zoom
  subplot(1,2,2)
  plot(data.chl_prof{ind(1)},-data.depth_prof{ind(1)},'-')
  hold on
  for i=2:length(ind)
    plot(data.chl_prof{ind(i)},-data.depth_prof{ind(i)},'-')
  end
  title(timestr{cr})
  ylabel('depth (m)')
  xlabel('chl (mg m^{-3})')
  axis([0 15 -50 0])
end

Sheet 3: PP profiles

Read the data and add to structure.

fn = 'Prim_Prod_2005-2007_for_Katja_Fennel_vertically_binned_sheet3.xls';
[num,txt,raw] = xlsread(fn);
%
depths = num(2,2:end);
pp = num(3:end,2:end);
id = num(3:end,1);
%
for i=1:length(id)
  % match id with data.id
  ind = find(data.id==id(i));
  % pull out meaningful part of the profile (i.e. above the bottom)
  bott_ind = find(depths<=data.bott_depth(ind));
  % add to structure
  data.pp_prof{i} = pp(i,bott_ind);
  data.depth_prof{i} = depths(bott_ind);
end
Warning: XLSREAD has limited import functionality on non-Windows platforms
or in basic mode.  Refer to HELP XLSREAD for more information. 

Plot PP profiles looping over cruises

for cr=1:length(timestr)
  ind = find(data.date>timelimits(cr) & data.date<timelimits(cr+1));
  figure
  subplot(1,2,1)
  plot(data.pp_prof{ind(1)},-data.depth_prof{ind(1)},'-')
  hold on
  for i=2:length(ind)
    plot(data.pp_prof{ind(i)},-data.depth_prof{ind(i)},'-')
  end
  title(timestr{cr})
  ylabel('depth (m)')
  xlabel('PP (mg C m^{-3} d^{-1})')
  % zoom
  subplot(1,2,2)
  plot(data.pp_prof{ind(1)},-data.depth_prof{ind(1)},'-')
  hold on
  for i=2:length(ind)
    plot(data.pp_prof{ind(i)},-data.depth_prof{ind(i)},'-')
  end
  title(timestr{cr})
  ylabel('depth (m)')
  xlabel('PP (mg C m^{-3} d^{-1})')
  axis([0 70 -50 0])
end