Skip to content

Commit 3541a1f

Browse files
fix: ensure missing value indicator in not a valid value in accumulat… (#316)
…ions ## Description <!-- Provide a brief summary of the changes introduced in this pull request. --> ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update ## Issue Number <!-- Link the Issue number this change addresses, ideally in one of the "magic format" such as Closes #XYZ --> <!-- Alternatively, explain the motivation behind the changes and the context in which they are being made. --> ## Code Compatibility - [ ] I have performed a self-review of my code ### Code Performance and Testing - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I ran the [complete Pytest test](https://anemoi.readthedocs.io/projects/training/en/latest/dev/testing.html) suite locally, and they pass <!-- In case this affects the model sharding or other specific components please describe these here. --> ### Dependencies - [ ] I have ensured that the code is still pip-installable after the changes and runs - [ ] I have tested that new dependencies themselves are pip-installable. <!-- List any new dependencies that are required for this change and the justification to add them. --> ### Documentation - [ ] My code follows the style guidelines of this project - [ ] I have updated the documentation and docstrings to reflect the changes - [ ] I have added comments to my code, particularly in hard-to-understand areas <!-- Describe any major updates to the documentation --> ## Additional Notes <!-- Include any additional information, caveats, or considerations that the reviewer should be aware of. --> Co-authored-by: Aaron Hopkinson <aaron.hopkinson@ecmwf.int>
1 parent 9a5ba3b commit 3541a1f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/anemoi/datasets/create/sources/accumulations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .mars import mars
2727

2828
LOG = logging.getLogger(__name__)
29+
MISSING_VALUE = 1e-38
2930

3031

3132
def _member(field: Any) -> int:
@@ -168,6 +169,7 @@ def write(self, template: Any) -> None:
168169
# are used to store the end step
169170

170171
edition = template.metadata("edition")
172+
assert np.all(self.values != MISSING_VALUE)
171173

172174
if edition == 1 and self.endStep > 254:
173175
self.out.write(
@@ -176,6 +178,7 @@ def write(self, template: Any) -> None:
176178
stepType="instant",
177179
step=self.endStep,
178180
check_nans=True,
181+
missing_value=MISSING_VALUE,
179182
)
180183
else:
181184
self.out.write(
@@ -185,6 +188,7 @@ def write(self, template: Any) -> None:
185188
startStep=self.startStep,
186189
endStep=self.endStep,
187190
check_nans=True,
191+
missing_value=MISSING_VALUE,
188192
)
189193
self.values = None
190194
self.done = True
@@ -205,9 +209,6 @@ def add(self, field: Any, values: NDArray[Any]) -> None:
205209
if step not in self.steps:
206210
return
207211

208-
if not np.all(values >= 0):
209-
warnings.warn(f"Negative values for {field}: {np.nanmin(values)} {np.nanmax(values)}")
210-
211212
assert not self.done, (self.key, step)
212213
assert step not in self.seen, (self.key, step)
213214

0 commit comments

Comments
 (0)