Skip to content

Commit 596bd53

Browse files
Merge pull request #31 from gregory-halverson/main
making `check_distribution` compatible with `numpy` arrays
2 parents 20a8c8b + 4af8ad0 commit 596bd53

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

breathing_earth_system_simulator/check_distribution.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BlankOutputError(Exception):
1111
pass
1212

1313
def check_distribution(
14-
image: Raster,
14+
image: Union[Raster, np.ndarray],
1515
variable: str,
1616
date_UTC: Union[date, str],
1717
target: str = None):
@@ -55,13 +55,18 @@ def check_distribution(
5555
else:
5656
nan_proportion_string = cl.val(f"{(nan_proportion * 100):0.2f}%")
5757

58+
if isinstance(image, Raster):
59+
nan_value = image.nodata
60+
else:
61+
nan_value = np.nan
62+
5863
message = "variable " + cl.name(variable) + \
5964
" on " + cl.time(f"{date_UTC:%Y-%m-%d}") + \
6065
target_message + \
6166
" min: " + minimum_string + \
6267
" mean: " + cl.val(f"{np.nanmean(image):0.3f}") + \
6368
" max: " + maximum_string + \
64-
" nan: " + nan_proportion_string + f" ({cl.val(image.nodata)})"
69+
" nan: " + nan_proportion_string + f" ({cl.val(nan_value)})"
6570

6671
if np.all(image == 0):
6772
message += " all zeros"
@@ -70,4 +75,4 @@ def check_distribution(
7075
logger.info(message)
7176

7277
if nan_proportion == 1:
73-
raise BlankOutputError(f"variable {variable} on {date_UTC:%Y-%m-%d}{target_message} is a blank image")
78+
raise BlankOutputError(f"variable {variable} on {date_UTC:%Y-%m-%d}{target_message} is a blank image")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.1
1+
1.5.2

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=60", "setuptools-scm>=8.0", "wheel"]
33

44
[project]
55
name = "breathing-earth-system-simulator"
6-
version = "1.5.1"
6+
version = "1.5.2"
77
description = "Breathing Earth System Simulator (BESS) Gross Primary Production (GPP) and Evapotranspiration (ET) Model Python"
88
readme = "README.md"
99
authors = [

0 commit comments

Comments
 (0)