def gpugem(query, subject, St0=2, St1=2, E=0.01, symmetric=False, squared=True): """GEM local similarity measure""" N = lgemc.TimeSeries(query) H = lgemc.TimeSeries(subject) R = lgemc.Result() lgemc.cuda_match(N, H, R, St0, St1, E, squared) dist = R[0].penalty if (symmetric): R = lgemc.Result() lgemc.cuda_match(H, N, R, St0, St1, E, squared) dist = min(dist, R[0].penalty) return dist
return (series - np.mean(series)) / np.std(series) # generate query and subject S = znormalize(get_signal(1001000)) N = gem.TimeSeries(S[:1000]) H = gem.TimeSeries(S[1000:]) print len(N), len(H) # matching parameters St0, St1, E = 2, 2, 0.01 R = gem.Result() t = time.time() gemc.cuda_match(N, H, R, St0, St1, E, True) print "time needed:", time.time( ) - t, "best match:", R[0].penalty, R[0].left, R[0].right R = gem.Result() t = time.time() gem.match(N, H, R, St0, St1, E, True, True) print "time needed:", time.time( ) - t, "best match:", R[0].penalty, R[0].left, R[0].right pl.plot(np.array(N) + 1) pl.plot(H, c="lightgrey") for item in R[:10]: L = gem.TimeSeries() X = gem.TimeCoords()
return (series-np.mean(series))/np.std(series) # generate query and subject S = znormalize(get_signal(1001000)) N = gem.TimeSeries(S[:1000]) H = gem.TimeSeries(S[1000:]) print len(N), len(H) # matching parameters St0, St1, E = 2, 2, 0.01 R = gem.Result() t=time.time() gemc.cuda_match(N, H, R, St0, St1, E, True) print "time needed:", time.time()-t, "best match:", R[0].penalty, R[0].left, R[0].right R = gem.Result() t=time.time() gem.match(N, H, R, St0, St1, E, True, True) print "time needed:", time.time()-t, "best match:", R[0].penalty, R[0].left, R[0].right pl.plot(np.array(N) + 1) pl.plot(H, c = "lightgrey") for item in R[:10]: L = gem.TimeSeries() X = gem.TimeCoords() Y = gem.TimeSeries()