-
Notifications
You must be signed in to change notification settings - Fork 128
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
Improve efficiency of local exceedance intensitry/impact and local return periods functions #1012
base: develop
Are you sure you want to change the base?
Conversation
LOGGER.info( | ||
"Some errors in the previous calculation of local exceedance impacts have been corrected," | ||
" see Impact.local_exceedance_impact. To reproduce data with the " | ||
"previous calculation, use CLIMADA v5.0.0 or less." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool idea, I am not sure though that this should be an info logging. @emanuel-schmid : what would be the most elegant way to inform the users that something changed, without having logs all the time?
impacts_stats, title, column_labels = self.local_exceedance_impact( | ||
return_periods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this calculous optional? Or what would be the way to refine the plot without having to recalculate these values (which can take quite long)? Is it using the util method instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best way is to do gdf, title, columns = hazard.local_exceedance_intensity()
and u_plot.plot_from_gdf(gdf, title, columns)
. Then you can just change the plot options by repeating the second step, without recalculating the gdf. The plot_rp_intensity
is just a wrapper around these two functions, which is why I asked if we want to keep it in the first place.
One way of not repeating the calculation here if one calls the function plot_rp_intensity
twice would be to save the local exceedance gdf as an attribute of the Hazard object, but I don't think we want to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about writing the info to better use the other two functions in the docstring, as you suggested in the issue? Is this enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be a solution I think. For small hazards I guess the method is rather fast, and for lager ones there would the solution in the docstring.
Changes proposed in this PR:
Changes address the methods
Hazard.local_exceedance_intensity
,Hazard.local_return_period
,Impact.local_exceedance_impact
, andImpact.local_return_period
.util.interpolate.round_to_sig_digits
was fixed.Hazard.plot_rp_intensity
andImpact.plot_rp_imp
now directly call the corresponding functions above, and a warning is added about how to recover values that are computed with CLIMADA 5.0.0 or earlier.Comments:
This PR fixes #1010
PR Author Checklist
develop
)PR Reviewer Checklist