|
14 | 14 | from eopf_geozarr.s2_optimization.s2_multiscale import ( |
15 | 15 | calculate_aligned_chunk_size, |
16 | 16 | calculate_simple_shard_dimensions, |
| 17 | + create_downsampled_resolution_group, |
17 | 18 | create_measurements_encoding, |
18 | 19 | create_multiscale_from_datatree, |
19 | 20 | ) |
@@ -54,6 +55,24 @@ def sample_dataset() -> xr.Dataset: |
54 | 55 | class TestS2MultiscaleFunctions: |
55 | 56 | """Test suite for S2 multiscale functions.""" |
56 | 57 |
|
| 58 | + def test_create_downsampled_resolution_group_quality_mask(self) -> None: |
| 59 | + """Quality-mask downsampling should not crash and should preserve dtype.""" |
| 60 | + x = np.arange(8) |
| 61 | + y = np.arange(6) |
| 62 | + quality = xr.DataArray( |
| 63 | + np.random.randint(0, 2, (6, 8), dtype=np.uint8), |
| 64 | + dims=["y", "x"], |
| 65 | + coords={"y": y, "x": x}, |
| 66 | + name="quality_clouds", |
| 67 | + ) |
| 68 | + ds = xr.Dataset({"quality_clouds": quality}) |
| 69 | + |
| 70 | + out = create_downsampled_resolution_group(ds, factor=2) |
| 71 | + |
| 72 | + assert "quality_clouds" in out.data_vars |
| 73 | + assert out["quality_clouds"].dtype == np.uint8 |
| 74 | + assert out["quality_clouds"].shape == (3, 4) |
| 75 | + |
57 | 76 | def test_calculate_simple_shard_dimensions(self) -> None: |
58 | 77 | """Test simplified shard dimensions calculation.""" |
59 | 78 | # Test 3D data (time, y, x) - shards are multiples of chunks |
|
0 commit comments