Add inter/extrapolate features to ImpactFreqCurve#1252
Add inter/extrapolate features to ImpactFreqCurve#1252ValentinGebhart wants to merge 11 commits intodevelopfrom
Conversation
chahank
left a comment
There was a problem hiding this comment.
Great, small tweaks.
Changelog needs to be updated too.
Co-authored-by: Samuel Juhel <10011382+spjuhel@users.noreply.github.com> Co-authored-by: Chahan M. Kropf <chahan.kropf@usys.ethz.ch>
…roject/climada_python into feature/interpolate_exceedance
|
This is what the method
|
|
Nice! And how would the interpolate look like? It seems to me that for this function interpolation (with extrapolation) would be more informative to smooth out the missing values at high return periods. (Maybe this should also be the default instead of the direct extrapolation). |
Interpolate would look exactly the same but with no values outside the two dashed lines. I think matplotlib would the automatically zoom into the data range, so it would look very much like the original plot() method (ofc the interpolation is a bit different).
What exactly do you mean with "smooth out"? I assume to mark the outside-of-data range, but not sure how you would like to visualize it. |
|
Thanks a lot for this, it's going to be very useful for me! Something that would be useful in some of the work I'm doing would be an Also: if that's not within scope of the PR and you'd just like to merge we can leave it for later! |
|
Great to hear @ChrisFairless. If you need this, you could add a wrapper method around the added |
|
I am hestitating with merging the PR due to two points. What do you think @chahank? (1) Depending on user input it can happen that the return period curve is interpolated twice, each with different methods. In this code fc = imp.calc_freq_curve(return_per=np.linspace(10, 100, 10))
fc.plot_extrapolate(return_periods=np.linspace(10,100,100))The first line creates a frequency curve at the given return periods, interpolated with linear interpolation between (exceedence frequncy, impact) pairs. (2) Is the plot style clear or do we want to show it differently? See two dashed gray lines indicating the range of data. |
|
Good points!
Should we make it default that
I think it is a bit unclear what the grey lines mean. Not sure how to make it clearer. Maybe instead make the color of the extrapolated part of the curve dashed? And no vertical dashed lines? |
|
Perfect, I like both your suggestions. I will implement them. Small question: A line like |
Good point. Then for the moment, let us keep it working, but with a deprecation warning. |
|
I added a deprecation warning if one creates the ImpactFreqCurve using Also, I changed the extrapolation plot style, extrapolated values are now shown as a dashed line, see plot above. @chahank for me this would be ready to merge, let me know if we should go ahead. |
Excellent! We now just have one little inconsistency: the extrapolate method returns a numpy array, while the calc_freq_curve returns directly the ImpactFreqCurve. Maybe we can improve the deprecation message to make it clear how to obtain a new ImpactFreqCurve? Or should maybe the extrapolate method be able to return an ImpactFreqCurve too? |
|
I would say that there are two methods to create an If you think it would be better to have the extrapolate method take an ImpactFreqCurve and return an ImpactFreqCurve, would could also do that. |
Yes, I am unsure what is best. Maybe we can ask in the developer's call for an opinion? |
|
After advice from @peanutfun and @emanuel-schmid (thanks!), I changed the implementation to:
@chahank Let me know if this looks good, then we can merge. |


Changes proposed in this PR:
ImpactFreqCurve, adding theinterpolatemethod to evaluate ImpactFreqCurve at new return periods with inter- and extrapolation optionsinterpolatemethodimpact.calc_freq_curve()with given return periods as inputsThis PR fixes #
PR Author Checklist
develop)PR Reviewer Checklist