From 9810c64974ba1aeafdbc640f601fdf90e4f5ce05 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Thu, 25 Jul 2024 17:03:23 +0200 Subject: [PATCH] Deployed 6de52a7 with MkDocs version: 1.6.0 --- api/chunks/index.html | 166 +++-- api/multiscale/index.html | 482 +++++++------- api/reducers/index.html | 1242 ++++++++++++++++++------------------- api/util/index.html | 290 +++++---- assets/_mkdocstrings.css | 5 + index.html | 2 +- sitemap.xml | 10 +- sitemap.xml.gz | Bin 257 -> 257 bytes 8 files changed, 1065 insertions(+), 1132 deletions(-) diff --git a/api/chunks/index.html b/api/chunks/index.html index 5383b19..680886f 100644 --- a/api/chunks/index.html +++ b/api/chunks/index.html @@ -502,12 +502,11 @@

chunks

-
+
- -
+
@@ -520,90 +519,87 @@

chunks

-

- normalize_chunks + normalize_chunks #

normalize_chunks(array, chunk_size)
 
-
- -

Given an xarray.DataArray, normalize a chunk size against that array.

+
+

Given an xarray.DataArray, normalize a chunk size against that array.

-

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + + + + + + + + + + + + + + + + +
array - DataArray - -
-

An xarray.DataArray.

-
-
- required - NameTypeDescriptionDefault
array + DataArray + +
+

An xarray.DataArray.

+
+
+ required +
chunk_size + str | int | Sequence[int] | dict[Hashable, int] + +
+

A specification of a chunk size.

+
+
+ required +
+ + +

Returns:

+ + - - - - - - -
chunk_size - str | int | Sequence[int] | dict[Hashable, int] - -
-

A specification of a chunk size.

-
-
- required -
- - - -

Returns:

- - - - - - - - - - - + + - -
TypeDescription
- dict[Hashable, int] - -
-

An xarray-compatible specification of chunk sizes.

-
-
TypeDescription
- -
- Source code in src/xarray_multiscale/chunks.py -
+ + + + + +
15
+      
+      
+ dict[Hashable, int] + +
+

An xarray-compatible specification of chunk sizes.

+
+
+ +
+ Source code in src/xarray_multiscale/chunks.py +
15
 16
 17
 18
@@ -703,32 +699,30 @@ 

return {dim: new_chunks[array.get_axis_num(dim)] for dim in array.dims}

-
-
+
+
-
-

- align_chunks + align_chunks #

align_chunks(array, scale_factors)
 
-
- +
+

Ensure that all chunks of a dask array are divisible by scale_factors, rechunking the array if necessary.

-
- Source code in src/xarray_multiscale/chunks.py -
+ + +
67
+            
+ Source code in src/xarray_multiscale/chunks.py +
67
 68
 69
 70
@@ -754,8 +748,8 @@ 

array = array.rechunk(new_chunks) return array

-
-
+ + @@ -763,7 +757,7 @@

- + diff --git a/api/multiscale/index.html b/api/multiscale/index.html index 870652f..cc10bc7 100644 --- a/api/multiscale/index.html +++ b/api/multiscale/index.html @@ -556,12 +556,11 @@

multiscale

-
+
- -
+
@@ -574,110 +573,99 @@

multiscale

-

- multiscale + multiscale #

-
multiscale(
-    array,
-    reduction,
-    scale_factors,
-    preserve_dtype=True,
-    chunks="preserve",
-    chained=True,
-    namer=_default_namer,
-    **kwargs
-)
+
multiscale(array, reduction, scale_factors, preserve_dtype=True, chunks='preserve', chained=True, namer=_default_namer, **kwargs)
 
-
- -

Generate a coordinate-aware multiscale representation of an array.

+
+

Generate a coordinate-aware multiscale representation of an array.

-

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - + + + + + + + + + + + +
array - Array-like, e.g. Numpy array, Dask array - -
-

The array to be downscaled.

-
-
- required - NameTypeDescriptionDefault
reduction - callable - -
-

A function that aggregates chunks of data over windows. +

array + Array-like, e.g. Numpy array, Dask array + +
+

The array to be downscaled.

+
+
+ required +
reduction + callable + +
+

A function that aggregates chunks of data over windows. See xarray_multiscale.reducers.WindowedReducer for the expected signature of this callable.

-
-
- required -
scale_factors - int or sequence of ints - -
-

The desired downscaling factors, one for each axis, or a single +

+
+ required +
scale_factors + int or sequence of ints + +
+

The desired downscaling factors, one for each axis, or a single value for all axes.

-
-
- required -
preserve_dtype - bool - -
-

If True, output arrays are all cast to the same data type as the +

+
+ required +
preserve_dtype + bool + +
+

If True, output arrays are all cast to the same data type as the input array. If False, output arrays will have data type determined by the output of the reduction function.

-
-
- True -
chunks - sequence or dict of ints, or the string "preserve" (default) - -
-

Set the chunking of the output arrays. Applies only to dask arrays. +

+
+ True +
chunks + sequence or dict of ints, or the string "preserve" (default) + +
+

Set the chunking of the output arrays. Applies only to dask arrays. If chunks is set to "preserve" (the default), then chunk sizes will decrease with each level of downsampling. Otherwise, this argument is passed to xarray_multiscale.chunks.normalize_chunks.

@@ -686,20 +674,20 @@

producing a list of arrays with the same chunk size. Note that rechunking can be computationally expensive for arrays with many chunks.

-

-
- 'preserve' -
chained - bool - -
-

If True (default), the nth downscaled array is generated by +

+
+ 'preserve' +
chained + bool + +
+

If True (default), the nth downscaled array is generated by applying the reduction function on the n-1th downscaled array with the user-supplied scale_factors. This means that the nth downscaled array directly depends on the n-1th downscaled array. @@ -710,76 +698,74 @@

(i.e., the input array) with the scale_factors raised to the nth power. This means that the nth downscaled array directly depends on the input array.

-

-
- True -
namer - callable, defaults to `_default_namer` - -
-

A function for naming the output arrays. This function should take an integer +

+
+ True +
namer + callable, defaults to `_default_namer` + +
+

A function for naming the output arrays. This function should take an integer index and return a string. The default function simply prepends the string representation of the integer with the character "s".

-
-
- _default_namer -
+ _default_namer +
**kwargs + Any + +
+

Additional keyword arguments that will be passed to the reduction function.

+
+
+ {} +
+ + +

Returns:

+ + - - - - + + - -
**kwargs - Any - -
-

Additional keyword arguments that will be passed to the reduction function.

-
-
- {} - Name TypeDescription
- - - -

Returns:

- - - - - - - - - - - + + + - - -
Name TypeDescription
result - list[DataArray] - -
-

The first element of this list is the input array, converted to an + +

result + list[DataArray] + +
+

The first element of this list is the input array, converted to an xarray.DataArray. Each subsequent element of the list is the result of downsampling the previous element of the list.

The coords attributes of these DataArrays track the changing offset and scale induced by the downsampling operation.

-
-
- +
+
-

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale import multiscale
 >>> from xarray_multiscale.reducers import windowed_mean
@@ -793,9 +779,9 @@ 

* dim_0 (dim_0) float64 0.5 2.5]

-
- Source code in src/xarray_multiscale/multiscale.py -
 31
+            
+ Source code in src/xarray_multiscale/multiscale.py +
 31
  32
  33
  34
@@ -1019,31 +1005,29 @@ 

return result

-
-
+ + -
-

- to_dataarray + to_dataarray #

to_dataarray(array, name=None)
 
-
- +
+

Convert the input to an xarray.DataArray if it is not already one.

-
- Source code in src/xarray_multiscale/multiscale.py -
145
+            
+ Source code in src/xarray_multiscale/multiscale.py +
145
 146
 147
 148
@@ -1085,31 +1069,29 @@ 

