Indexing
indexing
¶
Functions¶
find_argmax_nonzero_value(array, keepdims=False, axis=1)
¶
Find the argmax of an array, setting entires with zero sum or finite values to nan
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The input array |
required |
keepdims
|
bool
|
Should the dimensions be kept. Defaults to False. |
False
|
axis
|
int
|
Which axis to perform the argmax along. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
array
|
np.array: The argmax, with nans for invalid or all-zero entries |
Source code in geograypher/utils/indexing.py
inverse_map_interpolation(ijmap, downsample=1, fill=-1)
¶
Inverts the type of map that can be fed to skimage.transform.warp.
The basic construction is the pixel position of these maps is the position in the destination image, and the value of the map is the position in the source image. Therefore if location [20, 30] has value [22.2, 28.4], it means that the destination image pixel [20, 30] will be sampled from the source image at pixel [22.2, 28.4] (the sampler can choose to snap to the closest integer value or interpolate nearby pixels).
By inverting, we seek to reverse this map through interpolation. In the example above, in the output we would now have the location [22, 28] have the value [20, 30] (or slightly different because it might interpolate with nearby values).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ijmap
|
(2, H, W) numpy array
|
a map of the structure discussed above |
required |
downsample
|
int
|
Inverting (particularly griddata) can be expensive for high-res image maps. You can downsample in integer steps to save computation, which will downsample both the (i, j) axes. Using downsample=2 will therefore interpolate on 1/4 of the pixels. |
1
|
fill
|
int
|
Values outside of the interpolation convex hull will take this value. |
-1
|
Returns:
Type | Description |
---|---|
ndarray
|
(2, H, W) numpy array of the same shape as ijmap |