-
Notifications
You must be signed in to change notification settings - Fork 0
/
STRFA_200hPa_be362.m
193 lines (189 loc) · 4.92 KB
/
STRFA_200hPa_be362.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculating the daily % %
% streamfunction (STRF) anomalies %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
path(path,'C:\Users\Laís\Desktop\tese\scripts\Plot');
path(path,'C:\Users\Laís\Desktop\tese\scripts\toolbox_geral');
path(path,'C:\Users\Laís\Desktop\tese\scripts\toolbox_ocean');
%
clc
clear
%
if 1 == 2
cd G:/for_lais
%
ncdisp('be362.jan-dec_dmeans_ts.years1-30.sf200850.nc');
%360-day calendar. The year is made of 12 months, each of which has 30 days
%10800 days in 30 years (30 * 360 = 10800)
%
STRF = ncread('be362.jan-dec_dmeans_ts.years1-30.sf200850.nc',...
'atmosphere_horizontal_streamfunction');
%
lat = ncread('be362.jan-dec_dmeans_ts.years1-30.sf200850.nc','latitude_2');
%
lon = ncread('be362.jan-dec_dmeans_ts.years1-30.sf200850.nc','longitude_2');
%
%Extracting only the 200 hPa level:
%
STRF = STRF(:,:,2,:); STRF = squeeze(STRF);
%
end
%
cd G:/Lais_jasmin/u-be362/data/STRF_200hPa
%
load STRF_200hPa%data calculated in windspharm by me
%
%Cutting the matrix for the tropics/extratropics region
%(between 75°S and 75°N):
%
lat = lat(12:134); lat1 = lat; lon1 = lon;
%
STRF = STRF(:,12:134,:);
%
[I,J,T] = size(STRF);
%
L = 360;%days in a year
%
K = T/L;%years
%Example: Plotting the STRF of the day 10:
%
figure
south = -75 ; north = 75 ; west = 0 ; east = 357.5 ;
m_proj('equidistant cylindrical','lon',[west east],'lat',[south north]);
[x1,y1]=m_ll2xy(west,south);[x2,y2]=m_ll2xy(east,north);
[lon,lat]= meshgrid(lon1,lat1);[x,y]=m_ll2xy(lon,lat);
pcolor(x,y,STRF(:,:,10)'); shading interp; hold on;
axis([x1 x2 y1 y2]); hold on; set(gca,'Fontsize',12)
m_coast('color','k','linewidth',1.5)
m_grid_global('',6,3);
title('STRF day 10','Fontsize',16,'visible','on','fontweight','bold');
colormap('jet'); colorbar;
%OK!
%
%STRF zonally assymetric:
STRF_m = nanmean(STRF,1);
for k = 1:T
STRF(:,:,k) = STRF(:,:,k) - STRF_m(:,:,k);
end
clear STRF_m;
%Calculating the daily STRF climatology:
%
STRF = reshape(STRF,I*J,L,K);
%
STRFC = nanmean(STRF,3);
%
%Applying the 31-day moving mean
%
cd G:/lais_jasmin/functions
%
%Copying the last 15 series values at the beginning and the first
%15 series values at the end:
%
STRFC = [STRFC(:,346:end) STRFC STRFC(:,1:15)];
%
%Moving mean:
%
STRFC = STRFC';
%
for j = 1:(I*J)
a(:,j) = mediamovel_centrada(STRFC(:,j),31);
end
%
STRFC = a; STRFC = STRFC'; clear a;
%
STRFC = STRFC(:,16:end-15);
%
STRFC = reshape(STRFC,I,J,L);
%
%Example: Plotting the climatology daily STRF of the day 10:
%10th January
%
figure
south = -75 ; north = 75 ; west = 0 ; east = 357.5 ;
m_proj('equidistant cylindrical','lon',[west east],'lat',[south north]);
[x1,y1]=m_ll2xy(west,south);[x2,y2]=m_ll2xy(east,north);
[lon,lat]= meshgrid(lon1,lat1);[x,y]=m_ll2xy(lon,lat);
pcolor(x,y,STRFC(:,:,10)'); shading interp; hold on;
axis([x1 x2 y1 y2]); hold on; set(gca,'Fontsize',12)
m_coast('color','k','linewidth',1.5)
m_grid_global('',6,3);
title('STRFC day 10','Fontsize',16,'visible','on','fontweight','bold');
colormap('jet'); colorbar;
%OK!
%
%Calculating the daily STRF anomalies:
%
STRFC = reshape(STRFC,I*J,L);
%
STRFA = STRF*NaN;
%
for k = 1:K
STRFA(:,:,k) = STRF(:,:,k) - STRFC(:,:);
end
%
%Rearranging the data:
%
clear STRF; clear STRFC;
%
STRFA = reshape(STRFA,I*J,T); STRFA = reshape(STRFA,I,J,T);
%
%Example: Plotting the STRF anomaly of day 10:
%
figure
south = -35 ; north = 35 ; west = 0 ; east = 357.5 ;
m_proj('equidistant cylindrical','lon',[west east],'lat',[south north]);
[x1,y1]=m_ll2xy(west,south);[x2,y2]=m_ll2xy(east,north);
[lon,lat]= meshgrid(lon1,lat1);[x,y]=m_ll2xy(lon,lat);
pcolor(x,y,STRFA(:,:,10)'); shading interp; hold on;
axis([x1 x2 y1 y2]); hold on; set(gca,'Fontsize',12)
m_coast('color','k','linewidth',1.5)
m_grid_global('',6,3);
title('STRFA day 10','Fontsize',14,'visible','on','fontweight','bold');
colormap('jet'); colorbar;
%
clearvars -except STRFA lat lon lat1 lon1 I J T K L;
%
%Applying the Lanczos filter:
%
STRFA = reshape(STRFA,I*J,T);
STRFA = STRFA';
%
for j = 1:I*J
[Y(:,j),coef,window,Cx,Ff] = lanczosfilter(STRFA(:,j),1,0.05,211.1,'low');
%removing frequencies greater than 0.05
end
%
for j = 1:I*J
[Z(:,j),coef,window,Cx,Ff] = lanczosfilter(Y(:,j),1,0.01,211.1,'high');
%removing frequencies between 0 and 0.01
end
%
clear Y;
plot(STRFA(:,116));
hold on
plot(Z(:,116));%OK!
%
STRFA = Z;
clear Z coef window Cx Ff;
STRFA = STRFA';
%
%Using only DJF for the analyses envolving ERA data and its climatology:
%
%DJF anom:
STRFA = reshape(STRFA,I*J,L,K);
%
STRFA = cat(2,STRFA(:,1:60,:),STRFA(:,331:end,:));
%
%new L:
L = 90;%days in DJF
%
%new T:
T = K*L;
%
STRFA = reshape(STRFA,I,J,T);
%
cd G:/Lais_jasmin/u-be362/data/STRF_200hPa
save('STRFA_200hPa','STRFA','lat','lon','lat1','lon1','I',...
'J','T','K','L','-v7.3');
cd G:/Lais_jasmin/u-be362/scripts