From a9bc9bd807746bc40a32eed8adc1007f1f8447f0 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Fri, 8 Nov 2024 14:39:18 -0800 Subject: [PATCH 1/5] Set git config for working with Pixi --- .gitattributes | 2 ++ .gitignore | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07fe41c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# GitHub syntax highlighting +pixi.lock linguist-language=YAML linguist-generated=true diff --git a/.gitignore b/.gitignore index 53e359e..83c6ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,6 @@ cython_debug/ # MacOS .DS_Store + +# pixi environments +.pixi From 87e67e1665827a253c209408f0974c400c5b9fa7 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Fri, 8 Nov 2024 16:07:09 -0800 Subject: [PATCH 2/5] Fix integration test warnings re: Dataset.dims --- xee/ext_integration_test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 16d4d6c..032442c 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -341,7 +341,7 @@ def test_open_dataset__sanity_check(self): n_images=3, projection=ee.Projection('EPSG:4326', [25, 0, 0, 0, -25, 0]), ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) + self.assertEqual(dict(ds.sizes), {'time': 3, 'lon': 14, 'lat': 7}) self.assertNotEmpty(dict(ds.coords)) self.assertEqual( list(ds.data_vars.keys()), @@ -360,7 +360,7 @@ def test_open_dataset__sanity_check_with_negative_scale(self): scale=-25.0, # in degrees n_images=3, ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) + self.assertEqual(dict(ds.sizes), {'time': 3, 'lon': 14, 'lat': 7}) self.assertNotEmpty(dict(ds.coords)) self.assertEqual( list(ds.data_vars.keys()), @@ -410,8 +410,8 @@ def test_honors_geometry(self): engine=xee.EarthEngineBackendEntrypoint, ) - self.assertEqual(ds.dims, {'time': 4248, 'lon': 40, 'lat': 35}) - self.assertNotEqual(ds.dims, standard_ds.dims) + self.assertEqual(ds.sizes, {'time': 4248, 'lon': 40, 'lat': 35}) + self.assertNotEqual(ds.sizes, standard_ds.sizes) def test_honors_projection(self): ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate( @@ -427,8 +427,8 @@ def test_honors_projection(self): engine=xee.EarthEngineBackendEntrypoint, ) - self.assertEqual(ds.dims, {'time': 4248, 'lon': 3600, 'lat': 1800}) - self.assertNotEqual(ds.dims, standard_ds.dims) + self.assertEqual(ds.sizes, {'time': 4248, 'lon': 3600, 'lat': 1800}) + self.assertNotEqual(ds.sizes, standard_ds.sizes) @absltest.skipIf(_SKIP_RASTERIO_TESTS, 'rioxarray module not loaded') def test_expected_precise_transform(self): @@ -476,14 +476,14 @@ def test_parses_ee_url(self): scale=25.0, # in degrees n_images=3, ) - self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 14, 'lat': 7}) + self.assertEqual(dict(ds.sizes), {'time': 3, 'lon': 14, 'lat': 7}) ds = self.entry.open_dataset( 'ee:LANDSAT/LC08/C02/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': 14, 'lat': 7}) + self.assertEqual(dict(ds.sizes), {'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 eae60714e8c5ef68424242b468a9199d8a3866d9 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Fri, 8 Nov 2024 16:29:30 -0800 Subject: [PATCH 3/5] Updated deprecated dataset with new version --- 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 032442c..929ad3c 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -384,7 +384,7 @@ def test_open_dataset__n_images(self): def test_can_chunk__opened_dataset(self): ds = xr.open_dataset( - 'NASA/GPM_L3/IMERG_V06', + 'NASA/GPM_L3/IMERG_V07', crs='EPSG:4326', scale=0.25, engine=xee.EarthEngineBackendEntrypoint, From 970d19fa3f0c9a4159c60ca6332833dec817d5f7 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Fri, 15 Nov 2024 16:46:02 -0800 Subject: [PATCH 4/5] Add ability to open ee.Image objects --- xee/ext.py | 11 ++++++----- xee/ext_integration_test.py | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/xee/ext.py b/xee/ext.py index 2bcd523..763fe84 100644 --- a/xee/ext.py +++ b/xee/ext.py @@ -1122,11 +1122,12 @@ def open_dataset( if ee.data.getUserAgent() != user_agent: ee.data.setUserAgent(user_agent) - collection = ( - filename_or_obj - if isinstance(filename_or_obj, ee.ImageCollection) - else ee.ImageCollection(self._parse(filename_or_obj)) - ) + if isinstance(filename_or_obj, ee.ImageCollection): + collection = filename_or_obj + elif isinstance(filename_or_obj, ee.Image): + collection = ee.ImageCollection(filename_or_obj) + else: + collection = ee.ImageCollection(self._parse(filename_or_obj)) store = EarthEngineStore.open( collection, diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 929ad3c..a62a79b 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -382,6 +382,14 @@ def test_open_dataset__n_images(self): self.assertLen(ds.time, 1) + def test_open_dataset_image_to_imagecollection(self): + """Ensure that opening a ee.Image is the same as opening a single image ee.ImageCollection""" + img = ee.Image('CGIAR/SRTM90_V4') + ic = ee.ImageCollection(img) + ds1 = xr.open_dataset(img, engine='ee') + ds2 = xr.open_dataset(ic, engine='ee') + self.assertTrue(ds1.identical(ds2)) + def test_can_chunk__opened_dataset(self): ds = xr.open_dataset( 'NASA/GPM_L3/IMERG_V07', From 5182b8847086d64232e347a5b659ef56eb6d17e6 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Mon, 18 Nov 2024 10:47:16 -0800 Subject: [PATCH 5/5] End docstring with punctuation --- 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 a62a79b..8ea37aa 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -383,7 +383,7 @@ def test_open_dataset__n_images(self): self.assertLen(ds.time, 1) def test_open_dataset_image_to_imagecollection(self): - """Ensure that opening a ee.Image is the same as opening a single image ee.ImageCollection""" + """Ensure that opening an ee.Image is the same as opening a single image ee.ImageCollection.""" img = ee.Image('CGIAR/SRTM90_V4') ic = ee.ImageCollection(img) ds1 = xr.open_dataset(img, engine='ee')