docs: def f_energy(ac_power, times):
      """
      Calculate the total energy accumulated from AC power at the end of each
      timestep between the given times.
  
      :param ac_power: AC Power [W]
      :param times: times
      :type times: np.datetime64[s]
      :return: energy [W*h] and energy times
      """
      dt = np.diff(times)  # calculate timesteps
      # convert timedeltas to quantities
      dt = dt.astype('timedelta64[s]').astype('float') / sc_const.hour
      # energy accumulate during timestep
      energy = dt * (ac_power[:-1] + ac_power[1:]) / 2
      return energy, times[1:]