Hi Louis van Herwijnen
1.-
acquiring data from the provided Excel file
clear all;clc;close all
A=xlsread('AR07W_2011processed.xls')
L=A(:,1)
taking only 2 decimals
N=2
L=1/10^N*floor(L*10^N)
.
checking whether grid is uniform
.
[D,ni,na]=unique(L);
ni(1)=1
nD=[diff(ni); numel(L)-ni(end)+1]
.
The coordinates to use are D: Distance W: Depth
.
d=A(:,1);
w=A(:,2);
min(d)
max(d)
min(w)
max(w)
.
ok, now we see it's a non-uniform grid
2.-
acquiring measurements
T = A(:,3);
S = A(:,4);
TA = A(:,4);
TCO2 = A(:,5);
TpCO2 = A(:,6);
pH = A(:,7);
O2 = A(:,8);
3.-
Example plot without interpolation, on same distance
k=3
hf(1)=figure(1);plot(w([ni(k):1:ni(k+1)-1])',T([ni(k):1:ni(k+1)-1])')
xlabel('W:depth');ylabel('T(ºC)')
title(['Temperature measurements at distance d = ' num2str(d(ni(k)))]);
grid on
.
non-uniform grid of 2D reference points
.
hf(2)=figure(2);plot(d,w,'ro');grid on;grid minor
xlabel('D:distance');ylabel('W:depth')
.
Temperature interpolation
.
F_Temperature=scatteredInterpolant(d,w,T)
Q=4
d_uniform_range=linspace(min(d),max(d),Q*numel(nD)-1)
w_uniform_range=linspace(min(w),max(w),Q*numel(nD)-1)
[D,W]=meshgrid(d_uniform_range,w_uniform_range)
T2=F_Temperature(D,W)
hf(3)=figure(3);surf(D,W,T2)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['Temperature - interpolation factor Q = ' num2str(Q)])
.
4.- Temperature contours
.
hf(4)=figure(4);hT_surfc=surfc(D,W,T2)
campos([5578.878486985600 7013.723961265031 21.490607228584])
xlabel('D:distance');ylabel('W:depth')
title('Temp contour projections')
.
The projected contours are available in here:
hT_surfc(2)
ans =
Contour with properties:
LineColor: 'flat'
LineStyle: '-'
LineWidth: 0.500000000000000
Fill: 'off'
LevelList: [1×9 double]
XData: [71×71 double]
YData: [71×71 double]
ZData: [71×71 double]
.
You can carry on working on the contour lines by acquiring the 2D curves in the following way:
x_T_contours=hT_surfc(2).XData
y_T_contours=hT_surfc(2).YData
z_T_contours=hT_surfc(2).ZData
hf(5)=figure(5);contourf(T2,10)
xlabel('D:distance');ylabel('W:depth')
title('Temperature contours with contourf')
.
Once a surface is available it may be particularly useful to 1: zoom in and out and 2: check data with the cursor, that I prefer call it marker:
.
5.-
Salinity [psu] Surface
.
F_Salinity=scatteredInterpolant(d,w,S)
S2=F_Salinity(D,W)
hf(6)=figure(6);surf(D,W,S2)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['Salinity - interpolation factor Q = ' num2str(Q)])
hf(7)=figure(7);hS_surfc=surfc(D,W,S2)
campos([5578.878486985600 7013.723961265031 21.490607228584])
xlabel('D:distance');ylabel('W:depth')
title('Salinity contour projections')
x_S_contours=hS_surfc(2).XData;
y_S_contours=hS_surfc(2).YData;
z_S_contours=hS_surfc(2).ZData;
hf(8)=figure(8);contourf(T2,10)
xlabel('D:distance');ylabel('W:depth')
title('Temperature contours with contourf')
6.-
TA [umol/kgSW] surface
F_TA=scatteredInterpolant(d,w,TA)
TA2=F_TA(D,W)
hf(9)=figure(9);surf(D,W,TA2)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['TA - interpolation factor Q = ' num2str(Q)])
hf(10)=figure(10);hTA_surfc=surfc(D,W,S2)
campos([5578.878486985600 7013.723961265031 21.490607228584])
xlabel('D:distance');ylabel('W:depth')
title('TA contour projections')
x_TA_contours=hTA_surfc(2).XData
y_TA_contours=hTA_surfc(2).YData
z_TA_contours=hTA_surfc(2).ZData
hf(11)=figure(11);contourf(TA2,10)
xlabel('D:distance');ylabel('W:depth')
title('TA contours with contourf')
7.- TCO2 [umol/kgSW] surface
F_TCO2=scatteredInterpolant(d,w,TCO2)
TCO22=F_TCO2(D,W)
hf(12)=figure(12);surf(D,W,TCO22)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['TCO2 - interpolation factor Q = ' num2str(Q)])
hf(13)=figure(13);hTCO2_surfc=surfc(D,W,TCO22)
campos( 1.0e+04 *[ -0.486868459634731 1.534198637901339 0.281087905547732])
xlabel('D:distance');ylabel('W:depth')
title('TCO2 contour projections')
x_TCO2_contours=hTCO2_surfc(2).XData
y_TCO2_contours=hTCO2_surfc(2).YData
z_TCO2_contours=hTCO2_surfc(2).ZData
hf(14)=figure(14);contourf(TCO22,10)
xlabel('D:distance');ylabel('W:depth')
title('TCO2 contours with contourf')
8.- pCO2 [uatm] surface
F_TpCO2=scatteredInterpolant(d,w,TpCO2)
TpCO22=F_TpCO2(D,W)
hf(15)=figure(15);surf(D,W,TpCO22)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['TpCO2 - interpolation factor Q = ' num2str(Q)])
hf(16)=figure(16);hTpCO2_surfc=surfc(D,W,TpCO22)
campos( 1.0e+04 *[ -0.486868459634731 1.534198637901339 0.281087905547732])
xlabel('D:distance');ylabel('W:depth')
title('TpCO2 contour projections')
x_pCO2_contours=hTpCO2_surfc(2).XData
y_pCO2_contours=hTpCO2_surfc(2).YData
z_pCO2_contours=hTpCO2_surfc(2).ZData
hf(17)=figure(17);contourf(TpCO22,10)
xlabel('D:distance');ylabel('W:depth')
title('TpCO2 contours with contourf')
9.- Acidity [pH] surface
F_pH=scatteredInterpolant(d,w,pH)
pH2=F_pH(D,W)
hf(18)=figure(15);surf(D,W,pH2)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['pH - interpolation factor Q = ' num2str(Q)])
hf(19)=figure(16);hpH_surfc=surfc(D,W,pH2)
campos( 1.0e+04 *[ -0.486868459634731 1.534198637901339 0.281087905547732])
xlabel('D:distance');ylabel('W:depth')
title('pH contour projections')
x_pH2_contours=hpH_surfc(2).XData
y_pH2_contours=hpH_surfc(2).YData
z_pH2_contours=hpH_surfc(2).ZData
hf(20)=figure(17);contourf(pH2,10)
xlabel('D:distance');ylabel('W:depth')
title('pH contours with contourf')
10.- Oxygen O2: [umol/kgSW] surface
F_O2=scatteredInterpolant(d,w,O2)
O22=F_O2(D,W)
hf(21)=figure(15);surf(D,W,O22)
campos([4401.80925645085 23683.44745915113 25.18900384688])
xlabel('D:distance');ylabel('W:depth')
title(['O2 - interpolation factor Q = ' num2str(Q)])
hf(22)=figure(16);hO2_surfc=surfc(D,W,O22)
campos( 1.0e+04 *[-0.461106553630150 1.377458945573147 0.001065817992402])
xlabel('D:distance');ylabel('W:depth')
title('O2 contour projections')
x_O22_contours=hO2_surfc(2).XData
y_O22_contours=hO2_surfc(2).YData
z_O22_contours=hO2_surfc(2).ZData
hf(23)=figure(17);contourf(O22,10)
xlabel('D:distance');ylabel('W:depth')
title('O2 contours with contourf')
.
saving results
.
save('Excel_TSal_et_al_variables.mat')
savefig(hf,'AllFigures.fig')
Louis
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance for time and attention
John BG