ess.imaging.tools.analysis.resample#
- ess.imaging.tools.analysis.resample(image, sizes, method='sum')[source]#
Resample an image by folding it into blocks of specified sizes and applying a reduction method. The sizes should be provided as a dictionary where the keys are dimension names and the values are the sizes of the blocks. The shape of the input image must be divisible by the block sizes.
- Parameters:
sizes (
dict[str,int]) – A dictionary specifying the block sizes for each dimension. For example,{'x': 4, 'y': 4}will create blocks of size 4x4. Any dimensions with size1will be ignored. If all sizes are set to1, it will not applymethodand return a copy of the input resampling image.method (
str|Callable, default:'sum') – The reduction method to apply to the blocks. This can be a string referring to any valid Scipp reduction method, such as ‘sum’, ‘mean’, ‘max’, etc. Alternatively, a custom reduction function can be provided. The function signature should accept ascipp.Variableorscipp.DataArrayas first argument and a set of dimensions to reduce over as second argument. The function should return ascipp.Variableorscipp.DataArray.
- Return type:
Notes
If the image is a
scipp.DataArray, bin edges in the resampling dimensions will be preserved if they are 1-dimensional and sorted (they are dropped otherwise). New bin edges will be chosen according to the resampling sizes. For midpoint coordinates, new coordinates will be average values of each resampled block.Warning
The coordinates in the output may not be correct if they are not sorted or not linear.