Skip to content

Commit ece1a88

Browse files
authored
feat: Allow masking from numpy (#254)
## Description Allow masking from numpy ***As a contributor to the Anemoi framework, please ensure that your changes include unit tests, updates to any affected dependencies and documentation, and have been tested in a parallel setting (i.e., with multiple GPUs). As a reviewer, you are also responsible for verifying these aspects and requesting changes if they are not adequately addressed. For guidelines about those please refer to https://anemoi.readthedocs.io/en/latest/*** By opening this pull request, I affirm that all authors agree to the [Contributor License Agreement.](https://github.com/ecmwf/codex/blob/main/Legal/contributor_license_agreement.md)
1 parent 36f59da commit ece1a88

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/anemoi/transform/filters/fields/apply_mask.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ def prepare_filter(self):
107107
New name for the masked variable, by default None.
108108
"""
109109

110-
mask = ekd.from_source("file", self.path)[0].to_numpy(flatten=True)
110+
if self.path.endswith(".npy"):
111+
mask = np.load(self.path)
112+
else:
113+
mask = ekd.from_source("file", self.path)[0].to_numpy(flatten=True)
111114

112115
if self.mask_value is None and self.threshold is None:
113116
raise ValueError("Either `mask_value` or `threshold` must be provided.")

0 commit comments

Comments
 (0)