Esempio n. 1
0
def get_live_timeseries():
    ts = TimeSeries()
    ts.set_live()
    ts.dt = 1 / sampling_rate
    ts.npts = ts_size
    # ts.put('net', 'IU')
    ts.put("npts", ts_size)
    ts.put("sampling_rate", sampling_rate)
    ts.tref = TimeReferenceType.UTC
    ts.t0 = datetime.utcnow().timestamp()
    ts["delta"] = 0.1
    ts["calib"] = 0.1
    ts["site_id"] = bson.objectid.ObjectId()
    ts["channel_id"] = bson.objectid.ObjectId()
    ts["source_id"] = bson.objectid.ObjectId()
    ts.set_as_origin("test", "0", "0", AtomicType.TIMESERIES)
    ts.data = DoubleVector(np.random.rand(ts_size))
    return ts
Esempio n. 2
0
def get_live_timeseries():
    ts = TimeSeries()
    ts.set_live()
    ts.dt = 1 / sampling_rate
    ts.npts = ts_size
    # ts.put('net', 'IU')
    ts.put('npts', ts_size)
    ts.put('sampling_rate', sampling_rate)
    ts.tref = TimeReferenceType.UTC
    ts.t0 = datetime.utcnow().timestamp()
    ts['delta'] = 0.1
    ts['calib'] = 0.1
    ts['site_id'] = bson.objectid.ObjectId()
    ts['channel_id'] = bson.objectid.ObjectId()
    ts['source_id'] = bson.objectid.ObjectId()
    ts.set_as_origin('test', '0', '0', AtomicType.TIMESERIES)
    ts.data = DoubleVector(np.random.rand(ts_size))
    return ts
Esempio n. 3
0
def make_wavelet_noise_data(nscale=0.1,
                            ns=2048,
                            padlength=512,
                            dt=0.05,
                            npoles=3,
                            corners=[0.08, 0.8]):
    wn = TimeSeries(ns)
    wn.t0 = 0.0
    wn.dt = dt
    wn.tref = TimeReferenceType.Relative
    wn.live = True
    nd = ns + 2 * padlength
    y = nscale * randn(nd)
    sos = signal.butter(npoles,
                        corners,
                        btype='bandpass',
                        output='sos',
                        fs=1.0 / dt)
    y = signal.sosfilt(sos, y)
    for i in range(ns):
        wn.data[i] = y[i + padlength]
    return (wn)
Esempio n. 4
0
def test_TimeSeries():
    ts = TimeSeries()
    ts.npts = 100
    ts.t0 = 0.0
    ts.dt = 0.001
    ts.live = 1
    ts.tref = TimeReferenceType.Relative
    ts.data.append(1.0)
    ts.data.append(2.0)
    ts.data.append(3.0)
    ts.data.append(4.0)
    ts.sync_npts()
    assert ts.npts == 104
    assert ts.npts == ts["npts"]
    ts += ts
    for i in range(4):
        ts.data[i] = i * 0.5
    ts_copy = pickle.loads(pickle.dumps(ts))
    assert ts.data == ts_copy.data
    assert ts.data[3] == 1.5
    assert ts.data[103] == 8
    assert ts.time(100) == 0.1
    assert ts.sample_number(0.0998) == 100