%% import data from 1011NH_UnderwayCrop.txt %% this will give you a matrix called data xrows by 6, xrows should equal %% total rows as can be seen by opening file in Ultra edit. In this case %% there are 101941 rows and all imported. %% colheaders = {LA','LO','ST','SA','FL','FI';} %% Rename and save this data % uhead = colheaders; data=importdata('1203_UnderwayCrop.txt') udata = data.data; save u1203NH udata %uhead clear %% Load the data load u1203NH %% Flow rates %% Check the numbers, if a few are bad ignore, if there's alot remove as %% necessary as resave %figure; plot(udata(:,8),'.') %% Position data %% if gps drops out/innaccurate remove bad data %figure; plot(udata(:,4),udata(:,3),'.') %% Both check out, if bad check out 0901NH.m file for some more info %% Check time %% Should be uniform, could show an error, just good to check %% Check temperature %figure; plot(udata(:,5),'.r') %% Check Salt %figure; plot(udata(:,6),'.b') %% keep them as they are legit %% Import ...CTDvUnderway.txt only 10 columns date/time did not import data=importdata('1203_CTDvsUnderway.txt') cdata = data; save u1203NH udata cdata clear load u1203NH %% TEMPERATURE %% Derived linear regression using Excel y = 0.9883x + 0.4348 Rē = 0.9659 %% Enter appropriate values p1 = .8565; p2 = 2.0381; %% 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 t1203NH = Y; %% Clean up clear ans p1 p2 y Y i j close all %% SALINITY %% Derived linear regression using Excel y = 1.0028x - 0.1047 Rē = 0.992 %% Enter appropriate values p1 = .8489; p2 = 5.0365; %% 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 s1203NH = Y; %% Clean up clear ans p1 p2 y Y i j close all %% Fluorometer / ChlA %% Data y = 2.438x + 1.573 Rē = 0.6574 %% Enter appropriate values %p1 = 1.0854; %p2 = .8042; %% cdata : BTL_CHL = col8, FL = col11 %plot(cdata(:,6),cdata(:,9),'or');hold %% we apply the regression to small FL sample %y = p1.*cdata(:,6) + p2; %plot(cdata(:,6),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 %c1210NH = Y; %% Clean up %clear ans p1 p2 y Y i j %close all udata = [udata t1203NH s1203NH ]; clear t1203NH s1203NH % dont need them anymore save u1203NH dlmwrite('1203NH_UnderwayFinal.txt', udata, 'delimiter', '\t','precision', '%.6f'); %%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 u1203NH; 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 t1203NHpath %% 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 dgfsv %% Salinity %% Path %% % [a,b] = find (udata(:,10)>32.8); %take out majority >32.8 % sal = (udata(a,:)); % z = 1:10:length(sal); % sub = ones(length(z),11); % for k = 1:length(z); % sub(k,:) = sal(z(k),:); % end z = 1:10:length(udata); sub = ones(length(z),11); for k = 1:length(z); data(k,:) = udata(z(k),:); end 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 s1203NHpath % [a,b] = find (udata(:,10)<32.8); %add rainy spots % sal = (udata(a,:)); % z = 1:10:length(sal); % sub = ones(length(z),11); % for k = 1:length(z); % sub(k,:) = sal(z(k),:); % end % % figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold; % scatter(sub(:,4),sub(:,3),50,sub(:,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 s1008NHpath % %% 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)>11); need to subset % chl = (udata(a,:)); % z = 1:10:length(chl); % sub = ones(length(z),11); % for k = 1:length(z); % sub(k,:) = chl(z(k),:); % end %% didnt need to subset %z = 1:10:length(udata); %data = ones(length(z),11); %for k = 1:length(z); % data(k,:) = udata(z(k),:); %end %figure; grid on; box on; ylim([29 37]); xlim([-125 -117]); hold; %scatter(data(:,4),data(:,3),75,data(:,11)./10,'filled'); colorbar('eastoutside') %colormapeditor % to adjust the colors %print -depsc -r300 c1210NHpath % % [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