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

add partition plot #134

Merged
merged 19 commits into from
Jan 4, 2024
Merged

add partition plot #134

merged 19 commits into from
Jan 4, 2024

Conversation

juliettelavoie
Copy link
Contributor

@juliettelavoie juliettelavoie commented Nov 15, 2023

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
    • This PR fixes #xyz
  • (If applicable) Documentation has been added / updated (for bug fixes / features).
  • (If applicable) Tests have been added.
  • HISTORY.rst has been updated (with summary of main changes).
    • Link to issue (:issue:number) and pull request (:pull:number) has been added.

What kind of change does this PR introduce?

  • Add partition plot

Does this PR introduce a breaking change?

no

Other information:

Companion de Ouranosinc/xclim#1529

TODO:

  • test
  • todos in the code
  • add example in doc

@juliettelavoie juliettelavoie marked this pull request as draft November 15, 2023 20:43
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

juliettelavoie added a commit to Ouranosinc/xclim that referenced this pull request Dec 14, 2023
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #1497 
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] CHANGES.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

### What kind of change does this PR introduce?

*  Add partition algo from Lafferty and Sriver (2023)

### Does this PR introduce a breaking change?
depends (see options below)

### Other information:
TODO list in this PR:

- [x] Add weights
- [x] add tests
- [x] Maybe add `num` to `hawkins_sutton` ?
- [x] Clean up based on changes outside of this PR (eg. remove functions
that are now elsewhere)

TODO list outside of this PR:

- [ ] Add a more general `graph_fraction_of_total_variance` to figanos
(in progress by Juliette,
Ouranosinc/figanos#134)
- [ ] Add a function in xscen to prepare the data from a catalog.
(Ouranosinc/xscen#289)

In this function, I could rename the dimension to fit what the partition
vocabulary (`model`, `scenario`, `downscaling`) OR we could change the
partition vocab to the catalog/xscen vocab (`source`, `experiment`,
`bias_adjust_project`). Option 2 is my personal preference, but that
would be a breaking change for `hawkins_sutton`.
@juliettelavoie juliettelavoie marked this pull request as ready for review December 15, 2023 14:34
Copy link
Contributor

@huard huard left a comment

Choose a reason for hiding this comment

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

Ben beau. Question: qu'est-ce que je fais avec la PR originale #9 ?

Il y a dedans d'autres types de graphiques qu'on retrouve dans H&S ?

figanos/matplotlib/plot.py Outdated Show resolved Hide resolved
figanos/matplotlib/plot.py Outdated Show resolved Hide resolved
@juliettelavoie
Copy link
Contributor Author

Ben beau. Question: qu'est-ce que je fais avec la PR originale #9 ?

Il y a dedans d'autres types de graphiques qu'on retrouve dans H&S ?

Vite de même, je ne suis pas sur de voir l'utilité de mettre graph_variance. La majorité de la fonction est de mettre les couleurs H&S, mais idéalement figanos préfère ses propres couleurs.

Pour graph_fractional_uncertainty, je mettrais le calcul ailleurs que dans figanos et le reste est aussi presque juste les couleurs et un appel à xarray plot.

@sarahclaude
Copy link
Collaborator

sarahclaude commented Dec 20, 2023

C'est des détails, mais en changeant la linewidth il y a un dédoublement vers le bas et en zoomant on peut voir que la couleur orange dépasse de la ligne.
Show_num est aussi True, est-ce qu'il devrait avoir des nombres dans la légende?

image

Dans l'exemple du notebook, qu'est-ce que représente "total" avec la couleur "k" dans "fill_kw"?

@juliettelavoie
Copy link
Contributor Author

linewidth: Je pense que c'est un bug de matplotlib parce que c'est le bas du fill_width= black lines. Je peux ajouter dans le docstring qu'on recommande lw>=2 ?
show_num: L'information pour show_num est une addition de la PR#1529 de xclim. Elle n'est donc pas dans le release le plus récent utilisé pour build les docs prsentement. Une fois que xclim aura release la nouvelle version avec mes ajouts, l'information apparaitra dans la doc figanos.
total: C'est une erreur oups! Je l'enlève.

Copy link
Collaborator

@sarahclaude sarahclaude left a comment

Choose a reason for hiding this comment

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

I still see it as doubled with lw=2 at the lowest point but it makes sense then since there's some green in that area!
image
Looks good!

@juliettelavoie juliettelavoie merged commit f047bc3 into main Jan 4, 2024
15 checks passed
@juliettelavoie juliettelavoie deleted the add_partition_plot branch January 4, 2024 15:38
juliettelavoie added a commit to Ouranosinc/xscen that referenced this pull request Jan 10, 2024
<!-- Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [ ] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #xyz
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features).
- [x] (If applicable) Tests have been added.
- [x] This PR does not seem to break the templates.
- [x] HISTORY.rst has been updated (with summary of main changes).
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added.

### What kind of change does this PR introduce?

* Add `xs.ensembles.get_partition_input` to prepare data from catalog to
be passed to xclim partionning functions
(https://xclim.readthedocs.io/en/stable/api.html#uncertainty-partitioning)
* Now, I am wondering if it would be more xscen to also wrap the xclim
fonction instead only prepping the data? This would allow to add a attrs
`processing_level= partition` to be able to put it in a a catalog.
workflow 1: `xs.get_partition_input` -> `xc.ensembles.lafferty_sriver`
-> `fg.partition`
workflow 2: `xs.partition` (which gets the input and wraps xclim) ->
maybe save to disk and catalog -> `fg.partition` or other plots (maybe
maps of one component)
EDIT: I went with workflow 1

### Does this PR introduce a breaking change?
no

### Other information:
* I wasn't sure if this should be in `extract.py` (because we extract
from a cat) or in `ensembles.py` ( to match the xclim module).
* companion de Ouranosinc/xclim#1529 et
Ouranosinc/figanos#134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants