focal.focal_correlation
- focal.focal_correlation(a1: Array, a2: Array, *, window: int | tuple[int, ...] | list[int] | ndarray[tuple[int, ...], bool] | Window, fraction_accepted: float = 0.7, verbose: bool = False, reduce: bool = False, chunks: int | tuple[int, int] | None = None, p_values: bool = False, out: CorrelationResult | None = None) CorrelationResult
Focal correlation.
- Parameters:
a1 (Array) – Input arrays to be correlated. They must have the same shape and be two-dimensional.
a2 (Array) – Input arrays to be correlated. They must have the same shape and be two-dimensional.
window (int, array-like, or Window, optional) –
Window applied over the input arrays. It can be:
An integer (interpreted as a square window),
A sequence of integers (interpreted as a rectangular window),
A boolean array,
Or a
pyspatialstats.windows.Windowobject.
fraction_accepted (float, optional) –
Fraction of valid cells (i.e., not NaN) per window required for the correlation to be computed.
0: include views with at least 1 valid value1: include only fully valid viewsBetween
0and1: minimum fraction of valid values required
Default is 0.7.
verbose (bool, optional) – If True, print timing. Default is False.
reduce (bool, optional) – If True, use each pixel exactly once without overlapping windows. The resulting array will have shape
a_shape / window_shape. Default is False.p_values (bool, optional) – If True, calculate p-values along with correlation coefficients. Default is False.
chunks (int or tuple of int, optional) – Shape of chunks to split the array into. If None, the array is not split into chunks, which is the default.
out (CorrelationResult, optional) – CorrelationResult object to write results to.
- Returns:
Dataclass containing correlation coefficients (and optionally p-values).
- Return type:
CorrelationResult