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(). #90

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def __init__(
# TODO(#40): Investigate data discrepancy (off-by-one) issue.
x_min, y_min = self.transform(x_min_0, y_min_0)
x_max, y_max = self.transform(x_max_0, y_max_0)

x_min = x_min - x_min % self.scale_x
y_max = y_max - y_max % self.scale_y
self.bounds = x_min, y_min, x_max, y_max

max_dtype = self._max_itemsize()
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 @@ -261,7 +261,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': 16, 'lat': 8})
self.assertNotEmpty(dict(ds.coords))
self.assertEqual(
list(ds.data_vars.keys()),
Expand All @@ -270,7 +270,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, 16, 8))

def test_open_dataset__n_images(self):
ds = self.entry.open_dataset(
Expand Down Expand Up @@ -310,7 +310,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': 41, 'lat': 36})
self.assertNotEqual(ds.dims, standard_ds.dims)

def test_honors_projection(self):
Expand All @@ -337,14 +337,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': 7})
self.assertEqual(dict(ds.dims), {'time': 3, 'lon': 16, 'lat': 8})
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': 16, 'lat': 8})

def test_data_sanity_check(self):
# This simple test uncovered a bug with the default definition of `scale`.
Expand Down