def tsadd(t1, v1, n1, t2, v2, n2):
    """Adds two TS considering asynchronous times"""
    import numpy as np
    t, v = [], []
    k1, k2 = 0, 0
    p1, p2 = v1[0], v2[0]
    while True:
        if t1[k1] < t2[k2]:
            t.append(t1[k1])
            p1 = v1[k1]
            k1 += 1
        elif t1[k1] > t2[k2]:
            t.append(t2[k2])
            p2 = v2[k2]
            k2 += 1
        else:
            t.append(t1[k1])
            p1, p2 = v1[k1], v2[k2]
            k1 += 1
            k2 += 1
        v.append(p1 + p2)
        if k1 == n1 or k2 == n2:
            break
    return np.array(t), np.array(v), len(t)