result = xarray.DataArray(data=data, coords=coords, dims=dims, attrs=attrs, name=name) return result

-
-
+ + -
-

- downscale_dask + downscale_dask #

downscale_dask(array, reduction, scale_factors, **kwargs)
 
-
- +
+

Downscale a dask array.

-
- Source code in src/xarray_multiscale/multiscale.py -
168
+            
+ Source code in src/xarray_multiscale/multiscale.py +
168
 169
 170
 171
@@ -1163,31 +1145,29 @@ 

graph = HighLevelGraph.from_collections(name, dsk, dependencies=[array]) return Array(graph, name, chunks, meta=meta)

-
-
+ + -
-

- downscale_coords + downscale_coords #

downscale_coords(array, scale_factors)
 
-
- +
+

Downscale coordinates by taking the windowed mean of each coordinate array.

-
- Source code in src/xarray_multiscale/multiscale.py -
+ + + + + + + + + + + + + +
215
+            
+ Source code in src/xarray_multiscale/multiscale.py +
215
 216
 217
 218
@@ -1215,26 +1195,24 @@ 

new_coords[coord_name] = coord.coarsen(coarsening_dims).mean() return new_coords

-
-
+ + -
-

- downsampling_depth + downsampling_depth #

downsampling_depth(shape, scale_factors)
 
-
- +
+

For a shape and a sequence of scale factors, calculate the number of downsampling operations that must be performed to produce a downsampled shape with at least one singleton value.

@@ -1243,52 +1221,50 @@

If all scale_factors are 1, this function returns 0.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - - - - -
shape - Sequence[int] - -
-

An array shape.

-
-
- required - NameTypeDescriptionDefault
scale_factors - Sequence[int] - -
-

Downsampling factors.

-
-
- required -
- + +

shape + Sequence[int] + +
+

An array shape.

+
+
+ required +
scale_factors + Sequence[int] + +
+

Downsampling factors.

+
+
+ required +
-

Examples:

+

Examples:

>>> downsampling_depth((8,), (2,))
 3
 >>> downsampling_depth((8,2), (2,2))
@@ -1297,9 +1273,9 @@ 

2

-
- Source code in src/xarray_multiscale/multiscale.py -
+ + +
231
+            
+ Source code in src/xarray_multiscale/multiscale.py +
231
 232
 233
 234
@@ -1389,8 +1365,8 @@ 

result = min(depths.astype("int")) return result

-
-
+ + @@ -1398,7 +1374,7 @@

- + diff --git a/api/reducers/index.html b/api/reducers/index.html index 03d5c3c..bf6b9ed 100644 --- a/api/reducers/index.html +++ b/api/reducers/index.html @@ -610,12 +610,11 @@

reducers

-
+
- -
+
@@ -628,95 +627,91 @@

reducers

-

- reshape_windowed + reshape_windowed #

reshape_windowed(array, window_size)
 
-
- +
+

Reshape an array to support windowed operations. New dimensions will be added to the array, one for each element of window_size.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - -
array - NDArray[Any] - -
-

The array to be reshaped. The array must have a reshape method.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window size. The length of window_size must match the +

array + NDArray[Any] + +
+

The array to be reshaped. The array must have a reshape method.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window size. The length of window_size must match the dimensionality of array.

-
-
- required -
- - - -

Returns:

- - - - - - - - + + + + + +
TypeDescription
+ required +
+ + +

Returns:

+ + - - + + + + + + + - - -
- The input array reshaped with extra dimensions. - -
-

E.g., for an array with shape (10, 2), +

TypeDescription
+ The input array reshaped with extra dimensions. + +
+

E.g., for an array with shape (10, 2), reshape_windowed(array, (2, 2)) returns output with shape (5, 2, 1, 2).

-
-
- +
+
-

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import reshape_windowed
 >>> data = np.arange(12).reshape(3, 4)
@@ -725,9 +720,9 @@ 

(3, 1, 2, 2)

