Skip to content

The calculate_slope function should return -np.inf for the slope #1

@RGarcia-1

Description

@RGarcia-1

In the current implementation of calculate_slope()
https://github.com/fema-ffrd/overflow/blob/main/src/overflow/_flow_direction/flow_direction.py#L93C1-L94C22

    if dem[row + dy, col + dx] == nodata_value or np.isnan(dem[row + dy, col + dx]):
        return np.inf

This value is used inside flow_direction_for_tile():

                    slope = calculate_slope(dem, row, col, dy, dx, nodata_value)
                    if slope > max_slope:
                        max_slope = slope
                        max_index = i
                    if slope > 0:
                        all_non_positive = False

Because max_slope is initialised to -np.inf:

max_slope = -np.inf

Implies that any np.inf returned from calculate_slope() always becomes the maximum slope. Just checking that the calculate_slope should return -np.inf?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions