Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed small data discrepancy between Xee and pure computePixels(). #105

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did Sai’s modulus trick not work?

I have an internal only test where we want to substitute Xee for computePixels. Does that test pass with this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @shoyer would be good to consult, too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No @alxmrs sai's modulus trick is not working on all the images.
And Yes, that internal test was passed with this change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this sounds good to me!


self.shape = (ee_store.n_images, x_size, y_size)
self._apparent_chunks = {k: 1 for k in self.store.PREFERRED_CHUNKS.keys()}
Expand Down
10 changes: 5 additions & 5 deletions xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand All @@ -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`.
Expand Down