Closed ssolson closed 7 months ago
@cmichelenstrofer could you give me a quick sanity check on the approach I took to fix this bug?
@akeeste I am 99% certain what I did is correct and was mostly just checking with Carlos just in case. If you want to give a formal review while we wait I believe this PR is ready.
Caveat: I didn't run it to make sure it works.
But the logic & implementation look good to me. If I understand correctly these are the steps in the code:
based on how the data is divided the max/minimum if missing should only be one index away.
Overview
In #218 @Graham-EGI uncovered a bug in
mhkit.wave.contours.samples_contour
What he uncovered was quite simple:
samples_contour
ValueError: A value in x_new is above the interpolation range.
Reference Example from #218
The import part to note in the code block that
period_samples
is defined usingmax_tp
.The reason this error is thrown is because the sampling is performed by breaking the passed contour into 2 halves. The upper and lower half called
w1
andw2
insamples_contour
.samples_contour
chooses the upper half of the contour:As can be seen in the second plot the upper half ("chosen segment # 2") is not inclusive of the Max Tp value (red circle on right side). This max Tp value was used as the max of the Tp sample range. Therefore the interpolation throws an error as the sample is outside the data included for interpolation.
Solution
To fix this: