Skip to content

Commit 3c5d5b5

Browse files
committed
Add fix nan
1 parent bab679f commit 3c5d5b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

atlite/convert.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,10 @@ def hydro(
805805

806806
matrix = cutout.indicatormatrix(basins.shapes)
807807
# compute the average surface runoff in each basin
808-
matrix_normalized = matrix / matrix.sum(axis=1)
808+
# Fix NaN and Inf values to 0.0 to avoid numerical issues
809+
matrix_normalized = np.nan_to_num(
810+
matrix / matrix.sum(axis=1), nan=0.0, posinf=0.0, neginf=0.0
811+
)
809812
runoff = cutout.runoff(
810813
matrix=matrix_normalized,
811814
index=basins.shapes.index,

0 commit comments

Comments
 (0)