Filter löschen
Filter löschen

Creating hourly average data with geographic coordinates to produce 3D matrix

5 Ansichten (letzte 30 Tage)
I have 4 column matrix, which include irregular time, temperature, latitude and longitude. I want to creat 3-D matrix such that I have hourly averages of temperature within particular latitude and longitude grid. Thereby producing a 3D matrix of latitude x longitude x hourly averaged temperature.
Please find the attached dataset.
Thanks in advance!
  3 Kommentare
dpb
dpb am 25 Jul. 2021
Are there missing hours that would have to be interpolated/filled first (or if missing ignored)?
Aristo Pacino
Aristo Pacino am 25 Jul. 2021
Hi @KSSV, please find the attached data file with this reply. They are using hourly decimal units.
Hello @dpb, they are sometimes missing hours and can be considered as NaN. I have attached the data files with this reply .
Thanks for your interest in the my question.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

dpb
dpb am 25 Jul. 2021
Bearbeitet: dpb am 25 Jul. 2021
rowfun to the rescue yet again... :)
tData=readtable();
longrid=-180:10:180;
latgrid=-90:10:90;
[~,~,~,tData.lon_g,tData.lat_g]=histcounts2(tData.lon,tData.lat,longrid,latgrid);
tGroup=rowfun(@mean,tData,'InputVariables','temp', ...
'GroupingVariables',{'hour','lon_g','lat_g'}, ...
'OutputVariableNames','temp');
produces:
>> [head(tGroup,5);tail(tGroup,5)]
ans =
10×5 table
hour lon_g lat_g GroupCount temp
____ _____ _____ __________ ______
0 2 14 1 89.94
0 3 5 1 99.68
0 3 7 1 87.31
0 3 9 1 100.86
0 3 15 1 71.35
23 35 14 2 89.96
23 35 15 1 101.81
23 35 16 1 107.89
23 35 18 1 101.6
23 36 9 1 91.3
>>
  6 Kommentare
Aristo Pacino
Aristo Pacino am 26 Jul. 2021
Thanks @dpb, but I would like to have gridwise [latitude x longitude] correlation coefficient so as to finally have a contour plot!
dpb
dpb am 26 Jul. 2021
Well, that's not the Answer of the link... <VBG>
Then see
doc xcorr2
It's in Signal Processing TB

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

KSSV
KSSV am 25 Jul. 2021
T = readtable('New Text document.txt') ;
t = T.hour ;
lon = T.lon ;
lat = T.lat ;
temp = T.temp ;
[c,ia,ib] = unique(t) ;
n = length(c) ;
iwant = cell(n,1) ;
for i = 1:n
iwant{i} = [t(ib==i) lon(ib==i) lat(ib==i) temp(ib==i)] ;
end
  1 Kommentar
Aristo Pacino
Aristo Pacino am 25 Jul. 2021
Hi @KSSV, thank you very much but this is not what I desired. Sorry, I might be unclear but I wanted something for e.g within the longitude [-180 -170] and latitude [0 10] grid, I wanted the temperature to be sampled every one hour. So that I have some what like n x m x z matrix, where n is longitudinal size with grid size of 10 degrees, m is latitudinal size with grid size every 10 degrees and z is temperature size at every one hour sampling frequency.
I would be very happy if you could help me further but much thanks for your effort.
Cheers

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Marine and Underwater Vehicles 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!

Translated by