From a6e79452bf5a14c2fd2f09c3234f479b2e72e1dd Mon Sep 17 00:00:00 2001 From: dabhicusp Date: Wed, 22 Nov 2023 07:09:20 +0000 Subject: [PATCH 1/5] small data resolved between Xee and computePixels. --- README.md | 11 +++++++++++ xee/ext.py | 5 ++--- xee/ext_integration_test.py | 15 ++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4aef1cd..a776070 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,17 @@ ds = xarray.open_dataset( ) ``` +```python +ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31') +leg1 = ee.Geometry.BBox(113.33, -43.63, 153.56, -10.66) +ds = xarray.open_dataset( + ic, + engine='ee', + projection=ic.first().select(0).projection(), + geometry=leg1 +) +``` + Open multiple ImageCollections into one `xarray.Dataset`, all with the same projection: ```python diff --git a/xee/ext.py b/xee/ext.py index 03e9ed9..67f14e3 100644 --- a/xee/ext.py +++ b/xee/ext.py @@ -637,9 +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()} if isinstance(self.store.chunks, dict): diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index e340f52..753914f 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== r"""Integration tests for the Google Earth Engine backend for Xarray.""" +import io import json import os import pathlib @@ -43,8 +44,8 @@ def _read_identity_pool_creds() -> identity_pool.Credentials: def init_ee_for_tests(): ee.Initialize( - credentials=_read_identity_pool_creds(), - opt_url=ee.data.HIGH_VOLUME_API_BASE_URL, + # credentials=_read_identity_pool_creds(), + # opt_url=ee.data.HIGH_VOLUME_API_BASE_URL, ) @@ -281,7 +282,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 +291,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 +331,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 +358,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`. From c18554605ba68cb4fde87b802c57bf3375556312 Mon Sep 17 00:00:00 2001 From: dabhicusp Date: Wed, 22 Nov 2023 07:10:51 +0000 Subject: [PATCH 2/5] nit changes done. --- xee/ext_integration_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 753914f..025fcc6 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -44,8 +44,8 @@ def _read_identity_pool_creds() -> identity_pool.Credentials: def init_ee_for_tests(): ee.Initialize( - # credentials=_read_identity_pool_creds(), - # opt_url=ee.data.HIGH_VOLUME_API_BASE_URL, + credentials=_read_identity_pool_creds(), + opt_url=ee.data.HIGH_VOLUME_API_BASE_URL, ) From fe5517a5f4f78a1dd5b911fc7c274c81868dcfc5 Mon Sep 17 00:00:00 2001 From: dabhicusp Date: Wed, 22 Nov 2023 07:11:24 +0000 Subject: [PATCH 3/5] nit change. --- xee/ext_integration_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 025fcc6..56ec56d 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -13,7 +13,7 @@ # limitations under the License. # ============================================================================== r"""Integration tests for the Google Earth Engine backend for Xarray.""" -import io + import json import os import pathlib From ffc281706ce53be7fb17e4d44b3a557e2b6194c4 Mon Sep 17 00:00:00 2001 From: dabhicusp Date: Wed, 22 Nov 2023 07:11:42 +0000 Subject: [PATCH 4/5] nit chnages-1. --- xee/ext_integration_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 56ec56d..e727465 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -13,7 +13,6 @@ # limitations under the License. # ============================================================================== r"""Integration tests for the Google Earth Engine backend for Xarray.""" - import json import os import pathlib From 7bd0f5c76c125350ee397881c723a33cedd77218 Mon Sep 17 00:00:00 2001 From: dabhicusp Date: Wed, 22 Nov 2023 07:30:48 +0000 Subject: [PATCH 5/5] nit changes done. --- README.md | 11 ----------- xee/ext.py | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index a776070..4aef1cd 100644 --- a/README.md +++ b/README.md @@ -76,17 +76,6 @@ ds = xarray.open_dataset( ) ``` -```python -ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31') -leg1 = ee.Geometry.BBox(113.33, -43.63, 153.56, -10.66) -ds = xarray.open_dataset( - ic, - engine='ee', - projection=ic.first().select(0).projection(), - geometry=leg1 -) -``` - Open multiple ImageCollections into one `xarray.Dataset`, all with the same projection: ```python diff --git a/xee/ext.py b/xee/ext.py index 67f14e3..c3f4fc0 100644 --- a/xee/ext.py +++ b/xee/ext.py @@ -639,6 +639,7 @@ def __init__(self, variable_name: str, ee_store: EarthEngineStore): 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()} if isinstance(self.store.chunks, dict):