I have a list of N 2d numpy arrays, all of the same size Mx3, all of which represent a single sample of M coordinates. Sometimes the value of a coordinate can be np.nan.
I (think I) know how to compute the average and standard deviation over these coordinate samples, namely as follows (i.e. stack them and compute the average and std along axis=0):
averaged = np.nanmean(np.array(listOf2dArrays, dtype=np.float64), axis=0)
std = np.nanstd( np.array(listOf2dArrays, dtype=np.float64), axis=0)
How can I determine the count on which the average and std values for each coordinate are based i.e. the number of non-nan values for each coordinate(component) m?
The result should be a 2d-array of dimensions Mx3 containing non-nan-count values.
np.count_nonzero(~np.isnan(np.array(listOf2dArrays, dtype=np.float64)), axis=0)