-
- Source code in src/xarray_multiscale/reducers.py -
+ + +
24
+            
+ Source code in src/xarray_multiscale/reducers.py +
24
 25
 26
 27
@@ -807,115 +802,112 @@ 

new_shape += (s // f, f) return array.reshape(new_shape)

-
-
+ + -
-

- windowed_mean + windowed_mean #

windowed_mean(array, window_size, **kwargs)
 
-
- -

Compute the windowed mean of an array.

+
+

Compute the windowed mean of an array.

-

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - + + + + + + + + + + - - - - - - + + + + + + - - + + + + + + + + + + + +
array - NDArray[Any] - -
-

The array to be downscaled. The array must have +

NameTypeDescriptionDefault
array + NDArray[Any] + +
+

The array to be downscaled. The array must have reshape and mean methods that obey the np.reshape and np.mean APIs.

-
-
- required -
window_size - tuple[int, ...] - -
-

The window to use for aggregations. The array is partitioned into +

+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregations. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are aggregated to generate the result.

-
-
- required -
+ required +
**kwargs + Any + +
+

Extra keyword arguments passed to array.mean

+
+
+ {} +
+ + +

Returns:

+ + - - - - + + - -
**kwargs - Any - -
-

Extra keyword arguments passed to array.mean

-
-
- {} - TypeDescription
- - - -

Returns:

- - - - - - - - - - - + + + - - -
TypeDescription
- Array - like - -
-

The result of the windowed mean. The length of each axis of this array + +

+ Array - like + +
+

The result of the windowed mean. The length of each axis of this array will be a fraction of the input. The datatype is determined by the behavior of array.mean given the kwargs (if any) passed to it.

-
-
+
+
+
Notes @@ -926,8 +918,7 @@

implementation of the array reshaping routine.

- -

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_mean
 >>> data = np.arange(16).reshape(4, 4)
@@ -936,9 +927,9 @@ 

[10.5, 12.5]])

-
- Source code in src/xarray_multiscale/reducers.py -
+ + +
 66
+            
+ Source code in src/xarray_multiscale/reducers.py +
 66
  67
  68
  69
@@ -1036,114 +1027,111 @@ 

result: npt.NDArray[Any] = reshaped.mean(axis=tuple(range(1, reshaped.ndim, 2)), **kwargs) return result

-
-
+ + -
-

- windowed_max + windowed_max #

windowed_max(array, window_size, **kwargs)
 
-
- -

Compute the windowed maximum of an array.

+
+

Compute the windowed maximum of an array.

-

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - + + + + + + + + + + + +
array - NDArray[Any] - -
-

The array to be downscaled. The array must have reshape and -max methods.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window to use for aggregations. The array is partitioned into +

array + NDArray[Any] + +
+

The array to be downscaled. The array must have reshape and +max methods.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregations. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are aggregated to generate the result.

-
-
- required -
+ required +
**kwargs + Any + +
+

Extra keyword arguments passed to array.mean

+
+
+ {} +
+ + +

Returns:

+ + - - - - + + - -
**kwargs - Any - -
-

Extra keyword arguments passed to array.mean

-
-
- {} - TypeDescription
- - - -

Returns:

- - - - - - - - - - - + + + - - -
TypeDescription
- Array - like - -
-

The result of the windowed max. The length of each axis of this array + +

+ Array - like + +
+

The result of the windowed max. The length of each axis of this array will be a fraction of the input. The datatype of the return value will will be the same as the input.

-
-
+
+
+
Notes @@ -1154,8 +1142,7 @@

the implementation of the array reshaping routine.

- -

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_mean
 >>> data = np.arange(16).reshape(4, 4)
@@ -1164,9 +1151,9 @@ 

[13, 15]])

-
- Source code in src/xarray_multiscale/reducers.py -
+ + +
117
+            
+ Source code in src/xarray_multiscale/reducers.py +
117
 118
 119
 120
@@ -1262,114 +1249,111 @@ 

result: npt.NDArray[Any] = reshaped.max(axis=tuple(range(1, reshaped.ndim, 2)), **kwargs) return result

-
-
+ + -
-

- windowed_min + windowed_min #

windowed_min(array, window_size, **kwargs)
 
-
- -

Compute the windowed minimum of an array.

+
+

Compute the windowed minimum of an array.

-

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - + + + + + + + + + + + +
array - NDArray[Any] - -
-

The array to be downscaled. The array must have reshape and -min methods.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window to use for aggregations. The array is partitioned into +

array + NDArray[Any] + +
+

The array to be downscaled. The array must have reshape and +min methods.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregations. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are aggregated to generate the result.

-
-
- required -
+ required +
**kwargs + Any + +
+

Extra keyword arguments passed to array.mean

+
+
+ {} +
+ + +

Returns:

+ + - - - - + + - -
**kwargs - Any - -
-

Extra keyword arguments passed to array.mean

-
-
- {} - TypeDescription
- - - -

Returns:

- - - - - - - - - - - + + + - - -
TypeDescription
- Array - like - -
-

The result of the windowed min. The length of each axis of this array + +

+ Array - like + +
+

The result of the windowed min. The length of each axis of this array will be a fraction of the input. The datatype of the return value will will be the same as the input.

-
-
+
+
+
Notes @@ -1380,8 +1364,7 @@

for the implementation of the array reshaping routine.

- -

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_mean
 >>> data = np.arange(16).reshape(4, 4)
@@ -1390,9 +1373,9 @@ 

[8, 10]])

-
- Source code in src/xarray_multiscale/reducers.py -
+ + + + + +
167
+            
+ Source code in src/xarray_multiscale/reducers.py +
167
 168
 169
 170
@@ -1488,66 +1471,63 @@ 

result: npt.NDArray[Any] = reshaped.min(axis=tuple(range(1, reshaped.ndim, 2)), **kwargs) return result

-
-
+ + -
-

- windowed_mode + windowed_mode #

windowed_mode(array, window_size)
 
-
- +
+

Compute the windowed mode of an array using either windowed_mode_countess or windowed_mode_scipy Input will be coerced to a numpy array.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - -
array - NDArray[Any] - -
-

The array to be downscaled. The array must have a reshape -method.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window to use for aggregation. The array is partitioned into +

array + NDArray[Any] + +
+

The array to be downscaled. The array must have a reshape +method.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregation. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are aggregated to generate the result. If the product of the elements of window_size is 16 or less, then @@ -1555,43 +1535,41 @@

windowed_mode_scipy is used. This is a speculative cutoff based on the documentation of the countless algorithm used in windowed_mode_countless which was created by William Silversmith.

-

-
- required -
- - - -

Returns:

- - - - - - - - + + + + + +
TypeDescription
+ required +
+ + +

Returns:

+ + - - + + - -
- Numpy array - -
-

The result of the windowed mode. The length of each axis of this array -will be a fraction of the input.

-
-
TypeDescription
- + +
+ Numpy array + +
+

The result of the windowed mode. The length of each axis of this array +will be a fraction of the input.

+
+
-

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_mode
 >>> data = np.arange(16).reshape(4, 4)
@@ -1600,9 +1578,9 @@ 

[ 8, 10]])

-
- Source code in src/xarray_multiscale/reducers.py -
+ + + + + +
217
+            
+ Source code in src/xarray_multiscale/reducers.py +
217
 218
 219
 220
@@ -1686,108 +1664,104 @@ 

else: return windowed_mode_scipy(array, window_size)

-
-
+ + -
-

- windowed_mode_scipy + windowed_mode_scipy #

windowed_mode_scipy(array, window_size)
 
-
- +
+

Compute the windowed mode of an array using scipy.stats.mode. Input will be coerced to a numpy array.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - -
array - NDArray[Any] - -
-

The array to be downscaled. The array must have a reshape -method.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window to use for aggregation. The array is partitioned into +

array + NDArray[Any] + +
+

The array to be downscaled. The array must have a reshape +method.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregation. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are aggregated to generate the result.

