Skip to content

Commit

Permalink
r.vif.py: add error message
Browse files Browse the repository at this point in the history
The error message given when one of the input layers has no values (within the computational region) does not help to understand the problem. Added an error message to suggest the possible cause of the error.
  • Loading branch information
ecodiv committed Sep 16, 2023
1 parent e79e599 commit 671b83d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/raster/r.vif/r.vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@


# Functions
def prRed(skk): print("\033[91m {}\033[00m" .format(skk))


CLEAN_RAST = []


Expand Down Expand Up @@ -348,7 +351,12 @@ def main(options, flags):
vifstat = compute_vif2(x, y)
else:
# Compute vif using sample
y = p[:, k]
try:
y = p[:, k]
except Exception as e:
prRed(f"An exception occurred: {str(e)}")
prRed("Tip: check if all input rasters have values"
" within the computation region.")
x = np.delete(p, k, axis=1)
vifstat = compute_vif(x, y)

Expand Down

0 comments on commit 671b83d

Please sign in to comment.