Improve nan treatment and add kinks only if found
@@ -450,12 +450,12 @@ def upper_envelope(segments, calc_crossings = True):
row = interp(segments[i][0], segments[i][1], x)
extrap = np.logical_or(x < segments[i][0][0], x > segments[i][0][-1])
- row[extrap] = -np.Inf
+ row[extrap] = np.nan
y_cond[i,:] = row
# Take the maximum to get the upper envelope
- env_inds = np.argmax(y_cond, 0)
+ env_inds = np.nanargmax(y_cond, 0)
y = y_cond[env_inds,range(len(x))]
# Get crossing points if needed
@@ -463,7 +463,9 @@ def upper_envelope(segments, calc_crossings = True):
xing_points, xing_lines = calc_cross_points(x, y_cond.T, env_inds)
+ if len(xing_points) > 0:
# Extract x and y coordinates
+ print(xing_points)
xing_x = np.array([p[0] for p in xing_points])
xing_y = np.array([p[1] for p in xing_points])
