Skip to content

Conversation

@griembauer
Copy link
Contributor

@griembauer griembauer commented Aug 9, 2024

Running i.sentinel.mask, I encountered

Traceback (most recent call last):
  File "/home/griembauer/.grass8/addons/scripts/i.sentinel.mask", line 780, in <module>
    main()
  File "/home/griembauer/.grass8/addons/scripts/i.sentinel.mask", line 708, in main
    compute_shadow_shift(clouds, dark_pixels, sun_zenith, sun_azimuth)
  File "/home/griembauer/.grass8/addons/scripts/i.sentinel.mask", line 438, in compute_shadow_shift
    get_overlap(TMP_NAME, dark_pixel_map, map_region, new_region)
  File "/home/griembauer/.grass8/addons/scripts/i.sentinel.mask", line 361, in get_overlap
    gs.read_command(
IndexError: list index out of range

which corresponds to

    # measure overlap
    overlap = int(
        gs.read_command(
            "r.stats",
            quiet=True,
            flags="cn",
            input=f"{clouds},{dark_pixels}",
            separator=",",
        )
        .strip()
        .split(",")[2]    <---------
        .strip()
    )

Tested:

(Pdb) gs.read_command("r.stats",quiet=True, flags="cn",input=f"{clouds},{dark_pixels}",separator=",",)
 100%
''

I assume this occurs when the maps clouds and dark_pixels don't have any overlap. They contain only the values NoData and 0, so due to the -nflag, r.stats does not give any information on category combinations if the only occuring category combinations contain at least one NoData.

This PR fixes this issue, but I am not sure if this is consistent with the remaining logic of the module

@griembauer griembauer requested a review from ninsbl August 9, 2024 06:43
@neteler neteler added the bug Something isn't working label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants