downsample_axis¶
-
FITS_tools.downsample.
downsample_axis
(myarr, factor, axis, estimator=<function nanmean>, truncate=False)[source] [edit on github]¶ Downsample an ND array by averaging over factor pixels along an axis. Crops right side if the shape is not a multiple of factor.
This code is pure np and should be fast.
Parameters: myarr :
ndarray
The array to downsample
factor : int
The factor to downsample by
axis : int
The axis to downsample along
estimator : function
defaults to mean. You can downsample by summing or something else if you want a different estimator (e.g., downsampling error: you want to sum & divide by sqrt(n))
truncate : bool
Whether to truncate the last chunk or average over a smaller number. e.g., if you downsample [1,2,3,4] by a factor of 3, you could get either [2] or [2,4] if truncate is True or False, respectively.