diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ccd33a..f8179bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Make checks on max spatial resolution (1km) more lenient using math.isclose [\#30](https://github.com/mlcast-community/mlcast-dataset-validator/pull/30), @ladc - Detect Zarr v3 format from store files (`zarr.json`) instead of relying on `getattr(ds, "zarr_format", 2)` which always defaulted to v2, causing v3 stores to incorrectly fail the consolidated metadata check [\#27](https://github.com/mlcast-community/mlcast-dataset-validator/pull/27), @franchg ## [v0.2.0](https://github.com/mlcast-community/mlcast-dataset-validator/releases/tag/v0.2.0) diff --git a/mlcast_dataset_validator/checks/coords/spatial.py b/mlcast_dataset_validator/checks/coords/spatial.py index 9abbede..cd2b2d5 100644 --- a/mlcast_dataset_validator/checks/coords/spatial.py +++ b/mlcast_dataset_validator/checks/coords/spatial.py @@ -1,3 +1,5 @@ +import math + import xarray as xr from ...specs.reporting import ValidationReport, log_function_call @@ -35,9 +37,13 @@ def check_spatial_requirements( if len(x_vals) > 1 and len(y_vals) > 1: x_res = abs(float(x_vals[1] - x_vals[0])) y_res = abs(float(y_vals[1] - y_vals[0])) + max_resolution_m = max_resolution_km * 1000 if ( - x_res <= max_resolution_km * 1000 - and y_res <= max_resolution_km * 1000 + x_res <= max_resolution_m + or math.isclose(x_res, max_resolution_m, rel_tol=1e-6) + ) and ( + y_res <= max_resolution_m + or math.isclose(y_res, max_resolution_m, rel_tol=1e-6) ): report.add( SECTION_ID,