The IDL mean
function is equivalent to the numpy mean
function, and the IDL reform
can be used similarly to the numpy array_split
:
data_mean = mean(reform(data, n_elements(data) / N), dimension=2)
If you don't mind data
ending up with different dimensions, you can greatly speed this up using the /overwrite
keyword:
data_mean = mean(reform(data, n_elements(data) / N, /overwrite), dimension=2)
Finally, if you have a version of IDL before IDL 8.0, then you won't have the dimension
keyword for the mean
function. Use this (less elegant) pattern instead:
data_mean = total(reform(data, n_elements(data) / N), 2) / N
Note that this version with total
also accepts the /nan
keyword, so that it works even when some data are missing.