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

Fix division-by-zero when computing statistics for a single-time dataset #142

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

mpartio
Copy link
Contributor

@mpartio mpartio commented Nov 21, 2024

When calculating sample indices, make sure that at least one sample is included.

Example of the problem:

$ anemoi-datasets create example.yaml test.zarr
[..]
  File "/home/users/partio/src/anemoi-datasets/src/anemoi/datasets/data/dataset.py", line 471, in _compute_constant_fields_from_a_few_samples
      p = slice(0, count, count // (sample_count - 1))
                        ~~~~~~^^~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: integer division or modulo by zero

example.yaml:

dates:
  start: 2024-10-12T14:00:00Z
  end: 2024-10-12T14:00:00Z
  frequency: 1h
input:
  join:
  - grib:
      path: example.grib2
      param: [2t]
      levtype: sfc

When calculating sample indices, make sure that at least one sample
is included.
@FussyDuck
Copy link

FussyDuck commented Nov 21, 2024

CLA assistant check
All committers have signed the CLA.

@b8raoult b8raoult merged commit 7f7b181 into ecmwf:develop Nov 29, 2024
8 of 9 checks passed
@floriankrb floriankrb mentioned this pull request Dec 3, 2024
b8raoult added a commit that referenced this pull request Dec 7, 2024
* better error messages

* Fix division-by-zero when computing statistics for a single-time dataset (#142)

* accept frequency in minute in dataset names (#153)

* link to naming conventions

* fix negative variance  for constant variables (#148)

---------

Co-authored-by: Baudouin Raoult <[email protected]>
Co-authored-by: Mikko Partio <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: b8raoult <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants