Borrar filtros
Borrar filtros

How to count the number of pixels having values in 3Dtime series data?

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Pratyush Swain
Pratyush Swain el 15 de Mzo. de 2024
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))
timeseries Common Properties: Name: 'unnamed' Time: [12x1 double] TimeInfo: tsdata.timemetadata Data: [180x360x12 double] DataInfo: tsdata.datametadata
% 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))
Out = 1x12
0 0 0 0 0 0 0 0 0 0 0 0
% 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);
32512 32488 32525 32545 32406 32425 32428 32251 32317 32313 32290 32531
For more information please refer to following resources:
Hope this helps.

Más respuestas (0)

Categorías

Más información sobre Time Series en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by