Plotting Eddy Kinetic Energy

48 views (last 30 days)
Desak Made Pera Rosita Dewi
Answered: Nipun on 6 Jun 2024
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 Comments
Desak Made Pera Rosita Dewi
matlab said the matrix size do not match
Amilton Roberto Muhosse
Amilton Roberto Muhosse on 23 May 2023
I DO NOT UNDERSTAND WHAT IS ABSOLUTE P=TOPOGRAPHY

Sign in to comment.

Answers (1)

Nipun
Nipun on 6 Jun 2024
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:
  1. "coriolisf" : https://www.mathworks.com/matlabcentral/fileexchange/47338-coriolisf
  2. "padarray" : https://www.mathworks.com/help/images/ref/padarray.html
  3. "meshgrid" : https://www.mathworks.com/help/matlab/ref/meshgrid.html
Hope this helps.
Regards,
Nipun

Categories

Find more on Oceanography and Hydrology in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!