def threshold_filter(elevation_series, threshold=5.0):
  """Filter elevation series by breaking it into vertical increments.
  
  Args:
    elevation_series (pd.Series): elevation coordinates along a path.
    threshold (float): Threshold beyond which a change in elevation is
      registered by the algorithm, in the units of the elevation series.
      Default 5.0.
  """
  ref_elev = elevation_series.iloc[0]
  elev_array = []
  for i, elev in elevation_series.iteritems():
    if abs(elev - ref_elev) > threshold:
      ref_elev = elev
    elev_array.append(ref_elev) 

  elevation_series.iloc[:] = elev_array

  return elevation_series