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

Make sure single-pixel reads in the MODIS sinusoidal projection work. #120

Merged
1 commit merged into from
Jan 5, 2024
Merged
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
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
Loading