New interpolation util functionality by ValentinGebhart · Pull Request #930 · CLIMADA-project/climada_python

Conversation

@ValentinGebhart

Changes proposed in this PR:

  • new util module interpolate.py with which data can be linearly interpolated (and extrapolated) using the function interpolate_ev or interpolated with a stepfunction using the function stepfunction_ev. Options include thresholds and log scales. Also, a util function group_frequency is added to group frequencies for constant intensitity or impact values. These util functions will later be used in the functions Impact.local_exceedance_impact, Hazard.local_exceedance_intensity, Hazard.local_return_period, see PR Combining several interpolation functions using a new util function #918.

This PR is the first part of PR #918 (splitted for length reasons) that will fix #904, #915 and partially also #209.

PR Author Checklist

PR Reviewer Checklist

sarah-hlsn

Choose a reason for hiding this comment

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

Apart from a few typos and a minor suggestion this looks all good to me!

logx : bool, optional
If set to True, x_values are convert to log scale. Defaults to False.
logy : bool, optional
If set to True, x_values are convert to log scale. Defaults to False.

Choose a reason for hiding this comment

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

If set to True, x_values are convert to log scale. Defaults to False.
If set to True, y_values are convert to log scale. Defaults to False.

---

define fit functionalities for (local) exceedance frequencies and return periods

Choose a reason for hiding this comment

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

Is this line supposed to be here? As it is now I don't find it very explanatory for an external user. It's a matter of taste I guess but maybe something around the lines of: "Define interpolation and extrapolation functions for calculating (local) exceedance frequencies and return periods."?

Choose a reason for hiding this comment

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

agreed, I believe this was the description of the original PR, now it should be adapted as you say :)

if x_train.size < 2:
return _interpolate_small_input(x_test, x_train, y_train, None, y_asymptotic)

# find indeces of x_test if sorted into x_train

Choose a reason for hiding this comment

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

# find indeces of x_test if sorted into x_train
# find indices of x_test if sorted into x_train

Labels

2 participants

@ValentinGebhart @sarah-hlsn