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

Pmp #176

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

Pmp #176

wants to merge 43 commits into from

Conversation

ospinajulian
Copy link
Collaborator

@ospinajulian ospinajulian commented Jul 23, 2024

Pull Request Checklist:

  • (If applicable) Documentation has been added / updated (for bug fixes / features).
  • (If applicable) Tests have been added.
  • CHANGELOG.rst has been updated (with summary of main changes).

What kind of change does this PR introduce?

A new pmp module has been added to compute the Probable Maximum Precipitation

Does this PR introduce a breaking change?

No

@ospinajulian ospinajulian added the enhancement New feature or request label Jul 23, 2024
@ospinajulian ospinajulian self-assigned this Jul 23, 2024
Copy link

github-actions bot commented Jul 23, 2024

Welcome, new contributor!

It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the AUTHORS.rst and .zenodo.json:

  • The relevant author information has been added to AUTHORS.rst and .zenodo.json.

Please make sure you've read our contributing guide. We look forward to reviewing your Pull Request shortly ✨

src/xhydro/PMP.py Outdated Show resolved Hide resolved
tests/test_PMP.py Outdated Show resolved Hide resolved
src/xhydro/pmp.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added the CI label Jul 29, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added the notebooks Run tests against notebooks label Jul 30, 2024
@ospinajulian ospinajulian marked this pull request as ready for review July 30, 2024 20:49
Copy link
Contributor

@sebastienlanglois sebastienlanglois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Thanks for bringing this into xhydro 👍

CHANGELOG.rst Outdated Show resolved Hide resolved
environment-dev.yml Outdated Show resolved Hide resolved
environment.yml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@github-actions github-actions bot added the docs label Aug 7, 2024
Copy link
Collaborator

@Zeitsperre Zeitsperre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just want to make sure we don't lose track of needed changes.

pyproject.toml Outdated Show resolved Hide resolved
.yamllint.yaml Outdated Show resolved Hide resolved
environment.yml Outdated Show resolved Hide resolved
environment-dev.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to investigate the numpy testing utilities. More powerful tests (faster too, I would imagine): https://numpy.org/doc/stable/reference/routines.testing.html

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. The current test are also never checking the results themselves to make sure that they are OK or that they don't change when we update the code.

https://github.com/hydrologie/xhydro/blob/main/tests/test_local.py for inspiration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included numpy utilities in the tests. They also check the results numerically to make sure they do not change if the code is updated.

@@ -169,6 +169,7 @@ jobs:
create-args: >-
mamba
python=${{ matrix.python-version }}
lmoments3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can have a specific build that installs lmoments3. I can look into implementing that.

docs/notebooks/pmp.ipynb Show resolved Hide resolved
docs/notebooks/pmp.ipynb Show resolved Hide resolved
docs/notebooks/pmp.ipynb Show resolved Hide resolved
Copy link
Collaborator

@RondeauG RondeauG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job ! Par contre, j'ai un questionnement de fond sur l'endroit où ce code devrait se trouver.

  • 1: On garde ça comme ça.
  • 2: On garde ça dans xhydro, mais on déplace vers indicators.py. Il y a déjà des indicateurs similaires (compute_volume, get_yearly_op), donc je crois que ça peut fitter là plutôt que d'avoir son propre fichier.
  • 3: On bouge ça carrément dans xclim. Selon moi ça a clairement sa place là si on veut, mais ça va demander un peu plus de travail. On pourrait avoir un petit wrapper dans xhydro au besoin.

Thoughts? @ospinajulian @elysefournier

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. The current test are also never checking the results themselves to make sure that they are OK or that they don't change when we update the code.

https://github.com/hydrologie/xhydro/blob/main/tests/test_local.py for inspiration.

src/xhydro/pmp.py Outdated Show resolved Hide resolved
src/xhydro/pmp.py Outdated Show resolved Hide resolved
src/xhydro/pmp.py Outdated Show resolved Hide resolved
src/xhydro/pmp.py Outdated Show resolved Hide resolved
src/xhydro/pmp.py Outdated Show resolved Hide resolved
return da_higest


def precipitable_water(ds, ds_fx, acc_day=[1], path=None):
Copy link
Collaborator

@RondeauG RondeauG Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vois plusieurs améliorations possibles à tout ce qui suit dans ce fichier, pour suivre une mécanique plus près de xclim, mais ça serait long et pas convivial à mettre dans GitHub... Est-ce correct si je modifie directement la branche @ospinajulian ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui, aucun problème @RondeauG

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La dernière fois que @RondeauG a proposé de faire quelques modifications à une PR, ça a donné un super résultat ;)

@sebastienlanglois
Copy link
Contributor

Good job ! Par contre, j'ai un questionnement de fond sur l'endroit où ce code devrait se trouver.

  • 1: On garde ça comme ça.
  • 2: On garde ça dans xhydro, mais on déplace vers indicators.py. Il y a déjà des indicateurs similaires (compute_volume, get_yearly_op), donc je crois que ça peut fitter là plutôt que d'avoir son propre fichier.
  • 3: On bouge ça carrément dans xclim. Selon moi ça a clairement sa place là si on veut, mais ça va demander un peu plus de travail. On pourrait avoir un petit wrapper dans xhydro au besoin.

Thoughts? @ospinajulian @elysefournier

Personnellement, je pencherais pour 1 ou 2 (avec préférence pour l'option 2). L'objectif d'une PMP est quand même très "appliquée" et sert souvent seulement d'intrant pour l'étape suivante qui est la modélisation hydrologique et n'a pas vraiment d'utilité dans le monde de la climatologie par elle-même. Si tu penses pouvoir harmoniser le code avec les indicateurs lors de ton refactor, je pense que ce serait super.

À très long terme, si on voit que ça a vraiment plus sa place dans xclim, on pourrait opter pour le changement, mais pour le moment, je pense qu'il y a d'autres priorités plus importantes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI docs enhancement New feature or request notebooks Run tests against notebooks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants