Skip to content

Commit

Permalink
Make sure single-pixel reads in the MODIS sinusoidal projection work.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595889355
  • Loading branch information
Xee authors committed Jan 5, 2024
1 parent 7bb1407 commit aa9114c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,12 @@ def get_variables(self) -> utils.Frozen[str, xarray.Variable]:
width_coord = np.squeeze(lon)
height_coord = np.squeeze(lat)

# Make sure there's at least a single point in each dimension.
if width_coord.ndim == 0:
width_coord = width_coord[None, ...]
if height_coord.ndim == 0:
height_coord = height_coord[None, ...]

x_dim_name, y_dim_name = self.dimension_names

coords = [
Expand Down Expand Up @@ -687,8 +693,9 @@ def __init__(self, variable_name: str, ee_store: EarthEngineStore):

x_min, y_min, x_max, y_max = self.bounds

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)))
# Make sure the size is at least 1x1.
x_size = max(1, int(np.round((x_max - x_min) / np.abs(self.store.scale_x))))
y_size = max(1, 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()}
Expand Down

0 comments on commit aa9114c

Please sign in to comment.