-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOP_heat_transport_multitransects_crosscorr.m
182 lines (147 loc) · 13.7 KB
/
POP_heat_transport_multitransects_crosscorr.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
% compute cross-correlations of components of heat transport along multiple transects
path(path,'~/POP/')
path(path,'~/plotting_scripts/')
cd('/indopac/adelman/Global_mesoscale/POP/')
plot_name = 'Atlantic_2deg';
time_scale_separation = (3/12)*365.24; % time scale to separate low frequency from high frequency variability
year_offset = 1976;
load(['Multitransect_arrays_POP_',plot_name,'.mat'],'*tseries_array','*_vec','datenum_start','datenum_end','delta_t','lon_in_range_vel_all','depth_in_range','time_datenum_in_range')
datestr_title_start = [num2str(floor(datenum_start/365) + year_offset),'-',datestr([1990 01 (mod(datenum_start,365) + 1) 0 0 0],'mm-dd')];
datestr_title_end_minus1 = [num2str(floor((datenum_end - 1)/365) + year_offset),'-',datestr([1990 01 (mod(datenum_end - 1,365) + 1) 0 0 0],'mm-dd')];
datestr_start = [num2str(floor(datenum_start/365) + year_offset),datestr([1990 01 (mod(datenum_start,365) + 1) 0 0 0],'mmdd')];
datestr_end_minus1 = [num2str(floor((datenum_end - 1)/365) + year_offset),datestr([1990 01 (mod(datenum_end - 1,365) + 1) 0 0 0],'mmdd')];
heat_transport_components_tseries = NaN([size(heat_transport_all_tseries_array) 13]);
heat_transport_components_tseries(:,:,1) = heat_transport_zonmean_tmean_tseries_array;
heat_transport_components_tseries(:,:,2) = heat_transport_zonmean_lowfreq_tseries_array;
heat_transport_components_tseries(:,:,3) = heat_transport_zonmean_highfreq_tseries_array;
heat_transport_components_tseries(:,:,4) = heat_transport_largescale_tmean_tseries_array;
heat_transport_components_tseries(:,:,5) = heat_transport_largescale_lowfreq_tseries_array;
heat_transport_components_tseries(:,:,6) = heat_transport_largescale_highfreq_tseries_array;
heat_transport_components_tseries(:,:,7) = heat_transport_undef_tmean_tseries_array;
heat_transport_components_tseries(:,:,8) = heat_transport_undef_lowfreq_tseries_array;
heat_transport_components_tseries(:,:,9) = heat_transport_undef_highfreq_tseries_array;
heat_transport_components_tseries(:,:,10) = heat_transport_mesoscale_tmean_tseries_array;
heat_transport_components_tseries(:,:,11) = heat_transport_mesoscale_lowfreq_tseries_array;
heat_transport_components_tseries(:,:,12) = heat_transport_mesoscale_highfreq_tseries_array;
heat_transport_components_tseries(:,:,13) = heat_transport_all_tseries_array;
heat_transport_spatial_components_tseries = NaN([size(heat_transport_all_tseries_array) 4]);
heat_transport_spatial_components_tseries(:,:,1) = sum(heat_transport_components_tseries(:,:,1:3),3);
heat_transport_spatial_components_tseries(:,:,2) = sum(heat_transport_components_tseries(:,:,4:9),3);
heat_transport_spatial_components_tseries(:,:,3) = sum(heat_transport_components_tseries(:,:,10:12),3);
heat_transport_spatial_components_tseries(:,:,4) = heat_transport_components_tseries(:,:,13);
% remove seasonal cycle
n_bins = round(365.24/delta_t);
heat_transport_components_tseries_noseason = NaN(size(heat_transport_components_tseries));
heat_transport_spatial_components_tseries_noseason = NaN(size(heat_transport_spatial_components_tseries));
nan_mask_components = ones(size(heat_transport_components_tseries));
nan_mask_components((isnan(heat_transport_components_tseries) == 1) | (abs(heat_transport_components_tseries) < 1e-5)) = 0;
heat_transport_components_tseries(abs(nan_mask_components) < 1e-5) = 0;
nan_mask_spatial_components = ones(size(heat_transport_spatial_components_tseries));
nan_mask_spatial_components((isnan(heat_transport_spatial_components_tseries) == 1) | (abs(heat_transport_spatial_components_tseries) < 1e-5)) = 0;
heat_transport_spatial_components_tseries(abs(nan_mask_spatial_components) < 1e-5) = 0;
for bin_ind = 1:n_bins
curr_in_bin_ind = find(abs(mod(time_datenum_in_range - time_datenum_in_range(bin_ind) + (365.24/2),365.24) - (365.24/2)) < (0.4*delta_t));
good_ind_in_bin = find(sum(nan_mask_components,3) > size(nan_mask_components,3) - 1e-5);
if length(good_ind_in_bin) > 0.8*size(nan_mask_components,1)*length(curr_in_bin_ind)
heat_transport_components_tseries_noseason(:,curr_in_bin_ind,:) = heat_transport_components_tseries(:,curr_in_bin_ind,:) - repmat(sum(nan_mask_components(:,curr_in_bin_ind,:).*heat_transport_components_tseries(:,curr_in_bin_ind,:),2),[1 length(curr_in_bin_ind) 1]);
heat_transport_spatial_components_tseries_noseason(:,curr_in_bin_ind,:) = heat_transport_spatial_components_tseries(:,curr_in_bin_ind,:) - repmat(sum(nan_mask_spatial_components(:,curr_in_bin_ind,:).*heat_transport_spatial_components_tseries(:,curr_in_bin_ind,:),2),[1 length(curr_in_bin_ind) 1]);
end
end
% filter time series for interannual & decadal frequencies
half_power_adj = exp(erfinv((2^(1/2)) - 1)/5); % adjustment factor to set bounds at half-power (rather than half-amplitude)
[heat_transport_components_tseries_ID,~,~] = bandpass_err_fcn(heat_transport_components_tseries_noseason,2,delta_t,(1/(3*sum(diff(time_datenum_in_range))))/half_power_adj,(1/426)*half_power_adj,5,1,1,1,0);
[heat_transport_spatial_components_tseries_ID,~,~] = bandpass_err_fcn(heat_transport_spatial_components_tseries_noseason,2,delta_t,(1/(3*sum(diff(time_datenum_in_range))))/half_power_adj,(1/426)*half_power_adj,5,1,1,1,0);
heat_transport_components_tseries_ID = heat_transport_components_tseries_ID + repmat(mean(heat_transport_components_tseries,2),[1 size(heat_transport_components_tseries_ID,2) 1]);
heat_transport_spatial_components_tseries_ID = heat_transport_spatial_components_tseries_ID + repmat(mean(heat_transport_spatial_components_tseries,2),[1 size(heat_transport_spatial_components_tseries_ID,2) 1]);
% compute cross-correlations of spatial components of time series with mesoscale
[corr_spatial_mesoscale_all,dof_spatial_mesoscale_all,~,~,corr_lowbound_spatial_mesoscale_all,corr_highbound_spatial_mesoscale_all,lags] = correlation_scalar_scalar_uncert_bounds(heat_transport_spatial_components_tseries,repmat(heat_transport_spatial_components_tseries(:,:,3),[1 1 4]),2,delta_t,10*delta_t,365.24*[-1 1],0.95);
[corr_spatial_mesoscale_all_ID,dof_spatial_mesoscale_all_ID,~,~,corr_lowbound_spatial_mesoscale_all_ID,corr_highbound_spatial_mesoscale_all_ID,~] = correlation_scalar_scalar_uncert_bounds(heat_transport_spatial_components_tseries_ID,repmat(heat_transport_spatial_components_tseries_ID(:,:,3),[1 1 4]),2,delta_t,10*delta_t,365.24*[-1 1],0.95);
zero_lag_ind = find(abs(lags) < 1e-5);
corr_spatial_mesoscale_zerolag = squeeze(corr_spatial_mesoscale_all(:,zero_lag_ind,:));
corr_lowbound_spatial_mesoscale_zerolag = squeeze(corr_lowbound_spatial_mesoscale_all(:,zero_lag_ind,:));
corr_highbound_spatial_mesoscale_zerolag = squeeze(corr_highbound_spatial_mesoscale_all(:,zero_lag_ind,:));
corr_spatial_mesoscale_zerolag_ID = squeeze(corr_spatial_mesoscale_all_ID(:,zero_lag_ind,:));
corr_lowbound_spatial_mesoscale_zerolag_ID = squeeze(corr_lowbound_spatial_mesoscale_all_ID(:,zero_lag_ind,:));
corr_highbound_spatial_mesoscale_zerolag_ID = squeeze(corr_highbound_spatial_mesoscale_all_ID(:,zero_lag_ind,:));
aspect_ratio_baseline = 10;
xtick_spacing = 20;
fig18 = figure(18);
close(figure(1))
h = plot(lat_transects_vec,corr_spatial_mesoscale_zerolag(:,[1 2 4]));
leg = legend('Overturning-mesoscale corr.','Gyre scale-mesoscale corr.','Total-mesoscale corr.','location','eastoutside');
set(leg,'FontSize',8)
set(gca,'FontSize',12,'xlim',[min(lat_transects_vec) max(lat_transects_vec)],'xtick',(-80):xtick_spacing:80,'ylim',[-1 1],'ytick',(-1):0.25:1)
daspect([((2*aspect_ratio_baseline) + (0.2*(max(lat_transects_vec) - min(lat_transects_vec)))) 1 1])
set(h(1),'Color',[0.55 0 0.55],'LineWidth',2)
set(h(2),'Color',[0 0.3 0.8],'LineWidth',2)
set(h(3),'Color',[0 0 0],'LineWidth',2)
hold on
line([min(lat_transects_vec) max(lat_transects_vec)],[0 0],[1 1],'Color','k','LineStyle','-')
hold off
xlabel('Latitude')
ylabel('Correlation coefficient')
title({'POP correlation coefficient of spatial components of heat transport with mesoscale,'; ['across ',plot_name,' basin,']; ''},'FontSize',10)
saveas(fig18,['Corr_heat_transport_spatial_components_mesoscale_POP_',plot_name,'_int_lon_5_10_spatsep_',datestr_start,'_',datestr_end_minus1,'.pdf'])
close(fig18)
fig19 = figure(19);
close(figure(1))
h = plot(lat_transects_vec,corr_spatial_mesoscale_zerolag_ID(:,[1 2 4]));
leg = legend('Overturning-mesoscale corr.','Gyre scale-mesoscale corr.','Total-mesoscale corr.','location','eastoutside');
set(leg,'FontSize',8)
set(gca,'FontSize',12,'xlim',[min(lat_transects_vec) max(lat_transects_vec)],'xtick',(-80):xtick_spacing:80,'ylim',[-1 1],'ytick',(-1):0.25:1)
daspect([((2*aspect_ratio_baseline) + (0.2*(max(lat_transects_vec) - min(lat_transects_vec)))) 1 1])
set(h(1),'Color',[0.55 0 0.55],'LineWidth',2)
set(h(2),'Color',[0 0.3 0.8],'LineWidth',2)
set(h(3),'Color',[0 0 0],'LineWidth',2)
hold on
line([min(lat_transects_vec) max(lat_transects_vec)],[0 0],[1 1],'Color','k','LineStyle','-')
hold off
xlabel('Latitude')
ylabel('Correlation coefficient')
title({'POP correlation coefficient of spatial components of ID heat transport with mesoscale,'; ['across ',plot_name,' basin,']; ''},'FontSize',10)
saveas(fig19,['Corr_ID_heat_transport_spatial_components_mesoscale_POP_',plot_name,'_int_lon_5_10_spatsep_',datestr_start,'_',datestr_end_minus1,'.pdf'])
close(fig19)
corr_gyre_mesoscale_zerolag_lowerrange = NaN([size(corr_spatial_mesoscale_zerolag,1) 1]);
corr_gyre_mesoscale_zerolag_lowerrange(corr_spatial_mesoscale_zerolag(:,2) >= 0) = corr_spatial_mesoscale_zerolag(corr_spatial_mesoscale_zerolag(:,2) >= 0,2) - squeeze(corr_lowbound_spatial_mesoscale_all(corr_spatial_mesoscale_zerolag(:,2) >= 0,zero_lag_ind,2));
corr_gyre_mesoscale_zerolag_lowerrange(corr_spatial_mesoscale_zerolag(:,2) < 0) = corr_spatial_mesoscale_zerolag(corr_spatial_mesoscale_zerolag(:,2) < 0,2) - squeeze(corr_highbound_spatial_mesoscale_all(corr_spatial_mesoscale_zerolag(:,2) < 0,zero_lag_ind,2));
corr_gyre_mesoscale_zerolag_higherrange = NaN([size(corr_spatial_mesoscale_zerolag,1) 1]);
corr_gyre_mesoscale_zerolag_higherrange(corr_spatial_mesoscale_zerolag(:,2) >= 0) = squeeze(corr_highbound_spatial_mesoscale_all(corr_spatial_mesoscale_zerolag(:,2) >= 0,zero_lag_ind,2)) - corr_spatial_mesoscale_zerolag(corr_spatial_mesoscale_zerolag(:,2) >= 0,2);
corr_gyre_mesoscale_zerolag_higherrange(corr_spatial_mesoscale_zerolag(:,2) < 0) = squeeze(corr_lowbound_spatial_mesoscale_all(corr_spatial_mesoscale_zerolag(:,2) < 0,zero_lag_ind,2)) - corr_spatial_mesoscale_zerolag(corr_spatial_mesoscale_zerolag(:,2) < 0,2);
fig20 = figure(20);
close(figure(1))
h = plot(lat_transects_vec,corr_spatial_mesoscale_zerolag(:,2));
set(gca,'FontSize',12,'xlim',[min(lat_transects_vec) max(lat_transects_vec)],'xtick',(-80):xtick_spacing:80,'ylim',[-1 1],'ytick',(-1):0.25:1)
daspect([((2*aspect_ratio_baseline) + (0.2*(max(lat_transects_vec) - min(lat_transects_vec)))) 1 1])
hold on
line([min(lat_transects_vec) max(lat_transects_vec)],[0 0],[1 1],'Color','k','LineStyle','-')
ebar = errorbar(lat_transects_vec,corr_spatial_mesoscale_zerolag(:,2),corr_gyre_mesoscale_zerolag_lowerrange,corr_gyre_mesoscale_zerolag_higherrange);
hold off
set(h(1),'Color',[0 0.3 0.8],'LineWidth',2)
set(ebar,'Color',[0 0.3 0.8],'LineWidth',1)
xlabel('Latitude')
ylabel('Correlation coefficient')
title({'POP correlation coefficient of gyre-scale and mesoscale heat transport,'; ['across ',plot_name,' basin,']; ''},'FontSize',10)
saveas(fig20,['Corr_heat_transport_gyre_mesoscale_ebar_POP_',plot_name,'_int_lon_5_10_spatsep_',datestr_start,'_',datestr_end_minus1,'.pdf'])
close(fig20)
corr_gyre_mesoscale_zerolag_lowerrange_ID = NaN([size(corr_spatial_mesoscale_zerolag_ID,1) 1]);
corr_gyre_mesoscale_zerolag_lowerrange_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0) = corr_spatial_mesoscale_zerolag_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0,2) - squeeze(corr_lowbound_spatial_mesoscale_all_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0,zero_lag_ind,2));
corr_gyre_mesoscale_zerolag_lowerrange_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0) = corr_spatial_mesoscale_zerolag_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0,2) - squeeze(corr_highbound_spatial_mesoscale_all_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0,zero_lag_ind,2));
corr_gyre_mesoscale_zerolag_higherrange_ID = NaN([size(corr_spatial_mesoscale_zerolag_ID,1) 1]);
corr_gyre_mesoscale_zerolag_higherrange_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0) = squeeze(corr_highbound_spatial_mesoscale_all_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0,zero_lag_ind,2)) - corr_spatial_mesoscale_zerolag_ID(corr_spatial_mesoscale_zerolag_ID(:,2) >= 0,2);
corr_gyre_mesoscale_zerolag_higherrange_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0) = squeeze(corr_lowbound_spatial_mesoscale_all_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0,zero_lag_ind,2)) - corr_spatial_mesoscale_zerolag_ID(corr_spatial_mesoscale_zerolag_ID(:,2) < 0,2);
fig21 = figure(21);
close(figure(1))
h = plot(lat_transects_vec,corr_spatial_mesoscale_zerolag_ID(:,2));
set(gca,'FontSize',12,'xlim',[min(lat_transects_vec) max(lat_transects_vec)],'xtick',(-80):xtick_spacing:80,'ylim',[-1 1],'ytick',(-1):0.25:1)
daspect([((2*aspect_ratio_baseline) + (0.2*(max(lat_transects_vec) - min(lat_transects_vec)))) 1 1])
hold on
line([min(lat_transects_vec) max(lat_transects_vec)],[0 0],[1 1],'Color','k','LineStyle','-')
ebar = errorbar(lat_transects_vec,corr_spatial_mesoscale_zerolag_ID(:,2),corr_gyre_mesoscale_zerolag_lowerrange_ID,corr_gyre_mesoscale_zerolag_higherrange_ID);
hold off
set(h(1),'Color',[0 0.3 0.8],'LineWidth',2)
set(ebar,'Color',[0 0.3 0.8],'LineWidth',1)
xlabel('Latitude')
ylabel('Correlation coefficient')
title({'POP correlation coefficient of gyre-scale and mesoscale ID heat transport,'; ['across ',plot_name,' basin,']; ''},'FontSize',10)
saveas(fig21,['Corr_ID_heat_transport_gyre_mesoscale_ebar_POP_',plot_name,'_int_lon_5_10_spatsep_',num2str(time_scale_separation),'_timesep_',datestr_start,'_',datestr_end_minus1,'.pdf'])
close(fig21)