-
-
- required -
- - - -

Returns:

- - - - - - - - + + + + + +
TypeDescription
+ required +
+ + +

Returns:

+ + - - + + - -
- Numpy array - -
-

The result of the windowed mode. The length of each axis of this array -will be a fraction of the input.

-
-
TypeDescription
+ +
+ Numpy array + +
+

The result of the windowed mode. The length of each axis of this array +will be a fraction of the input.

+
+
+
Notes

This function wraps scipy.stats.mode.

- -

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_mode
 >>> data = np.arange(16).reshape(4, 4)
@@ -1796,9 +1770,9 @@ 

[ 8, 10]])

-
- Source code in src/xarray_multiscale/reducers.py -
+ + + + + +
261
+            
+ Source code in src/xarray_multiscale/reducers.py +
261
 262
 263
 264
@@ -1880,26 +1854,24 @@ 

result: npt.NDArray[Any] = mode(collapsed, axis=collapsed.ndim - 1, keepdims=False).mode return result

-
-
+ + -
-

- windowed_mode_countless + windowed_mode_countless #

windowed_mode_countless(array, window_size)
 
-
- +
+

countless downsamples labeled images (segmentations) by finding the mode using vectorized instructions. It is ill advised to use this O(2^N-1) time algorithm @@ -1915,53 +1887,52 @@

Parameters:

+ + - - - - + + + + - - - - + + + + + + + + + + + - - - -
array - NDArray[Any] - -
-

The array to be downscaled.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window size. The length of window_size must match the +

array + NDArray[Any] + +
+

The array to be downscaled.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window size. The length of window_size must match the dimensionality of array.

-
-
- required -
- -
- Source code in src/xarray_multiscale/reducers.py -
+ + + +
312
+              
+
+ required +
+ +
+ Source code in src/xarray_multiscale/reducers.py +
312
 313
 314
 315
@@ -2099,123 +2070,118 @@ 

return final_result

-
-
+
+

-
-

- windowed_rank + windowed_rank #

windowed_rank(array, window_size, rank=-1)
 
-
- +
+

Compute the windowed rank order filter of an array. Input will be coerced to a numpy array.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - -
array - NDArray[Any] - -
-

The array to be downscaled. The array must have a reshape -method.

-
-
- required - NameTypeDescriptionDefault
window_size - tuple[int, ...] - -
-

The window to use for aggregation. The array is partitioned into +

array + NDArray[Any] + +
+

The array to be downscaled. The array must have a reshape +method.

+
+
+ required +
window_size + tuple[int, ...] + +
+

The window to use for aggregation. The array is partitioned into non-overlapping regions with size equal to window_size, and the values in each window are sorted to generate the result.

-
-
- required -
rank - int - -
-

The index to take from the sorted values in each window. If non-negative, then +

+
+ required +
rank + int + +
+

The index to take from the sorted values in each window. If non-negative, then rank must be between 0 and the product of the elements of window_size minus one, (inclusive). Rank may be negative, in which case it denotes an index relative to the end of the sorted values following normal python indexing rules. E.g., when rank is -1 (the default), this takes the maxmum value of each window.

-
-
- -1 -
- - - -

Returns:

- - - - - - - - + + + + + +
TypeDescription
+ -1 +
+ + +

Returns:

+ + - - + + - -
- Numpy array - -
-

The result of the windowed rank filter. The length of each axis of this array -will be a fraction of the input.

-
-
TypeDescription
- + +
+ Numpy array + +
+

The result of the windowed rank filter. The length of each axis of this array +will be a fraction of the input.

+
+
-

Examples:

+

Examples:

>>> import numpy as np
 >>> from xarray_multiscale.reducers import windowed_rank
 >>> data = np.arange(16).reshape(4, 4)
@@ -2224,9 +2190,9 @@ 

[12 14]])

-
- Source code in src/xarray_multiscale/reducers.py -
383
+            
+ Source code in src/xarray_multiscale/reducers.py +
383
 384
 385
 386
