code: def despike(self, window_length=33, samples=True, z=2):
          
          window_length //= 1 if samples else self.step
          z *= np.nanstd(self)  # Transform to curve's units
          curve_sm = self._rolling_window(window_length, np.median)
          spikes = np.where(np.nan_to_num(self - curve_sm) > z)[0]
          spukes = np.where(np.nan_to_num(curve_sm - self) > z)[0]
          out = np.copy(self)
          params = self.__dict__.copy()
          out[spikes] = curve_sm[spikes] + z
          out[spukes] = curve_sm[spukes] - z
          return Curve(out, params=params)
docs: Args:
              window (int): window length in samples. Default 33 (or 5 m for
                  most curves sampled at 0.1524 m intervals).
              samples (bool): window length is in samples. Use False for a window
                  length given in metres.
              z (float): Z score
  
          Returns:
              Curve.