Plotting Eddy Kinetic Energy
48 ビュー (過去 30 日間)
古いコメントを表示
Hi I have problem with plotting eddy kinetic energy (EKE)
I have a data of sea surface height (variable name: adt) with matrix [n m k]. n is latitude, m is longitude and k is time.
I want to plot EKE with equation below
here is my initial code
regionName = 'SouthIndian' % change as you need to ..
eval(['load ' regionName]); %to evaluate the data
[n, m, k] = size(b.adt); %n =lat, m= lon, k = absolute topohraphy
adt_mean = squeeze(mean(shiftdim(b.adt,2)));
g=(9.8).^2;
f=2.*(coriolisf(b.lat)).^2;
dhx=(diff(adt_mean)./diff(b.lat)).^2;
dhy=(diff(shiftdim(adt_mean,1))./diff(b.lon)).^2;
eke=g/f*(dhx+dhy);
But it doesnt working. Plese help or any suggestion about it.
2 件のコメント
回答 (1 件)
Nipun
2024 年 6 月 6 日
Hi Desak,
I understand that you want to calculate and plot the Eddy Kinetic Energy (EKE) from sea surface height (adt) data. Based on the shared information about the code, I can confirm that the root cause of the problem is dimension handling and related calculation.
Here is the recommended version for the expected output:
regionName = 'SouthIndian'; % change as needed
eval(['load ' regionName]); % load the data
% Extract dimensions
[n, m, k] = size(b.adt); % n = lat, m = lon, k = time
% Compute the mean absolute dynamic topography (adt) over time
adt_mean = mean(b.adt, 3);
% Constants
g = (9.8)^2;
% Compute Coriolis parameter squared (f^2)
f = 2 * (coriolisf(b.lat)).^2;
% Calculate spatial derivatives
[lat_grid, lon_grid] = meshgrid(b.lat, b.lon);
dhx = (diff(adt_mean, 1, 1) ./ diff(lat_grid, 1, 1)).^2; % Gradient in lat direction
dhy = (diff(adt_mean, 1, 2) ./ diff(lon_grid, 1, 2)).^2; % Gradient in lon direction
% Extend the matrices to original size by padding with zeros
dhx = padarray(dhx, [1, 0], 'post');
dhy = padarray(dhy, [0, 1], 'post');
% Compute EKE
eke = g ./ f .* (dhx + dhy);
% Plotting EKE
figure;
imagesc(b.lon, b.lat, eke');
set(gca, 'YDir', 'normal');
colorbar;
title('Eddy Kinetic Energy (EKE)');
xlabel('Longitude');
ylabel('Latitude');
For more information on the functions used, refer to the following MathWorks documentation:
- "coriolisf" : https://www.mathworks.com/matlabcentral/fileexchange/47338-coriolisf
- "padarray" : https://www.mathworks.com/help/images/ref/padarray.html
- "meshgrid" : https://www.mathworks.com/help/matlab/ref/meshgrid.html
Hope this helps.
Regards,
Nipun
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Oceanography and Hydrology についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!