Skip to content

Commit 5ed3ca2

Browse files
authored
Merge pull request #51 from earthdaily/dev
v0.0.10
2 parents 87e4f85 + 0af3e1b commit 5ed3ca2

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

examples/multisensors_cube.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# See the NDVI evolution
6161
# -------------------------------------------
6262

63-
datacube["NDVI"].ed.plot_index(col_wrap=3, vmin=0, vmax=0.8, cmap="Greens")
63+
datacube["NDVI"].ed.plot_band(col_wrap=3, vmin=0, vmax=0.8, cmap="Greens")
6464
plt.show()
6565

6666
##############################################################################

tests/test_zonalstats.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,31 @@ def setUp(self, constant=np.random.randint(1, 12)):
2727
"time": times,
2828
},
2929
).rio.write_crs("EPSG:4326")
30-
30+
ds = ds.transpose('time','x','y')
3131
# first pixel
3232
geometry = [
33-
Polygon([(0, 0), (0, 0.8), (0.8, 0.8), (0.8, 0)]),
34-
Polygon([(1, 1), (9, 1), (9, 2.1), (1, 1)]),
33+
Polygon([(0, 0), (0, 1.2), (1.2, 1.2), (1.2, 0)]),
34+
Polygon([(1, 1), (9, 1), (9, 2.1), (1, 1)])
3535
]
3636
# out of bound geom # Polygon([(10,10), (10,11), (11,11), (11,10)])]
3737
gdf = gpd.GeoDataFrame({"geometry": geometry}, crs="EPSG:4326")
3838
self.gdf = gdf
3939
self.datacube = ds
4040

41-
def test_numpy(self):
42-
zonalstats = earthdaily.earthdatastore.cube_utils.zonal_stats_numpy(
43-
self.datacube,
44-
self.gdf,
45-
all_touched=True,
46-
operations=dict(
47-
mean=np.nanmean, max=np.nanmax, min=np.nanmin, mode=np.mode
48-
),
49-
)
50-
51-
for operation in ["min", "max", "mode"]:
52-
self._check_results(
53-
zonalstats["first_var"].sel(stats=operation).values, operation=operation
54-
)
5541

5642
def test_basic(self):
5743
zonalstats = earthdaily.earthdatastore.cube_utils.zonal_stats(
58-
self.datacube, self.gdf, all_touched=True, operations=["min", "max", "mode"]
44+
self.datacube, self.gdf, all_touched=True, operations=["min", "max"]
5945
)
60-
for operation in ["min", "max", "mode"]:
46+
for operation in ["min", "max"]:
6147
self._check_results(
6248
zonalstats["first_var"].sel(stats=operation).values, operation=operation
6349
)
6450

6551
def _check_results(self, stats_values, operation="min"):
6652
results = {
67-
"min": np.asarray([[0, self.constant], [9, self.constant]]),
68-
"max": np.asarray([[8, self.constant], [23, self.constant]]),
69-
"mode": np.asarray([[0, self.constant], [9, self.constant]]),
53+
"min": np.asarray([[1, self.constant], [10, self.constant]]),
54+
"max": np.asarray([[9, self.constant], [15, self.constant]])
7055
}
7156
self.assertTrue(np.all(stats_values == results[operation]))
7257

0 commit comments

Comments
 (0)