code: def _max_helper(self, arr, approximate=False,
                      interp_kwargs=None, minimize_kwargs=None):
          
          assert self.norbits == 1
          assert self.t[-1] > self.t[0] # time must increase
  
          _ix = argrelmax(arr.value, mode='wrap')[0]
          _ix = _ix[(_ix != 0) & (_ix != (len(arr)-1))] # remove edges
          t = self.t.value
  
          approx_arr = arr[_ix]
          approx_t = t[_ix]
  
          if approximate:
              return approx_arr, approx_t * self.t.unit
  
          if interp_kwargs is None:
              interp_kwargs = dict()
  
          if minimize_kwargs is None:
              minimize_kwargs = dict()
  
          # default scipy function kwargs
          interp_kwargs.setdefault('k', 3)
          interp_kwargs.setdefault('ext', 3) # don't extrapolate, use boundary
          minimize_kwargs.setdefault('method', 'powell')
  
          # Interpolating function to upsample array:
          # Negative sign because we assume we're always finding the maxima
          interp_func = InterpolatedUnivariateSpline(t, -arr.value,
                                                     **interp_kwargs)
  
          better_times = np.zeros(_ix.shape, dtype=float)
          for i, j in enumerate(_ix):
              res = minimize(interp_func, t[j], **minimize_kwargs)
              better_times[i] = res.x
  
          better_arr = -interp_func(better_times)
          return better_arr * arr.unit, better_times * self.t.unit
docs: Helper function for computing extrema (apocenter, pericenter, z_height)
          and times of extrema.
  
          Parameters
          ----------
          arr : `numpy.ndarray`