Skip to content

Nan values propagates in sky illumination function #38

@Thibalt-C

Description

@Thibalt-C

I noticed that the rvt.vis.sky_illumination function was not taking well into account the np.nan values no matter which argument of no_data is chosen. This looks to be because np.maximum which is used in the function is propagating NaN values. np.fmax can be substituted to avoid this issue.

Here is the concerned part if it helps:

    for i_dir, direction in enumerate(pyramid[0]["shift"]):
        dir_rad = np.radians(direction)
        # reset maximum at each iteration (direction)
        max_slope = np.zeros(pyramid[n_levels]["dem"].shape, dtype=np.float32) - 1000

        for i_level in reversed(range(n_levels + 1)):
            height = pyramid[i_level]["dem"]
            move = pyramid[i_level]["shift"]

            # ... and to the search radius
            for i_rad, radius in enumerate(move[direction]["distance"]):
                # get shift index from move dictionary
                shift_indx = move[direction]["shift"][i_rad]
                # estimate the slope
                _ = np.maximum((np.roll(height, shift_indx, axis=(0, 1)) - height) / radius, 0.) # <----- replace with np.fmax 
                # compare to the previous max slope and keep the larges
                max_slope = np.maximum(max_slope, _) # <----- replace with np.fmax 

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