def ts_to_double(ts):
    """Calculate a double precision UNIX time from a timespec.

    Parameters
    ----------
    ts : timespec
        Time as timespec.

    Returns
    -------
    time : float
        Time as UNIX time float.
    """
    return ts.tv + 1e-9 * ts.tv_nsec