Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix differences between stackstack and odc (due to nodata)
  • Loading branch information
nicolasK committed Dec 30, 2024
1 parent a55e396 commit 42819a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion odc/stac/bench/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ def compute_args(self, method: str = "") -> Dict[str, Any]:
extra.setdefault("dtype", "uint16")
extra.setdefault("fill_value", 0)
extra.setdefault("xy_coords", "center")

extra.setdefault("rescale", False)

return _trim_dict(
{
"chunksize": self.chunks[0],
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ planetary-computer
pylint
isort
pytest
pandas-stubs
18 changes: 9 additions & 9 deletions tests/test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
CFG = {
"*": {
"warnings": "ignore",
# for every asset in every product default to uint16 with nodata=0
"assets": {"*": {"data_type": "uint16", "nodata": 0}},
# for every asset in every product default to int64 with nodata=0
"assets": {"*": {"data_type": "int64", "nodata": 0}},
}
}

Expand Down Expand Up @@ -107,13 +107,13 @@ def test_load_from_json_stackstac(fake_dask_client, bench_site1, bench_site2):
resampling="nearest",
extra={
"odc-stac": {"groupby": "solar_day", "stac_cfg": CFG},
"stackstac": {"dtype": "uint16", "fill_value": 0},
"stackstac": {"dtype": "int64", "fill_value": 0},
},
)
xx = load_from_json(bench_site1, params)
assert "band" in xx.dims
assert xx.shape == (1, 3, 90978, 10980)
assert xx.dtype == "uint16"
assert xx.dtype == "int64"
assert xx.spec.epsg == 32735

yy = load_from_json(
Expand All @@ -127,13 +127,13 @@ def test_load_from_json_stackstac(fake_dask_client, bench_site1, bench_site2):

xx = load_from_json(bench_site2, params)
assert "band" in xx.dims
assert xx.dtype == "uint16"
assert xx.dtype == "int64"
assert xx.spec.epsg == 32735

params.crs = "epsg:32736"
xx = load_from_json(bench_site2, params)
assert "band" in xx.dims
assert xx.dtype == "uint16"
assert xx.dtype == "int64"
assert xx.spec.epsg == 32736

with pytest.raises(ValueError):
Expand Down Expand Up @@ -166,14 +166,14 @@ def test_bench_context(fake_dask_client, bench_site1, bench_site2):

header_txt = rr.render_txt()
assert "T.slice : 2020-06-06" in header_txt
assert f"Data : 1.3.{ny}.{nx}.uint16, 5.58 GiB" in header_txt
assert f"Data : 1.3.{ny}.{nx}.int64, 22.33 GiB" in header_txt

run_txt = rr.render_timing_info((0, 0.1, 30))
assert isinstance(run_txt, str)

pd_dict = rr.to_pandas_dict()
assert pd_dict["resolution"] == rr.resolution
assert pd_dict["data"] == f"1.3.{ny}.{nx}.uint16"
assert pd_dict["data"] == f"1.3.{ny}.{nx}.int64"
assert pd_dict["chunks_x"] == 2048
assert pd_dict["chunks_y"] == 2048

Expand Down Expand Up @@ -290,4 +290,4 @@ def test_bench_params_json():

# function should round-trip too
params.patch_url = load_from_json
assert params == BenchLoadParams.from_json(params.to_json())
assert params == BenchLoadParams.from_json(params.to_json())

0 comments on commit 42819a6

Please sign in to comment.