-
Notifications
You must be signed in to change notification settings - Fork 1
/
General_Plotting.m
executable file
·224 lines (199 loc) · 6.33 KB
/
General_Plotting.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
% This script analyses the heat budget in MOM025-CORENYF
%% file-names and grid properties:
base = '/srv/ccrc/data03/z3500785/MOM_HeatDiag/output007/';
baser = '/srv/ccrc/data03/z3500785/MOM_HeatDiag/restart006/';
hname = [base 'ocean_heat.nc'];
fname = [base 'ocean.nc'];
gname = [base 'ocean_grid.nc'];
sname = [base 'ocean_snap.nc'];
rnameT = [baser 'ocean_temp_salt.res.nc'];
rnameZ = [baser 'ocean_thickness.res.nc'];
lon = ncread(hname,'geolon_t');
lat = ncread(hname,'geolat_t');
area = ncread(gname,'area_t');
[xL,yL] = size(lon);
z = ncread(hname,'st_ocean');
zL = length(z);
time = mod(ncread(hname,'time'),365);
time_snap = [0; mod(ncread(sname,'time'),365)];
if (time_snap(end) == 0) time_snap(end) = 365;end
tL = length(time);
TL = 161;
T = linspace(-3,35,TL);
dT = T(2)-T(1);
Cp = 3992.1; % J kg-1 degC-1
rho0 = 1035; % kgm-3
% $$$ xvec = 1:3:xL;
% $$$ yvec = 1:3:yL;
% $$$ xvec2 = 1:20:xL;
% $$$ yvec2 = 1:20:yL;
% $$$ txtmonth = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
%%% Plot Mean Heat Flux and SST:
xvec = 1:1:xL;
yvec = 1:1:yL;
shflux = ncread(fname,'net_sfc_heating',[1 1 1],[xL yL 12]);
SST = squeeze(ncread(fname,'temp',[1 1 1 1],[xL yL 1 12]));
months = {[1:12], ...
[3], ...
[7], ...
[11]};
monconv = datevec(mod(time,365));
monconv = monconv(:,2);
tmp = monconv;
for i=1:length(monconv)
[pp tmp(i)] = min(abs(monconv-i));
end
monconv = tmp;
labels = {'Annual Average', ...
'March', ...
'July', ...
'November'};
figure;
set(gcf,'Position',[1 36 1920 970]);
%set(gcf,'Position',[3 59 1916 914]);
set(0,'defaulttextfontsize',15);
set(0,'defaultaxesfontsize',15);
poss = [0.1300 0.4553 0.7402 0.4697; ...
0.1300 0.1389 0.2343 0.2680; ...
0.3951 0.1389 0.2343 0.2680; ...
0.6681 0.1389 0.2343 0.2680];
for i=1:length(months)
if (i == 1)
subplot(5,3,[1 9]);
else
subplot(5,3,[10 13]+(i-2));
end
X = lon(xvec,yvec);
Y = lat(xvec,yvec);
Z = mean(shflux(:,:,monconv(months{i})),3);
Z2 = mean(SST(:,:,monconv(months{i})),3);
Z = Z(xvec,yvec);
Z2 = Z2(xvec,yvec);
contourf(X,Y,Z,[-1e10 -500:20:500 1e10],'linestyle','none');
hold on;
% $$$ quiver(lon(xvec2,yvec2),lat(xvec2,yvec2),tau_x(xvec2,yvec2),tau_y(xvec2,yvec2),3,'-k');
% $$$ if (i==1)
[c,h] = contour(X,Y,Z2,[-3:2:35],'-k');
% $$$ else
% $$$ [c,h] = contour(X,Y,Z2,[-3:4:35],'-k');
% $$$ end
clabel(c,h);
caxis([-200 200]);
if (i==1)
cb = colorbar;
ylabel(cb,'Wm$^{-2}$');
end
ylim([-75 60]);
if (i>1)
xlabel('Longitude ($^\circ$E)');
end
if (i<=2)
ylabel('Latitude ($^\circ$N)');
end
if (i>1)
text(-276,53,labels{i},'BackgroundColor','w');
else
text(-278,55,labels{i},'BackgroundColor','w');
end
set(gca,'Position',[poss(i,:)]);
set(gca,'color','k');
end
colormap(redblue);
%%% Plot Seasonal cycle of winds and SST:
xvec2 = 1:20:xL;
yvec2 = 1:20:yL;
figure;
set(gcf,'Position',get(0,'ScreenSize'));
set(0,'defaulttextfontsize',20);
set(0,'defaultaxesfontsize',20);
for i=1:6
month = 2*i-1;
subplot(3,2,i);
SST = ncread(fname,'temp',[1 1 1 month],[xL yL 1 1]);
tau_x = ncread(fname,'tau_x',[1 1 month],[xL yL 1]);
tau_y = ncread(fname,'tau_y',[1 1 month],[xL yL 1]);
contourf(lon(xvec,yvec),lat(xvec,yvec),SST(xvec,yvec),[-5:1:40],'linestyle','none');
hold on;
quiver(lon(xvec2,yvec2),lat(xvec2,yvec2),tau_x(xvec2,yvec2),tau_y(xvec2,yvec2),3,'-k');
% $$$ contour(lon(xvec,yvec),lat(xvec,yvec),sqrt(tau_x(xvec,yvec).^2+tau_y(xvec,yvec).^2),[0.15 ...
% $$$ 0.2 0.25 0.3],'-k');
cb = colorbar;
caxis([0 32]);
ylim([-75 65]);
xlim([-280 80]);
set(gca,'color','k');
xlabel('Longitude ($^\circ$E)');
ylabel('Latitude ($^\circ$N)');
title(['MOM025 ' txtmonth{month} ' SST ($^\circ$C) and wind stress, ']);
end
colormap(redblue);
%% Plot Depth averaged T:
load('MOM025_WMHeatBudget.mat');
[X,Y] = ndgrid(0.5:1:11.5,-z);
figure;
contourf(X,Y,Temp'-repmat(mean(Temp',1),[12 1]),[-2:0.025:2],'linestyle','none');
ylim([-150 0]);
ylabel('Depth (m)');
xlabel('Month');
title('MOMO25 Global Temperature Anomaly ($^\circ$C)');
cb = colorbar;
caxis([-0.75 0.75]);
%% Plot zonal averaged T:
TZ = zeros(yL,zL);
[X,Y] = ndgrid(lat(1,:),-z);
for zi=1:zL
zi
TZ(:,zi) = squeeze(nanmean(nanmean(ncread(fname,'temp',[1 1 zi 1],[xL ...
yL 1 12]),4),1));
end
[c,h] = contourf(X,Y,TZ,[-2:1:35],'-k');
clabel(c,h);
xlabel('Latitude ($^\circ$N)');
ylabel('Depth (m)');
title('MOM025 Annual Average Temperature ($^\circ$C)');
cb = colorbar;
colormap(redblue);
ylim([-1000 0]);
caxis([5 28]);
%% Plot Sea level variability:
close all;
clear all;
base = '/srv/ccrc/data03/z3500785/mom/';
gname = [base 'ocean_grid_mom025.nc'];
lon = ncread(gname,'geolon_t');
lat = ncread(gname,'geolat_t');
area = ncread(gname,'area_t');
[xL,yL] = size(lon);
% $$$ xvec = 1:6:xL;
% $$$ yvec = 1:6:yL;
% $$$ % 1/10 sea level variability:
% $$$ cont = ncread([base 'ncdata/sea_levelsq.cont.ncra.nc'],'sea_levelsq') - ...
% $$$ ncread([base 'ncdata/sea_level.cont.ncra.nc'],'sea_level').^2;
% $$$ pert = ncread([base 'ncdata/sea_levelsq.ncra.nc'],'sea_levelsq') - ...
% $$$ ncread([base 'ncdata/sea_level.ncra.nc'],'sea_level').^2;
% $$$ % Global integral:
% $$$ contG = nansum(nansum(cont.*area))
% $$$ contP = nansum(nansum(pert.*area))
% $$$ figure;
% $$$ subplot(2,2,1);
% $$$ pcolPlot(lon(xvec,yvec),lat(xvec,yvec),cont(xvec,yvec));
% $$$ caxis([0 0.1]);
% $$$ subplot(2,2,2);
% $$$ pcolPlot(lon(xvec,yvec),lat(xvec,yvec),pert(xvec,yvec));
% $$$ caxis([0 0.1]);
% $$$ subplot(2,2,3);
% $$$ pcolPlot(lon(xvec,yvec),lat(xvec,yvec),pert(xvec,yvec)-cont(xvec,yvec));
% $$$ caxis([-0.1 0.1]);
xvec = 1:2:xL;
yvec = 1:2:yL;
% 1/4 EKE and temperature variability:
u_sq = ncread([base 'ncdata/ocean_month.rediGM.ncra.nc'],'u_sq');
u_rms = ncread([base 'ncdata/ocean_month.rediGM.ncra.nc'],'u');
figure;
subplot(2,2,1);
pcolPlot(lon(xvec,yvec),lat(xvec,yvec),u_sq(xvec,yvec,1));
caxis([0 0.5]);
subplot(2,2,2);
pcolPlot(lon(xvec,yvec),lat(xvec,yvec),u_rms(xvec,yvec,1).^2);
caxis([0 0.5]);
pcolPlot(lon(xvec,yvec),lat(xvec,yvec),u_rms(xvec,yvec,1).^2-u_sq(xvec,yvec,1));