def elev_gain_loss(elev_data, smooth_time=25):
    """
    Calculate elevation gain and loss over the course of the activity.

    Elevation profile smoothed to reduce the impact of short-term elevation noise.

    Gain and loss defined as cumulative sum of positive and negative 1st discrete difference, respectively.

    :param pd.Series elev_data: series of elevation data, indexed with timestamp
    :param int smooth_time: number of seconds to smooth input data before calculating changes
    :return: (elevation gain, elevation loss)
    :rtype: tuple
    """
    # smooth input data by n seconds
    elev_data = elev_data.rolling('{}s'.format(str(smooth_time))).mean()

    # gain and loss calculation
    gain = sum([i for i in elev_data.diff() if i > 0])
    loss = sum([i for i in elev_data.diff() if i < 0])

    return gain, loss