elapid.stats¶
Utilities for calculating zonal stats and other transformations
RasterStat
¶
Utility class to iterate over and apply reductions to multiband arrays
Source code in elapid/stats.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
__init__(name, method, dtype=None, **kwargs)
¶
Create a RasterStat object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the label to prepend to the output column |
required |
method |
Callable
|
function to reduce a 2d ndarray to an (nbands,) shape array |
required |
dtype |
str
|
the output array data type |
None
|
**kwargs |
additional arguments to pass to |
{}
|
Source code in elapid/stats.py
14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
format(x)
¶
Format the array data into an array of shape [nbands, n_valid_pixels]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
ndarray of shape (nbands, nrows, ncols) or (nbands, n_valid_pixels) |
required |
Returns:
Type | Description |
---|---|
ndarray
|
2d ndarray |
Source code in elapid/stats.py
28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
reduce(x)
¶
Reduce an array using the objects method
function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
ndarray of shape (nbands, n_valid_pixels) |
required |
Returns:
Type | Description |
---|---|
ndarray
|
ndarray of shape (nbands,) |
Source code in elapid/stats.py
42 43 44 45 46 47 48 49 50 51 |
|
get_raster_stats_methods(mean=True, min=False, max=False, count=False, sum=False, stdv=False, skew=False, kurtosis=False, mode=False, percentiles=[], all=False)
¶
Return RasterStat configs for the requested stats calculations
Source code in elapid/stats.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
normalize_sample_probabilities(values)
¶
Compute scaled probability scores for an array of samples.
These normalized probabilities sum to 1.0 and are designed to be used
as the p
parameter for determining sample probabilities in
np.random.choice
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
ArrayLike
|
numeric array to be treated as sample probabilities.
probabilities will be scaled linearly based on the input range.
setting |
required |
Returns:
Type | Description |
---|---|
ndarray
|
sample probabiility scores |
Source code in elapid/stats.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|