Hovmoller Diagram: longitude (x axis), time (y axis), and z(temperature values)
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Carlotta Dentico
am 1 Sep. 2023
Kommentiert: Mathieu NOE
am 20 Sep. 2023
Hi,
I wuold like to extract temperature from a 3D matrix temp 609x881x372 (lonxlatxtime) and do an Hovmoller plot where I have time on the y-axis and longitude on the x-axis (see figure).
I created a logical matrix of 0 and 1 to identify where my coordinates meet my condition:
coord = (aa_lon>=-7 & aa_lon<=9 & aa_lat>=79 & aa_lat<=79.01);
coord is 609x881 logical but my matrix (temp) from which I want to extract the data is 609x881x372 double.
Hope my question is clear.
Please help me :)
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 13 Sep. 2023
Verschoben: Mathieu NOE
am 13 Sep. 2023
hello again
I modified my code so it should work now on your data
as I understand we have here only 12 months of data , so my display assumes we have here only the first 12 months (1 year) of the entire time vector (which starts in Jan 1991) - you may need to correct this
also I changed a bit the tolerance on the latitude : aa_lat>=79 & aa_lat<=79+0.1
so we pick more data points of the temp matrix ; otherwise your diagram will have a very coarse display
result so far :
code
%% load data 609x881x12 (lonxlatxtime)
load lat.mat
load lon.mat
load time.mat
load temp.mat
%% convert time serial number into Y/M/D format
[y,mo,d,h,mi,s] = datevec(TT);% samplin time = 1 month (data is stored every 15th of the month)
%% spatial filtering
% coord = (aa_lon>=-7 & aa_lon<=9 & aa_lat>=79 & aa_lat<=79.01);
b = (aa_lat>=79 & aa_lat<=79+0.1); % play with tolerance (here 0.1) and see impact on how many points are selected
selected_lon = aa_lon(b);
ind_lon = (selected_lon>=-7 & selected_lon<=9);
final_lon = selected_lon(ind_lon);
%% main code
[m,n,p] = size(temp);
out = [];
for k = 1:p
tmp = temp(:,:,k);
selected_temp = tmp(b); % filtering for lat
selected_temp = selected_temp(ind_lon); % filtering for lon
% concatenation of the selected_temp data
out = [out; selected_temp']; % nb transpose of selected_temp to have data as row
end
% plot
% downsample Y tick spacing to display only years (tick position at january
% / 1st month of the year)
new_y = (1:12:p);
imagesc(final_lon,(1:p),out);
yticks(new_y)
yticklabels(num2str(y(new_y)))
xlabel('Longitude');
ylabel('Time (Years)');
% add horizontal line corresponding to january 15th (first data of the
% year)
hold on
for ci = 1:numel(new_y)
plot(final_lon,new_y(ci)*ones(size(final_lon)),'k--');
end
3 Kommentare
Weitere Antworten (1)
Mathieu NOE
am 1 Sep. 2023
hello
maybe this ?
I created some dummy data to test my code
hope it helps
%% dummy data 609x881x372 (lonxlatxtime)
aa_lon = -45:0.1:60.9-45-0.1;
aa_lat = 0:0.1:88.1-0.1;
p = 10*12;% 10 years of monthly data = 120 time steps
for k = 1:p
data(:,:,k) = rand(609,881) + sin(0.1*k)*ones(609,881);
end
%% spatial filtering
% coord = (aa_lon>=-7 & aa_lon<=9 & aa_lat>=79 & aa_lat<=79.01);
% equivalent to :
a = (aa_lon>=-7 & aa_lon<=9);
b = (aa_lat>=79 & aa_lat<=79.01);
coord = logical(a'*b);
%% main code
[m,n,p] = size(data);
dt = 1; % put here the time increment or use a time vector if it exist
out = [];
% main loop
for k = 1:p
tmp = data(:,:,k);
tmp = tmp(coord); % spatial filtering of the data
time(k) = k*dt;
% time concatenation of the tmp data
out = [out; tmp']; % nb transpose of tmp to have data as row
end
% plot
x_plot = aa_lon(a);
imagesc(x_plot,time,out);
xlabel('Longitude');
ylabel('Time (months)');
4 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!