nodes: 0, module; 1, function_definition; 2, function_name:_find_append_zero_crossings; 3, parameters; 4, block; 5, identifier:x; 6, identifier:y; 7, expression_statement; 8, comment:# Find and append crossings to the data; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# Resort so that data are in order; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, comment:# Remove duplicate data points if there are any; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, return_statement; 21, comment:r"""
      Find and interpolate zero crossings.
  
      Estimate the zero crossings of an x,y series and add estimated crossings to series,
      returning a sorted array with no duplicate values.
  
      Parameters
      ----------
      x : `pint.Quantity`
          x values of data
      y : `pint.Quantity`
          y values of data
  
      Returns
      -------
      x : `pint.Quantity`
          x values of data
      y : `pint.Quantity`
          y values of data
  
      """; 22, assignment; 23, assignment; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, assignment; 31, expression_list; 32, identifier:crossings; 33, call; 34, identifier:x; 35, call; 36, identifier:y; 37, call; 38, identifier:sort_idx; 39, call; 40, identifier:x; 41, subscript; 42, identifier:y; 43, subscript; 44, identifier:keep_idx; 45, comparison_operator:np.ediff1d(x, to_end=[1]) > 0; 46, identifier:x; 47, subscript; 48, identifier:y; 49, subscript; 50, identifier:x; 51, identifier:y; 52, identifier:find_intersections; 53, argument_list; 54, identifier:concatenate; 55, argument_list; 56, identifier:concatenate; 57, argument_list; 58, attribute; 59, argument_list; 60, identifier:x; 61, identifier:sort_idx; 62, identifier:y; 63, identifier:sort_idx; 64, call; 65, integer:0; 66, identifier:x; 67, identifier:keep_idx; 68, identifier:y; 69, identifier:keep_idx; 70, subscript; 71, subscript; 72, binary_operator:np.zeros_like(y[1:]) * y.units; 73, tuple; 74, tuple; 75, identifier:np; 76, identifier:argsort; 77, identifier:x; 78, attribute; 79, argument_list; 80, identifier:x; 81, slice; 82, identifier:y; 83, slice; 84, call; 85, attribute; 86, identifier:x; 87, subscript; 88, identifier:y; 89, subscript; 90, identifier:np; 91, identifier:ediff1d; 92, identifier:x; 93, keyword_argument; 94, integer:1; 95, integer:1; 96, attribute; 97, argument_list; 98, identifier:y; 99, identifier:units; 100, identifier:crossings; 101, integer:0; 102, identifier:crossings; 103, integer:1; 104, identifier:to_end; 105, list; 106, identifier:np; 107, identifier:zeros_like; 108, subscript; 109, integer:1; 110, identifier:y; 111, slice; 112, integer:1
code: def _find_append_zero_crossings(x, y):
      r"""
      Find and interpolate zero crossings.
  
      Estimate the zero crossings of an x,y series and add estimated crossings to series,
      returning a sorted array with no duplicate values.
  
      Parameters
      ----------
      x : `pint.Quantity`
          x values of data
      y : `pint.Quantity`
          y values of data
  
      Returns
      -------
      x : `pint.Quantity`
          x values of data
      y : `pint.Quantity`
          y values of data
  
      """
      # Find and append crossings to the data
      crossings = find_intersections(x[1:], y[1:], np.zeros_like(y[1:]) * y.units)
      x = concatenate((x, crossings[0]))
      y = concatenate((y, crossings[1]))
  
      # Resort so that data are in order
      sort_idx = np.argsort(x)
      x = x[sort_idx]
      y = y[sort_idx]
  
      # Remove duplicate data points if there are any
      keep_idx = np.ediff1d(x, to_end=[1]) > 0
      x = x[keep_idx]
      y = y[keep_idx]
      return x, y