def calculate_stats(container, twin, fargs, minima=False):
    """
    Calculate time series statistics

    Parameters
    ----------
    container : dict
        TimeSeries objects
    twin : tuple
        Time window. Time series are cropped to time window before extracting maxima.
    fargs : tuple
        Filter arguments. Time series are filtered before extracting maxima.
    minima : bool, optional
        Fit to sample of minima instead of maxima. The sample is multiplied by -1 prior to parameter estimation.

    Returns
    -------
    dict
        Filtered and windowed time series and peaks/throughs
    """
    return {name: ts.stats(twin=twin, filterargs=fargs, statsdur=10800., quantiles=(0.37, 0.57, 0.9),
                           is_minima=minima, include_sample=True) for name, ts in container.items()}