-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJC_Fig4_PTtrend_Comparsion.m
348 lines (261 loc) · 9.44 KB
/
JC_Fig4_PTtrend_Comparsion.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
%add F:\USF_Research\REU_OHC\CTD-Sections\P18 into path;
clc;clear;
load('P18_lonlat.mat')
% remove bias point (large than 0.5 degree)
lon1=LON1; lat1=LAT1; % 1994
lon2=cat(1,LON2(1:100),LON2(102:174)); lat2=cat(1,LAT2(1:100),LAT2(102:174));
lon3=cat(1,LON3(1:116),LON3(126:209)); lat3=cat(1,LAT3(1:116),LAT3(126:209));
clear LON1 LON2 LON3 LAT1 LAT2 LAT3
% apply same crietria for T, D
load('P18_Tinterp1994.mat')
T1interp=Tinterp1;
load('P18_Tinterp2007.mat')
T2interp=cat(2,Tinterp2(:,1:100),Tinterp2(:,102:174));
load('P18_Tinterp2017.mat')
T3interp=cat(2,Tinterp3(:,1:116),Tinterp3(:,126:209));
clear Tinterp1 Tinterp2 Tinterp3
% interplate into 2minute grid
yq=[-67:1/4:23]';
%
%%1994
y1=lat1;
[B,I] = sort(y1);
y1=B;
b=T1interp(:,I); T1interp=b;
[yyy1,ddd1]=meshgrid(y1,D);
[yyyq1,dddq1]=meshgrid(yq,D);
T1Pchip=interp2(yyy1,ddd1,T1interp,yyyq1,dddq1);
%%2007
y2=lat2;
[B,I] = sort(y2);
y2=B;
b=T2interp(:,I); T2interp=b;
[yyy2,ddd2]=meshgrid(y2,D);
[yyyq2,dddq2]=meshgrid(yq,D);
T2Pchip=interp2(yyy2,ddd2,T2interp,yyyq2,dddq2);
%% 2017
y3=lat3;
[B,I] = sort(y3);
y3=B;
b=T3interp(:,I); T3interp=b;
[yyy3,ddd3]=meshgrid(y3,D);
[yyyq3,dddq3]=meshgrid(yq,D);
T3Pchip=interp2(yyy3,ddd3,T3interp,yyyq3,dddq3);
%%
Tall=cat(3,T1Pchip,T2Pchip,T3Pchip);
Tmean=nanmean(Tall(:,:,1:2),3);
delta=T2Pchip-T1Pchip;
deltaDt=delta./1.3;
delta32=T3Pchip-T2Pchip;
deltaDt32=delta32./1;
Temp=cat(3,T1Pchip,T2Pchip,T3Pchip);
t=[1994,2007,2017];
Trend=zeros(300,361)*nan;
for i=1:300
for j=1: 361
a= squeeze(Temp(i,j,:));
if ~isnan(a(1))*~isnan(a(2))*~isnan(a(3))==0
Trend(i,j)=nan;
else
[x_trend,err_trend,yf,yr,x,err,corrmat,Perc_var] = leastsq1 (t,a,t(1),0,0);
Trend(i,j)=x_trend;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%section truth;
load ('F:\USF_Research\REU_OHC\v4r4_interp_monthly\Theta\ThetaD2.mat' )
load('P182007.mat') ;
DISTP18=zeros(length(P182007),1)*nan; Theta=zeros(length(P182007),13,312)*nan;
for i=1: length(P182007)
i
x=P182007(i,1);y=P182007(i,2);
% X=floor(x);
X0=abs(lon-x); X1=lon-x;
IDx0=find(X0==min(X0));
if X1(IDx0)>=2
IDx1=IDx0-1;IDx2=IDx0;
elseif IDx0<720 | IDx0==1
IDx1=IDx0;IDx2=IDx0+1;
else
IDx1=IDx0; IDx2=1;
end
Y0=abs(lat-y);Y1=lat-y;
IDy0=find(Y0==min(Y0));
if Y1(IDy0)>=0
IDy1=IDy0-1;IDy2=IDy0;
else
IDy1=IDy0;IDy2=IDy0+1;
end
dist11=distance(y,x,lat(IDy1),lon(IDx1),6370);
dist12=distance(y,x,lat(IDy1),lon(IDx2),6370);
dist21=distance(y,x,lat(IDy2),lon(IDx1),6370);
dist22=distance(y,x,lat(IDy2),lon(IDx2),6370);
dist=[dist11;dist12;dist21;dist22];
DISTP18(i)=min(dist);
if min(dist)==dist11
IDx=IDx1; IDy=IDy1;
else if min(dist)==dist12
IDx=IDx2; IDy=IDy1;
else if min(dist)==dist21
IDx=IDx1; IDy=IDy2;
else if min(dist)==dist22
IDx=IDx2; IDy=IDy2;
end
end
end
end
Theta(i,:,:)=squeeze(Td(min(IDx),min(IDy),:,:));
end
D=depth(38:end);
ThetaL2=reshape(Theta,170*13,312);
T=[1992+1/24:1/12:2018-1/24];
TrendL2=zeros(170*13,1)*nan;
for i=1:170*13
y=ThetaL2(i,:);
[P,S]=polyfit(T,y,1);
TrendL2(i)=P(1)*10;
end
dTdt=reshape(TrendL2,170,13);
[y2,Id]=sort(P182007(:,2)); dTdt=dTdt(Id,:);
[yyq1,ddq1]=meshgrid(y2,D);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
level = 23; n = ceil(level/2);
cmap2 = [linspace(1, 1, n); linspace(1, 0, n); linspace(1, 0, n)]';
cmap1 = [linspace(0, 1, n); linspace(0, 1, n); linspace(1, 1, n)]';
cmap = [cmap1; cmap2(2:end, :)];
figure
set(gcf,'Units','inches')
set(gcf,'position',[1,0, 14 10])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
hh21=subplot(2,3,1)
pcolor(yyyq3,-dddq3,deltaDt*100);shading interp
colormap(vivid(cmap, [.5 .5]));
% colorbar
caxis([-5 5])
ylim([-5500 -2000])
box on; grid on
% hold on
% v=[0.2 0.4 0.6 0.8 1 1.2 1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8 4 4.5 5 5.5 6 6.5 7];
% [C,h]=contour(yyyq,-dddq,Tmean,v,'k');
% clabel (C,h)
% xlabel('LAT');
% xlabel('LAT');ylabel('Depth(m)')
xticks([-60 -50 -40 -30 -20 -10 0 10 20])
xticklabels('')
yticks([-5500 -5000 -4500 -4000 -3500 -3000 -2500 -2000 ])
% yticklabels('')
ylabel('Depth(m)','fontsize',14)
% title('P18 Time rate of change of potential temperature 2007-1994 (^oC/Decade)')
% saveas (gcf,'P18dTdt0794.png')
% title('P18 Temperature trend 2007-1994 (m^oC year^-^1)')
text(15,-4800,'(a)','Color','k','fontsize',18,'fontweight','bold')
text(-65,-5300,'P18 Observational Trend 07-94 (10^-^3 ^oC year^-^1)','Color','k','fontsize',13,'fontweight','bold')
set(gca,'fontsize',14)
%%
% figure
% set(gcf,'Units','inches')
% set(gcf,'position',[1,0, 12 8])
hh22=subplot(2,3,2)
pcolor(yyyq1,-dddq1,Trend*10*100);shading interp
colormap(vivid(cmap, [.5 .5]));
% colorbar
box on; grid on
% xlabel('LAT');ylabel('Depth(m)')
xticks([-60 -50 -40 -30 -20 -10 0 10 20])
xticklabels('')
yticks([-5500 -5000 -4500 -4000 -3500 -3000 -2500 -2000 ])
yticklabels('')
caxis([-5 5])
ylim([-5500 -2000])
% title('P18 Temperature trend 2017-2007-1994 (m^oC year^-^1)')
text(15,-4800,'(b)','Color','k','fontsize',18,'fontweight','bold')
text(-65,-5300,'P18 Observational Trend 17-07-94 (10^-^3 ^oC year^-^1)','Color','k','fontsize',13,'fontweight','bold')
set(gca,'fontsize',14)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ECCO
%%
%section truth;
load('P18truth.mat')
dTdt_Truth=dTdt;
hh31=subplot(2,3,4)
pcolor(yyq1',-ddq1',dTdt_Truth*100);shading interp
colormap(vivid(cmap, [.5 .5]));
% colorbar
caxis([-5 5])
box on; grid on
ylim([-5500 -2000])
xlabel('Lat','fontsize',14);
xticks([-60 -50 -40 -30 -20 -10 0 10 20])
% xticklabels('')
ylabel('Depth(m)','fontsize',14)
% title('P18 ECCOv4r4 section truth (m^oC year^-^1)')
text(15,-4800,'(c)','Color','k','fontsize',18,'fontweight','bold')
text(-65,-5300,'P18 ECCO Section Truth (10^-^3 ^oC year^-^1)','Color','k','fontsize',13,'fontweight','bold')
set(gca,'fontsize',14)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%pseudo sections-Purkey
load('P18dTdt.mat')
[Yyq1,Ddq1]=meshgrid(yq,D);
hh32=subplot(2,3,5)
pcolor(Yyq1,-Ddq1,P18deltaDt*100);shading interp
colormap(vivid(cmap, [.5 .5]));
hcolorbar=colorbar
caxis([-5 5])%caxis([-0.03 0.03])
ylim([-5500 -2000])
box on; grid on
xlabel('Lat','fontsize',14);
xticks([-60 -50 -40 -30 -20 -10 0 10 20])
% xticklabels('')
% ylabel('Depth(m)','fontsize',14)
yticks([-5500 -5000 -4500 -4000 -3500 -3000 -2500 -2000 ])
yticklabels('')
% xlim([51,113])
% title('P18 ECCOv4r4 pseudo section (m^oC year^-^1)')
text(15,-4800,'(d)','Color','k','fontsize',18,'fontweight','bold')
text(-65,-5300,'P18 ECCO Pseudo Section (10^-^3 ^oC year^-^1)','Color','k','fontsize',13,'fontweight','bold')
set(gca,'fontsize',14)
%%
hh23=subplot(2,3,3)
hold on; grid on;box on
D_obs=[10:20:6000]';
M_truth=nanmean(dTdt_Truth,1)*100; Std_truth=nanstd(dTdt_Truth,0,1)*100;
% M_Freq=nanmean(dTdt_Freq,1)*100; Std_Freq=nanstd(dTdt_Freq,0,1)*100;
M_PseudoP=nanmean(P18deltaDt,2)*100; Std_PseudoP=nanstd(P18deltaDt,0,2)*100;
% M_PseudoG=nanmean(P18deltaDtV6,1)*100; Std_PseudoG=nanstd(P18deltaDtV6,0,1)*100;
M_obs9707=nanmean(deltaDt,2)*100; Std_obs9707=nanstd(deltaDt,0,2)*100;
M_obs970717=nanmean(Trend,2)*1000; Std_obs970717=nanstd(Trend,0,2)*1000;
errorbar(M_obs9707(101:5:end),-D_obs(101:5:end),Std_obs9707(101:5:end),'horizontal','Linewidth',1.5)
errorbar(M_obs970717(101:5:end),-D_obs(101:5:end),Std_obs970717(101:5:end),'horizontal','Linewidth',1.5)
errorbar(M_truth,-D,Std_truth,'horizontal','Linewidth',3)
% errorbar(M_Freq,-D,Std_Freq,'horizontal','Linewidth',3)
% errorbar(M_PseudoG,-D,Std_PseudoG,'horizontal','Linewidth',3)
errorbar(M_PseudoP,-D,Std_PseudoP,'horizontal','Linewidth',3)
lgd=legend('P18-obs-9707','P18-obs-970717','P18-ECCO-truth','P18-ECCO-pseudo','location','southwest')
set(lgd,'color','none')
xlabel('PT Trend (10^-^3 ^oC year^-^1)','fontsize',13)
text(-4.5,-2200,'(e)','Color','k','fontsize',18,'fontweight','bold')
set(gca,'fontsize',14)
%
%
% set(subh1,'Position',[0.0800 0.20 0.400 0.75]);
% set(hcolorbar1,'position',[0.080 0.10 0.40 0.02])
% xlabel(hcolorbar1,'(^oC)','fontsize',10,'fontweight','bold','fontname','times')
%
%
% set(subh2,'Position',[0.530 0.20 0.400 0.75]);
% set(hcolorbar2,'position',[0.530 0.10 0.40 0.02])
% xlabel(hcolorbar2,'(^oC)','fontsize',10,'fontweight','bold','fontname','times')
%%
% set(hh11,'Position',[0.05500 0.775 0.925 0.20]);
set(hh21,'Position',[0.0600 0.54 0.32 0.43]);
set(hh22,'Position',[0.3900 0.54 0.32 0.43]);
set(hh23,'Position',[0.7900 0.08 0.19 0.88]);
set(hh31,'Position',[0.0600 0.07 0.32 0.43]);
set(hh32,'Position',[0.3900 0.07 0.32 0.43]);
set(hcolorbar,'position',[0.72 0.07 0.01 0.90])
saveas(gcf,'JC_Fig3_samplingEXPexample_PTtrendComparisonV6_Part2.png')
%