@@ -2336,8 +2302,8 @@ 

result: npt.NDArray[Any] = np.take(np.sort(collapsed, axis=-1), rank, axis=-1) return result

-
-
+ + @@ -2345,7 +2311,7 @@

- + diff --git a/api/util/index.html b/api/util/index.html index 4a1a98e..19f447b 100644 --- a/api/util/index.html +++ b/api/util/index.html @@ -500,12 +500,11 @@

util

-
+
- -
+
@@ -518,94 +517,91 @@

util

-

- adjust_shape + adjust_shape #

adjust_shape(array, scale_factors)
 
-
- +
+

Pad or crop array such that its new dimensions are evenly divisible by a set of integers.

- -

Parameters:

- - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
+ - - - - + + + + - - - - + + + + + + + + + + + - - - -
array - ndarray - -
-

Array that will be padded.

-
-
- required - NameTypeDescriptionDefault
scale_factors - Sequence of ints - -
-

The output array is guaranteed to have dimensions that are each +

array + ndarray + +
+

Array that will be padded.

+
+
+ required +
scale_factors + Sequence of ints + +
+

The output array is guaranteed to have dimensions that are each evenly divisible by the corresponding scale factor, and chunks that are smaller than or equal to the scale factor (if the array has chunks)

-
-
- required -
- - - -

Returns:

- - - - - - - - + + + + + +
TypeDescription
+ required +
+ + +

Returns:

+ + - - + + - -
- DataArray - -
- -
-
TypeDescription
- -
- Source code in src/xarray_multiscale/util.py -
+ + + + + +
 8
+      
+      
+ DataArray + +
+ +
+
+ +
+ Source code in src/xarray_multiscale/util.py +
 8
  9
 10
 11
@@ -657,99 +653,95 @@ 

result = array.isel({d: slice(s) for d, s in zip(array.dims, new_shape)}) return result

-
-
+
+
-
-

- logn + logn #

logn(x, n)
 
-
- -

Compute the logarithm of x base n.

+
+

Compute the logarithm of x base n.

-

Parameters:

- - - - - - - - - - - - - - - - +

Parameters:

+
NameTypeDescriptionDefault
x - float or int. - -
- -
-
- required -
+ - - - - + + + + - -
n - ArrayLike - -
- -
-
- required - NameTypeDescriptionDefault
- - - -

Returns:

- - - - - - - - + + + + + + + + + + + + + + + +
TypeDescription
x + float or int. + +
+ +
+
+ required +
n + ArrayLike + +
+ +
+
+ required +
+ + +

Returns:

+ + - - + + - -
- float - -
-

np.log(x) / np.log(n)

-
-
TypeDescription
- -
- Source code in src/xarray_multiscale/util.py -
+ + + + + +
36
+      
+      
+ float + +
+

np.log(x) / np.log(n)

+
+
+ +
+ Source code in src/xarray_multiscale/util.py +
36
 37
 38
 39
@@ -783,8 +775,8 @@ 

result: npt.NDArray[np.float64] = np.log(x) / np.log(n) return result

-
-
+
+
@@ -792,7 +784,7 @@

-
+
diff --git a/assets/_mkdocstrings.css b/assets/_mkdocstrings.css index 57a23e1..85449ec 100644 --- a/assets/_mkdocstrings.css +++ b/assets/_mkdocstrings.css @@ -26,6 +26,11 @@ float: right; } +/* Backward-compatibility: docstring section titles in bold. */ +.doc-section-title { + font-weight: bold; +} + /* Symbols in Navigation and ToC. */ :root, [data-md-color-scheme="default"] { diff --git a/index.html b/index.html index fc1632d..35d3a90 100644 --- a/index.html +++ b/index.html @@ -648,7 +648,7 @@

Coordinates matter when y | |

Another way of thinking about this is that if you downsample an arbitrarily large image to a single value, then the only sensible place to localize that value is at the center of the image. Thus, incrementally downsampling slightly shifts the downsampled image toward that point.

-

Why should you care? If you work with images where the coordinates matter (for example, images recorded from scientific instruments), then you should care about keeping track of those coordinates. Tools like numpy or scikit-image make it very easy to ignore the coordinates of your image. These tools model images as simple arrays, and from the array perspective data[0,0] and downsampled_data[0,0] lie on the same position in space because they take the same array index. However, downsampled_data[0,0] is almost certainly shifted relative to data[0,0]. Coordinate-blind tools like scikit-image force your to track the coordinates on your own, which is a recipe for mistakes. This is the value of xarray. By explicitly modelling coordinates alongside data values, xarray ensures that you never lose track of where your data comes from, which is why xarray-multiscale uses it.

+

Why should you care? If you work with images where the coordinates matter (for example, images recorded from scientific instruments), then you should care about keeping track of those coordinates. Tools like numpy or scikit-image make it very easy to ignore the coordinates of your image. These tools model images as simple arrays, and from the array perspective data[0,0] and downsampled_data[0,0] lie on the same position in space because they take the same array index. However, downsampled_data[0,0] is almost certainly shifted relative to data[0,0]. Coordinate-blind tools like scikit-image force you to track the coordinates on your own, which is a recipe for mistakes. This is the value of xarray. By explicitly modelling coordinates alongside data values, xarray ensures that you never lose track of where your data comes from, which is why xarray-multiscale uses it.

Who needs this#

The library xarray already supports basic downsampling routines via the DataArray.coarsen API. So if you use xarray and just need to compute a windowed mean, then you may not need xarray-multiscale at all. But the DataArray.coarsen API does not allow users to provide their own downsampling functions; If you need something like windowed mode downsampling, or something you wrote yourself, then xarray-multiscale should be useful to you.

diff --git a/sitemap.xml b/sitemap.xml index d84af4b..98f71f3 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,27 +2,27 @@ https://janeliascicomp.github.io/xarray-multiscale/ - 2024-07-24 + 2024-07-25 daily https://janeliascicomp.github.io/xarray-multiscale/api/chunks/ - 2024-07-24 + 2024-07-25 daily https://janeliascicomp.github.io/xarray-multiscale/api/multiscale/ - 2024-07-24 + 2024-07-25 daily https://janeliascicomp.github.io/xarray-multiscale/api/reducers/ - 2024-07-24 + 2024-07-25 daily https://janeliascicomp.github.io/xarray-multiscale/api/util/ - 2024-07-24 + 2024-07-25 daily \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 1f7af1157063e0788e6fbcd15c4491c8e7d02a9d..5ed3746753186c5004636a1ebd1362b6356322c6 100644 GIT binary patch delta 237 zcmV+c{J0F%$?c1isPX~Yg=aJH z^mu$4f!v>*t-ehp48CJ`ykV8`I`rs=j=dfa^%L8xoy^gaNmVg>>e!gl^diJO&zvwB z2NUrS2SIu)8xl8BH2j&VT~%rcxUMcGZP02-p%U`}-dF_EsDqpMfN9Kc9D`jrL5y&& zUA75HgEc~m<={F8D7nz9wrTI{=CN)cish!QY-q#Z4P_G6OX3Px;*F2f#-zw|Di9f{ABe5?oydz`2zp|II?xj delta 237 zcmV+c{J0Fn$?c1isPX~Yg=aJH z^mu$4fjpd@txhHq2H&v<-muDe9eVUb$KH;w^%Fa&oy^gaNmVg>>e!gl^diJO&zvwB z2NUrS2SIu)8xnU>H2j&VT~%rcxUH@wZP02-p%U{6-dF_EsDqpMfN9L{9D`jrLyT~# zUA75HgEc~m<={F8D7nz9wrTfu^H{h0V!3N8n;yXr<|CSK)dSj#6f5NhD1Hh5h!rL* nw`BiCo5SAl#G~o6F3)*$;5niFf9Pu~KUw_%00w%0`2zp|iG^|W