Increasing the dection limit to 5 seemed to work well. Early detection disappearead, and the program still seems to find the beginning of the event very quickly. The last challenge in mapping is just finding the left limit more consistently. The minimum detection method seems fairly robust, but it misses a few points. This may have to do with the window size. It might be smart to double the window size for the second derivative calculation.
Fixed problems with left tail end. Now using max delta from d2fdz2 as detction endpoint. This is ineffective for curves without breakthroughs, so
those curves without breakthroughs are measured with first derivatives (which should always be highest at the end of the curve). This seems
effective. I now need to try fitting the actual JKR formula to the fitted region.