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 function to plot Impf variability of calibration #791

Merged

Conversation

timschmi95
Copy link
Collaborator

@timschmi95 timschmi95 commented Oct 17, 2023

Changes proposed in this PR:

  • add a function which plots the impact function variability given a certain percentage difference in the cost function values. Additionaly has the option to plot the distribution of hazard intensity values at the selected exposure points

As discussed at the retreat. For me this function was quite useful to get a "feel" for the data. In some cases, it highlighted completely different impact functions with an almost equal cost-function value. Let me know if you think such a function is useful for users in general.

The two added plots and description are in the Section "Analyze the Calibration" of the tutorial Jupyter notebook.

PR Author Checklist

PR Reviewer Checklist

@timschmi95 timschmi95 marked this pull request as draft October 17, 2023 15:31
@timschmi95 timschmi95 requested a review from peanutfun October 17, 2023 15:32
Copy link
Collaborator

@leonie-villiger leonie-villiger left a comment

Choose a reason for hiding this comment

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

Thanks for adding the method .plot_impf_variability() to the OutputEvaluator! I believe this nice and informative visualisation is very helpful when calibrating impact functions. My comments:

  • code comments could be a bit more specific (see suggestions in base.py)
  • don't fully understand the reasoning to show the intermediate step of getting the haz_vals before plotting (see climada_util_calibrate.ipynb)
  • several trailing whitespace Linter issues (VS can remove the automatically, https://linux.how2shout.com/remove-trailing-spaces-automatically-in-visual-code-studio/)
  • complete the PR checklist (just now saw that the PR is only a draft...uuuups. I can give a final review once you're fully ready).

climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
doc/tutorial/climada_util_calibrate.ipynb Outdated Show resolved Hide resolved
doc/tutorial/climada_util_calibrate.ipynb Outdated Show resolved Hide resolved
@timschmi95 timschmi95 marked this pull request as ready for review October 24, 2023 08:43
@timschmi95
Copy link
Collaborator Author

Thanks @leonie-villiger for the review, especially the automatic whitespace removal tip! :)
Since this is a pull request within a hanging pull request I didn't update the documentation or Changelog, but marked it as done.

@peanutfun I managed to get the histogram much faster by using the .data attribute. Do you want to have a look over it before I merge it? The failing unit test are not related to this specific pull request, and I didn't add any tests for the new plotting function for now (as with the other plotting function in the calibration module). Is that all fine?

Copy link
Member

@peanutfun peanutfun left a comment

Choose a reason for hiding this comment

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

@timschmi95 Very helpful contribution, thanks a lot for that! My main concerns are how to deal with multiple impact functions within the impact function set and with the handling of plot parameters.

The failing tests are fine, we will fix this in the "main" PR.

climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
@timschmi95
Copy link
Collaborator Author

timschmi95 commented Oct 24, 2023

@peanutfun Thanks for the review, let me know if you think the added changes are suitable. Currently, the function will only return the last axis object in case there are multiple impact functions, but I think this shouldn't be an issue?

climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
climada/util/calibrate/base.py Show resolved Hide resolved
climada/util/calibrate/base.py Outdated Show resolved Hide resolved
@peanutfun peanutfun merged commit 2ace55f into calibrate-impact-functions Nov 14, 2023
3 of 10 checks passed
@emanuel-schmid emanuel-schmid deleted the feature/add_impf_variability_plot branch November 20, 2023 15:18
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.

3 participants