code: def nearest_intersection_idx(a, b):
      
      # Difference in the two y-value sets
      difference = a - b
  
      # Determine the point just before the intersection of the lines
      # Will return multiple points for multiple intersections
      sign_change_idx, = np.nonzero(np.diff(np.sign(difference)))
  
      return sign_change_idx
docs: Determine the index of the point just before two lines with common x values.
  
      Parameters
      ----------
      a : array-like
          1-dimensional array of y-values for line 1
      b : array-like
          1-dimensional array of y-values for line 2
  
      Returns
      -------
          An array of indexes representing the index of the values
          just before the intersection(s) of the two lines.