Skip to content

Commit

Permalink
feat: add percentile valid points in
Browse files Browse the repository at this point in the history
  • Loading branch information
vschaffn committed Jan 24, 2025
1 parent 514ea82 commit 2b4958b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,7 @@ def _statistics(self, band: int = 1) -> dict[str, np.floating[Any]]:
"NMAD": nmad(data),
"RMSE": np.sqrt(np.nanmean(np.square(data - np.nanmean(data)))),
"Standard deviation": np.nanstd(data),
"Percentile valid points": (np.count_nonzero(~np.isnan(data)) / data.size) * 100,
}
return stats_dict

Expand Down Expand Up @@ -1986,6 +1987,8 @@ def get_stats(
"stddev": "Standard deviation",
"standarddev": "Standard deviation",
"standarddeviation": "Standard deviation",
"percentvalidpoint": "Percentile valid point",
"validpoint": "Percentile valid point",
}
if isinstance(stats_name, list):
result = {}
Expand Down
1 change: 1 addition & 0 deletions tests/test_raster/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ def test_stats(self, example: str, caplog) -> None:
"NMAD",
"RMSE",
"Standard deviation",
"Percentile valid points",
]
for name in expected_stats:
assert name in stats
Expand Down

0 comments on commit 2b4958b

Please sign in to comment.