Skip to content

Commit

Permalink
Fleshing out linear decay kernel docstring.
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Feb 7, 2023
1 parent 77357f9 commit a439764
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/pygeoprocessing/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,30 @@ def _exponential_decay(dist):
)


def linear_decay_kernel(target_kernel_path, max_distance, pixel_radius=None,
normalize=True):
def linear_decay_kernel(
target_kernel_path: Text,
max_distance: Union[int, float],
pixel_radius: Union[int, float] = None,
normalize: bool = True) -> None:
"""Create a linear decay kernel.
Args:
target_kernel_path: The path to where the kernel will be written.
Must have a file extension of ``.tif``.
max_distance: The maximum distance of the kernel, in pixels. Kernel
pixels that are greater than ``max_distance`` from the centerpoint
of the kernel will have values of ``0.0``.
pixel_radius: The radius of the target kernel, in pixels. If ``None``,
then ``math.ceil(max_distance)`` will be used.
normalize: Whether to normalize the kernel.
Returns:
``None``
"""

def _linear_decay(dist):
return (max_distance - dist) / max_distance

create_kernel(
target_kernel_path=target_kernel_path,
function="(max_dist - dist) / max_dist",
Expand Down

0 comments on commit a439764

Please sign in to comment.