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

3 次查看(过去 30 天)
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 个评论
dpb
dpb 2021-7-25
Are there missing hours that would have to be interpolated/filled first (or if missing ignored)?
Aristo Pacino
Aristo Pacino 2021-7-25
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.

请先登录,再进行评论。

采纳的回答

dpb
dpb 2021-7-25
编辑:dpb 2021-7-25
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 个评论
Aristo Pacino
Aristo Pacino 2021-7-26
Thanks @dpb, but I would like to have gridwise [latitude x longitude] correlation coefficient so as to finally have a contour plot!

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2021-7-25
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 个评论
Aristo Pacino
Aristo Pacino 2021-7-25
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Marine and Underwater Vehicles 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by