5.26. bin

Bins the data of the FitsArray object.


FitsArray.bin(self, binning_factor: int | List[int], func: Callable[[Any], float] = np.mean, output: str | None = None) Self

Bins the data of the FitsArray object.

Parameters

binning_factorUnion[int, List[Union[int, List[int]]]]

Binning factor.

funcCallable[[Any], float], default np.mean

The function to be used for merging values during binning.

outputOptional[str]

New path to save the files.

Returns

FitsArray

A binned FitsArray object.

Raises

ValueError

When the binning_factor is invalid.

ValueError

When the binning_factor is too large.


5.26.1. Example:

from myraflib import FitsArray
import math

fa = FitsArray.sample()

cropped_fa_1 = fa.bin(10)
cropped_fa_2 = fa.bin([10, 20])