% The next step will be to use our bin
% average profile data of potential temperature, absolute salinity, and potential
% density to estimate the potential temperature maximum of the Atlantic waters below
% 1_Create a file with latitude, longitude, year, Tmax, D(Tmax), S(Tmax), and year where
% D(Tmax) and S(Tmax) for each year.
binDepth_2017 = [binDepth_2017(:,1:29) binDepth_2017(:,31:35)];
binPT_2017 = [binPT_2017(:,1:29) binPT_2017(:,31:35)];
binR0_2017 = [binR0_2017(:,1:29) binR0_2017(:,31:35)];
binSA_2017 = [binSA_2017(:,1:29) binSA_2017(:,31:35)];
lon_2017 = [lon_2017(:,1:29) lon_2017(:,31:35)];
lat_2017 = [lat_2017(:,1:29) lat_2017(:,31:35)];
% Tmax below 100 m water depth
indDepth_100m_2017(ii) = find(binDepth_2017(:,ii) >= 100,1,'first'); % index 100 m depth
Tmax_100m_2017(ii) = max(binPT_2017(indDepth_100m_2017:end,ii)); % maximum potential temperature below 100 m
indTmax_100m_2017(ii) = find(binPT_2017(:,ii) == Tmax_100m_2017(ii)); % index Tmax at 100 m depth
Density_tmax_100m_2017(ii) = binR0_2017(indTmax_100m_2017(ii),ii); % potential density at Tmax
S_tmax_100m_2017(ii) = binSA_2017(indTmax_100m_2017(ii),ii); % absolute salinity at Tmax
Depth_Tmax_100m_2017(ii) = binDepth_2017(indTmax_100m_2017(ii),ii);
lat_2017 = lat_2017(1,:);
lon_2017 = lon_2017(1,:);
year_2017 = 2017.*ones(1,34);
plot(binPT_2017(:,profile),binDepth_2017(:,profile),'linewidth',2)
plot(Tmax_100m_2017(:,profile),Depth_Tmax_100m_2017(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Temperature [deg. C]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binSA_2017(:,profile),binDepth_2017(:,profile),'linewidth',2)
plot(S_tmax_100m_2017(:,profile),Depth_Tmax_100m_2017(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Absolute Salinity [ppt]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binR0_2017(:,profile),binDepth_2017(:,profile),'linewidth',2)
plot(Density_tmax_100m_2017(:,profile),Depth_Tmax_100m_2017(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Density [kg/m^3]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
% Tmax below 100 m water depth
indDepth_100m_2018(ii) = find(binDepth_2018(:,ii) >= 100,1,'first'); % index 100 m depth
Tmax_100m_2018(ii) = max(binPT_2018(indDepth_100m_2018:end,ii)); % maximum potential temperature below 100 m
indTmax_100m_2018(ii) = find(binPT_2018(:,ii) == Tmax_100m_2018(ii)); % index Tmax at 100 m depth
Density_tmax_100m_2018(ii) = binR0_2018(indTmax_100m_2018(ii),ii); % potential density at Tmax
S_tmax_100m_2018(ii) = binSA_2018(indTmax_100m_2018(ii),ii); % absolute salinity at Tmax
Depth_Tmax_100m_2018(ii) = binDepth_2018(indTmax_100m_2018(ii),ii);
lat_2018 = lat_2018(1,:);
lon_2018 = lon_2018(1,:);
year_2018 = 2018.*ones(1,18);
plot(binPT_2018(:,profile),binDepth_2018(:,profile),'linewidth',2)
plot(Tmax_100m_2018(:,profile),Depth_Tmax_100m_2018(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Temperature [deg. C]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binSA_2018(:,profile),binDepth_2018(:,profile),'linewidth',2)
plot(S_tmax_100m_2018(:,profile),Depth_Tmax_100m_2018(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Absolute Salinity [ppt]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binR0_2018(:,profile),binDepth_2018(:,profile),'linewidth',2)
plot(Density_tmax_100m_2018(:,profile),Depth_Tmax_100m_2018(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Density [kg/m^3]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
% profile 25 does not have any data below 100m -> skip profile
binDepth_2019 = [binDepth_2019(:,1:24) binDepth_2019(:,26:end)];
binPT_2019 = [binPT_2019(:,1:24) binPT_2019(:,26:end)];
binR0_2019 = [binR0_2019(:,1:24) binR0_2019(:,26:end)];
binSA_2019 = [binSA_2019(:,1:24) binSA_2019(:,26:end)];
lon_2019 = [lon_2019(:,1:24) lon_2019(:,26:end)];
lat_2019 = [lat_2019(:,1:24) lat_2019(:,26:end)];
% Tmax below 100 m water depth
indDepth_100m_2019(ii) = find(binDepth_2019(:,ii) >= 100,1,'first'); % index 100 m depth
Tmax_100m_2019(ii) = max(binPT_2019(indDepth_100m_2019:end,ii)); % maximum potential temperature below 100 m
indTmax_100m_2019(ii) = find(binPT_2019(:,ii) == Tmax_100m_2019(ii)); % index Tmax at 100 m depth
Density_tmax_100m_2019(ii) = binR0_2019(indTmax_100m_2019(ii),ii); % potential density at Tmax
S_tmax_100m_2019(ii) = binSA_2019(indTmax_100m_2019(ii),ii); % absolute salinity at Tmax
Depth_Tmax_100m_2019(ii) = binDepth_2019(indTmax_100m_2019(ii),ii);
lat_2019 = lat_2019(1,:);
lon_2019 = lon_2019(1,:);
year_2019 = 2019.*ones(1,36);
plot(binPT_2019(:,profile),binDepth_2019(:,profile),'linewidth',2)
plot(Tmax_100m_2019(:,profile),Depth_Tmax_100m_2019(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Temperature [deg. C]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binSA_2019(:,profile),binDepth_2019(:,profile),'linewidth',2)
plot(S_tmax_100m_2019(:,profile),Depth_Tmax_100m_2019(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Absolute Salinity [ppt]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binR0_2019(:,profile),binDepth_2019(:,profile),'linewidth',2)
plot(Density_tmax_100m_2019(:,profile),Depth_Tmax_100m_2019(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Density [kg/m^3]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
% Tmax below 100 m water depth
indDepth_100m_2020(ii) = find(binDepth_2020(:,ii) >= 100,1,'first'); % index 100 m depth
Tmax_100m_2020(ii) = max(binPT_2020(indDepth_100m_2020:end,ii)); % maximum potential temperature below 100 m
indTmax_100m_2020(ii) = find(binPT_2020(:,ii) == Tmax_100m_2020(ii)); % index Tmax at 100 m depth
Density_tmax_100m_2020(ii) = binR0_2020(indTmax_100m_2020(ii),ii); % potential density at Tmax
S_tmax_100m_2020(ii) = binSA_2020(indTmax_100m_2020(ii),ii); % absolute salinity at Tmax
Depth_Tmax_100m_2020(ii) = binDepth_2020(indTmax_100m_2020(ii),ii);
lat_2020 = lat_2020(1,:);
lon_2020 = lon_2020(1,:);
year_2020 = 2020.*ones(1,39);
plot(binPT_2020(:,profile),binDepth_2020(:,profile),'linewidth',2)
plot(Tmax_100m_2020(:,profile),Depth_Tmax_100m_2020(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Temperature [deg. C]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binSA_2020(:,profile),binDepth_2020(:,profile),'linewidth',2)
plot(S_tmax_100m_2020(:,profile),Depth_Tmax_100m_2020(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Absolute Salinity [ppt]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binR0_2020(:,profile),binDepth_2020(:,profile),'linewidth',2)
plot(Density_tmax_100m_2020(:,profile),Depth_Tmax_100m_2020(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Density [kg/m^3]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
% Tmax below 100 m water depth
indDepth_100m_2021(ii) = find(binDepth_2021(:,ii) >= 100,1,'first'); % index 100 m depth
Tmax_100m_2021(ii) = max(binPT_2021(indDepth_100m_2021:end,ii)); % maximum potential temperature below 100 m
indTmax_100m_2021(ii) = find(binPT_2021(:,ii) == Tmax_100m_2021(ii)); % index Tmax at 100 m depth
Density_tmax_100m_2021(ii) = binR0_2021(indTmax_100m_2021(ii),ii); % potential density at Tmax
S_tmax_100m_2021(ii) = binSA_2021(indTmax_100m_2021(ii),ii); % absolute salinity at Tmax
Depth_Tmax_100m_2021(ii) = binDepth_2021(indTmax_100m_2021(ii),ii);
lat_2021 = lat_2021(1,:);
lon_2021 = lon_2021(1,:);
year_2021 = 2021.*ones(1,30);
plot(binPT_2021(:,profile),binDepth_2021(:,profile),'linewidth',2)
plot(Tmax_100m_2021(:,profile),Depth_Tmax_100m_2021(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Temperature [deg. C]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binSA_2021(:,profile),binDepth_2021(:,profile),'linewidth',2)
plot(S_tmax_100m_2021(:,profile),Depth_Tmax_100m_2021(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Absolute Salinity [ppt]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
plot(binR0_2021(:,profile),binDepth_2021(:,profile),'linewidth',2)
plot(Density_tmax_100m_2021(:,profile),Depth_Tmax_100m_2021(:,profile),'-s','MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',[1 .6 .6])
xlabel('Potential Density [kg/m^3]')
set(gca,'ydir','reverse','linewidth',2,'fontsize',10)
% % 1_Create a file with latitude, longitude, year, Tmax, D(Tmax), S(Tmax), and year where
% D(Tmax) and S(Tmax) for each year.
file_2017 = [lat_2017;lon_2017;year_2017;Tmax_100m_2017;Depth_Tmax_100m_2017;S_tmax_100m_2017;Density_tmax_100m_2017];
file_2018 = [lat_2018;lon_2018;year_2018;Tmax_100m_2018;Depth_Tmax_100m_2018;S_tmax_100m_2018;Density_tmax_100m_2018];
file_2019 = [lat_2019;lon_2019;year_2019;Tmax_100m_2019;Depth_Tmax_100m_2019;S_tmax_100m_2019;Density_tmax_100m_2019];
file_2020 = [lat_2020;lon_2020;year_2020;Tmax_100m_2020;Depth_Tmax_100m_2020;S_tmax_100m_2020;Density_tmax_100m_2020];
file_2021 = [lat_2021;lon_2021;year_2021;Tmax_100m_2021;Depth_Tmax_100m_2021;S_tmax_100m_2021;Density_tmax_100m_2021];
file_disko_bay = [file_2017;file_2018;file_2019;file_2020;file_2021]';
fileID = fopen('file_disko_bay.txt','w');
fprintf(fileID,'%6s %6s %6s %6s %6s %6s %6s\n','latitude','longitude','year','Tmax','Depth(Tmax)','SA(Tmax)','R0(Tmax)');
fprintf(fileID,'%7f %7f %4d %7f %7f %7f %7f\n',file_disko_bay);