Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
mask indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Mar 13, 2024
1 parent b9dafbc commit 5b7b2de
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ecml_tools/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,26 @@ def longitudes(self):

@debug_indexing
def __getitem__(self, index):
if isinstance(index, tuple):
return self._get_tuple(index)

result = self.forward[index]
print(index, result.shape)
# We don't support subsetting the grid values
assert result.shape[-1] == len(self.mask), (result.shape, len(self.mask))

return result[..., self.mask]

@debug_indexing
@expand_list_indexing
def _get_tuple(self, index):
index, changes = index_to_slices(index, self.shape)
index, previous = update_tuple(index, self.axis, slice(None))
result = self.forward[index]
result = result[..., self.mask]
result = result[..., previous]
result = apply_index_to_slices_changes(result, changes)
return result


class Thinning(Masked):

Expand Down

0 comments on commit 5b7b2de

Please sign in to comment.