Fairly straight forward processing, no real surprises.  Low salinity water was abundant in the bay. This skewed the gradient a bit, so it was removed for sake of resolution throughout the entire cruise.  There were a handful of bad rows throughout the cruise, not sure what caused them but they were culled nonetheless.  As usual, couldn't really get a good regression between the fluorometer and chlorophyll.  

Files uploaded (5/1/10):

0901NH_CTDd.txt
0901NH_CTDvsUnderway.xlsx
0901NH_Notes.txt
0901NH_UnderwayFinal.txt
0901NH_UnderwayRaw.txt
c0901NHpath.pdf
c0901NHpath.png
c0901NHpath_t.png
s0901NHpath.pdf
s0901NHpath.png
s0901NHpath_t.png
t0901NHpath.pdf
t0901NHpath.png
t0901NHpath_t.png


0901NH.m file:

%% import data from 0901NH_UnderwayCrop.txt
%% this will give you a matrix called data xrows by 8, xrows should equal
%% total rows as can be seen by opening file in Ultra edit.  In this case
%% there are 95137 rows but only 2544 got imported.  This will fall out
%% when we check the lat long.  See below.
%% colheaders = {'DATE_UTC','TIME_UTC','LA','LO','ST','SA','FL','FI';} 
%% Rename and save this data
uhead = colheaders;
udata = data;
save u0901NH udata uhead
clear
 
%% Load the data
load u0901NH
 
%% Flow rates
%% Check the numbers, if a few are bad ignore, if there's alot remove as
%% necessary as resave
figure; plot(udata(:,8),'.')
%% Notes: deleted the last row
 
%% Position data
%% if gps drops out/innaccurate remove bad data
figure; plot(udata(:,4),udata(:,3),'.')
%% Notes plot siezed because of import.  Since it stopped on row 2544 we need
%% to go to that spot using UltraEdit and remove the bad data. Save in
%% UltraEdit and import again and again until all bad data is gone.
%% Bad data at 2544, 25893, 53195, 71674
 
%% That fixed the bad data, but now we have bad GPS.  This is easily found
%% by the fact that Lon is all negative, find anything smaller than 0 and
%% cull the rest
[i,j] = find (udata(:,4)<0);
udata = udata(i,:);
%% replot
figure; plot(udata(:,4),udata(:,3),'.')
%% looks good save it!
save u0901NH udata uhead
clear
load u0901NH
%% Check time
%% Should be uniform, could show an error, just good to check
figure; plot(udata(:,2)) %% looks good
 
%% Check temperature
figure; plot(udata(:,5),'.r') %% looks good
 
%% Check Salt
figure; plot(udata(:,6),'.b') %% not good, something's up
%% low salinity water in the bay (<32.9) is skewing things
[i,j] = find (udata(:,6)>32.9);
udata = udata(i,:);
 
 
%% Import ...CTDvUnderway.txt
cdata = data;
save u0901NH udata uhead cdata
clear
load u0901NH
 
%% TEMPERATURE
%% Derived linear regression using Excel
%% Enter appropriate values
p1 = 0.9455;
p2 = 0.9146;
%% cdata : T_AVG = col3, ST = col7
plot(cdata(:,3),cdata(:,7),'or');hold
%% we apply the regression to small ST sample
y = p1.*cdata(:,7) + p2;
plot(cdata(:,7),y,'ob')
%% udata : now apply to all ST
Y = p1.*udata(:,5) + p2;
plot(udata(:,5),Y,'.k')
%% Compare original and corrected
figure;hold;
plot(udata(:,5),'or')
plot(Y,'.k')
%% Corrected Underway Temperature vector
t0901NH = Y;
%% Clean up
clear ans p1 p2 y Y i j 
close all
 
%% SALINITY
%% Derived linear regression using Excel
%% Enter appropriate values
p1 = 0.9997;
p2 = 0.0001;
%% cdata : BTL_SALT = col5, SA = col8
plot(cdata(:,5),cdata(:,8),'or');hold
%% we apply the regression to small SA sample
y = p1.*cdata(:,8) + p2;
plot(cdata(:,8),y,'ob')
%% udata : now apply to all SA
Y = p1.*udata(:,6) + p2;
plot(udata(:,6),Y,'.k')
%% Compare original and corrected
figure;hold;
plot(udata(:,6),'or')
plot(Y,'.k')
%% Corrected Underway Salinity vector
s0901NH = Y;
%% Clean up
clear ans p1 p2 y Y i j 
close all
 
 
%% Fluorometer / ChlA
%% Derived linear regression using Excel
%% Enter appropriate values
p1 = 1.356;
p2 = 3.4236;
%% cdata : BTL_CHL = col6, FL = col9
plot(cdata(:,6),cdata(:,9),'or');hold
%% we apply the regression to small FL sample
y = p1.*cdata(:,9) + p2;
plot(cdata(:,9),y,'ob')
%% udata : now apply to all FL = col7
Y = p1.*udata(:,7) + p2;
plot(udata(:,7),Y,'.k')
%% Compare original and corrected
figure;hold;
plot(udata(:,7),'or')
plot(Y,'.k')
%% Corrected Underway ChlA vector
c0901NH = Y;
%% Clean up
clear ans p1 p2 y Y i j 
close all
 
