# Find index where variable is closest to split_valuesplit_value = 0 # Change as needed (e.g., x=0, y=0, etc.)split_var = x # Change to variable you're splitting bysplit_idx = np.argmin(np.abs(split_var - split_value))# Split into two parts (both include the split point)x_part1 = x[:split_idx+1] # Start to split point (inclusive)y_part1 = y[:split_idx+1]x_part2 = x[split_idx:] # Split point to endy_part2 = y[split_idx:]
2. Preparing Data for Interpolation
# Method A: Sort to ensure monotonic x-valuessort_idx1 = np.argsort(x_part1)x_part1, y_part1 = x_part1[sort_idx1], y_part1[sort_idx1]sort_idx2 = np.argsort(x_part2)x_part2, y_part2 = x_part2[sort_idx2], y_part2[sort_idx2]# Method B: Check and reverse if neededif x_part1[0] > x_part1[-1]: # If decreasing x_part1, y_part1 = x_part1[::-1], y_part1[::-1]