How to count the number of pixels having values in 3Dtime series data?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone,
I have 3D time series data (180 x 360 x 120), where 180 is latitude, 360 is longitude and 120 is number of months.
For every month, I want to count how many pixels are having values because in every month data is not available for all the 180x360 pixels.
For example: In january there are 100 pixles having data, feb = 115, march = 1224, april = 447, may = 995
Accordingy my 2D output will be : Out = [100 115 1224 447 995];
Thanks
0 件のコメント
採用された回答
Pratyush Swain
2024 年 3 月 15 日
Hello Vedanta,
Given that you have a 3D time series data and you want to create a 2D output containing count of valid pixel values each month, you can refer to following example implementation:
% Assuming data of 3D timeseries is of dimension: 180 x 360 x 12 --> 12 is referring to the number of months here
% Example timeseries object with random data %
ts = timeseries(rand(180, 360, 12))
% Accessing Data property %
data=ts.Data;
% Introducing some NaNs as an example of missing data %
data(data < 0.5) = NaN;
% Preallocate the output array for performance
Out = zeros(1, size(data, 3))
% Loop through each month and count non-NaN pixels
for month = 1:size(data, 3)
% Count the number of non-NaN elements for the current month
Out(month) = sum(~isnan(data(:, :, month)), 'all');
end
% Display the result
disp(Out);
For more information please refer to following resources:
Hope this helps.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!