diff --git a/xee/ext.py b/xee/ext.py index cdc2dfe..56648f0 100644 --- a/xee/ext.py +++ b/xee/ext.py @@ -637,8 +637,8 @@ def __init__(self, variable_name: str, ee_store: EarthEngineStore): x_min, y_min, x_max, y_max = self.bounds - x_size = int(np.ceil((x_max - x_min) / np.abs(self.store.scale_x))) - y_size = int(np.ceil((y_max - y_min) / np.abs(self.store.scale_y))) + x_size = int(np.round((x_max - x_min) / np.abs(self.store.scale_x))) + y_size = int(np.round((y_max - y_min) / np.abs(self.store.scale_y))) self.shape = (ee_store.n_images, x_size, y_size) self._apparent_chunks = {k: 1 for k in self.store.PREFERRED_CHUNKS.keys()} diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index e340f52..e727465 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -281,7 +281,7 @@ def test_open_dataset__sanity_check(self): scale=25.0, # in degrees n_images=3, ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 15, 'lat': 8}) + self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) self.assertNotEmpty(dict(ds.coords)) self.assertEqual( list(ds.data_vars.keys()), @@ -290,7 +290,7 @@ def test_open_dataset__sanity_check(self): for v in ds.values(): self.assertIsNotNone(v.data) self.assertFalse(v.isnull().all(), 'All values are null!') - self.assertEqual(v.shape, (3, 15, 8)) + self.assertEqual(v.shape, (3, 14, 7)) def test_open_dataset__n_images(self): ds = self.entry.open_dataset( @@ -330,7 +330,7 @@ def test_honors_geometry(self): engine=xee.EarthEngineBackendEntrypoint, ) - self.assertEqual(ds.dims, {'time': 4248, 'lon': 41, 'lat': 35}) + self.assertEqual(ds.dims, {'time': 4248, 'lon': 40, 'lat': 35}) self.assertNotEqual(ds.dims, standard_ds.dims) def test_honors_projection(self): @@ -357,14 +357,14 @@ def test_parses_ee_url(self): scale=25.0, # in degrees n_images=3, ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 15, 'lat': 8}) + self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) ds = self.entry.open_dataset( 'ee:LANDSAT/LC08/C01/T1', drop_variables=tuple(f'B{i}' for i in range(3, 12)), scale=25.0, # in degrees n_images=3, ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 15, 'lat': 8}) + self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) def test_data_sanity_check(self): # This simple test uncovered a bug with the default definition of `scale`.