udata = [udata t0901NH s0901NH c0901NH];
clear t0901NH s0901NH c0901NH % dont need them anymore
save u0901NH 
 
dlmwrite('0901NH_UnderwayFinal.txt', udata, 'delimiter', '\t','precision', '%.4f');
%%You will need to manually add the headers
%% DATE_UTC TIME_UTC LA LO ST SA FL FI CAL_T CAL_S CAL_C
 
%% Scatter Plots
load u0901NH;
load coast; load stacoor; % load coastline and station position
%% Subset the data ~ every 2.5 minutes
z = 1:10:length(udata);
data = ones(length(z),11); %% number here is the # of columns in udata it should always be 11 if you get an error here your matrix is too wide
for k = 1:length(z);
    data(k,:) = udata(z(k),:);  
end
%% Temperature
%% Path
figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold; %% these limits may change if you include data north or south of the standard calcofi lines
scatter(data(:,4),data(:,3),50,data(:,9),'filled') % plot temperature data
plot(coast(:,1),coast(:,2),'k','LineWidth', 2) % plot coastline
plot(stacoor(:,4),stacoor(:,3),'ok','MarkerSize',10) % plot station position
% set(gca,'clim', [10 26]); % set the color bar limit
colorbar('eastoutside'); % position the bar
colormapeditor; % edit the bar (1-blue(5,-4) : 32-white : 64-red(1,-2) : this is a custom function 
print -depsc -r300 t0901NHpath 
%% Contour
figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold;
[x y] = meshgrid (min(data(:,4)):.1:max(data(:,4)), min(data(:,3)):.1:max(data(:,3)) ); %minimum value:increment:maximum value of x and y axis grid
[xi,yi,zi] = griddata(data(:,4),data(:,3),data(:,9),x,y,'linear'); % grid the data
contourf(xi,yi,zi,'LineWidth', 2); % plotting the contour
plot(coast(:,1),coast(:,2),'k','LineWidth', 2) % plot coastline
plot(stacoor(:,4),stacoor(:,3),'ok','MarkerSize',10) % plot station position
grid on; box on;
% print -depsc -r300 t0901NHcon
 
%% Salinity
%% Path
figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold;
scatter(data(:,4),data(:,3),50,data(:,10),'filled') % plot salinity data
% caxis([32.4 34]); % set the color bar limit
colorbar('eastoutside');
% colorbar('YTickLabel',{'32.4','32.8','33.2','33.6','34.0'}); % position the bar
plot(coast(:,1),coast(:,2),'k','LineWidth', 2) % plot coastline
plot(stacoor(:,4),stacoor(:,3),'ok','MarkerSize',10) % plot station position
% set(gca,'clim', [32.4 34]); % set the color bar limit
colormapeditor; % edit the bar (1-blue(5,-4) : 32-white : 64-purple(8,-4)
print -depsc -r300 s0901NHpath 
%% Contour
figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold;
[x y] = meshgrid (min(data(:,4)):.1:max(data(:,4)), min(data(:,3)):.1:max(data(:,3)) ); %minimum value:increment:maximum value of x and y axis grid
[xi,yi,zi] = griddata(data(:,4),data(:,3),data(:,10),x,y,'linear'); % grid the data
contourf(xi,yi,zi,'LineWidth', 2); % plotting the contour
plot(coast(:,1),coast(:,2),'k','LineWidth', 2) % plot coastline
plot(stacoor(:,4),stacoor(:,3),'ok','MarkerSize',10) % plot station position
grid on; box on;
% print -depsc -r300 s0901NHcon
 
 
%% Fluorescence
%% 
[a,b] = find (udata(:,11)>15);
chl = (udata(a,:));
z = 1:10:length(chl);
sub = ones(length(z),11);
for k = 1:length(z);
    sub(k,:) = chl(z(k),:);  
end
figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold;
scatter(sub(:,4),sub(:,3),75,sub(:,11),'filled'); colorbar('eastoutside')
colormapeditor % to adjust the colors all red
%print -depsc -r300 c0901path
 
[x y] = meshgrid (min(sub(:,4)):.1:max(sub(:,4)), min(sub(:,3)):.1:max(sub(:,3)) ); %minimum value:increment:maximum value of x and y axis grid
[xi,yi,zi] = griddata(sub(:,4),sub(:,3),sub(:,11),x,y,'linear');
%gridding the temperature data to the above grid.
%‘cubic’ or any other interpolation methods can be used
figure; hold;
contourf(xi,yi,zi,'LineWidth', 2); %plotting the contour
colormapeditor % to adjust the colros
plot(coast(:,1),coast(:,2),'k','LineWidth', 2); plot(stacoor(:,4),stacoor(:,3),'k*');
ylim([29 37]); xlim([-125 -117]);
%print -depsc -r300 c0901con