def interpolateAndPlot(xIn, yIn, tIn, tMin, tMax, k, Ts, fCode): # tIn = timeStamps#np.array(timeStamps) # xIn = coordX#np.array(coordX) # yIn = coordY#np.array(coordY) interpolatedXOnTime = interpolateBS(tIn, xIn, tMin, tMax, k, Ts, fCode) interpolatedYOnTime = interpolateBS(tIn, yIn, tMin, tMax, k, Ts, fCode) sampledTime = np.linspace(tMin, tMax, 1000) interpolatedXOnSampledTime = splev(sampledTime, interpolatedXOnTime) interpolatedYOnSampledTime = splev(sampledTime, interpolatedYOnTime) fig = plt.figure() ax = fig.gca() ax.scatter(xIn, yIn, c=tIn, cmap=cm.seismic) ax.plot(interpolatedXOnSampledTime, interpolatedYOnSampledTime, color='green') ax.legend() plt.show()
def interpolateAndPlot(xIn, yIn, tIn, tMin, tMax, k, Ts, fCode): """ interpolates given xIn, yIn acoording to times tMin, tMax and other inputs, and plots them on a graph """ # tIn = timeStamps#np.array(timeStamps) # xIn = coordX#np.array(coordX) # yIn = coordY#np.array(coordY) interpolatedXOnTime = interpolateBS(tIn, xIn, tMin, tMax, k, Ts, fCode) interpolatedYOnTime = interpolateBS(tIn, yIn, tMin, tMax, k, Ts, fCode) sampledTime = np.linspace(tMin, tMax, 1000) interpolatedXOnSampledTime = splev(sampledTime, interpolatedXOnTime) interpolatedYOnSampledTime = splev(sampledTime, interpolatedYOnTime) fig = plt.figure() ax = fig.gca() ax.scatter(xIn, yIn, c=tIn, cmap=cm.seismic) ax.plot(interpolatedXOnSampledTime, interpolatedYOnSampledTime, color="green") ax.legend() plt.show()
traceToFileLists(traceFileName, userNames, "Extracted Users:", "User: "******"Extracted Sessions:", "Session: ") traceToFileLists(traceFileName, projectionFields, "Extracted Fileds:", "Field: ") traceToFileLists(traceFileName, relativeTime, "Extracted Time Period:", "relativeTime: ") tracetoUsersExpDesVariables(userName1, tMin, tMax, k, Ts, fCode) tracetoUsersExpDesVariables(userName2, tMinUser, tMaxUser, kUser, TsUser, fCodeUser) # ============================================================================================================ # 6. Implement Experiment -------------------------------------------------------------------------------------------- #interpolate xCoord and yCoord with the timeStamps and other inputs for first user interpolatedXOnTime = interpolateBS(timeStamps, xCoord, tMin, tMax, k, Ts, fCode) interpolatedYOnTime = interpolateBS(timeStamps, yCoord, tMin, tMax, k, Ts, fCode) #sample the time and evaluate interpolation on sampledTime for first user sampledTime = np.linspace(tMin, tMax, 1000) interpolatedXOnSampledTime = splev(sampledTime, interpolatedXOnTime) interpolatedYOnSampledTime = splev(sampledTime, interpolatedYOnTime) #interpolate xCoord and yCoord with the timeStamps and other inputs for second user interpolatedXOnTimeUser = interpolateBS(timeStampsUser, xCoordUser, tMinUser, tMaxUser, kUser, TsUser, fCodeUser) interpolatedYOnTimeUser = interpolateBS(timeStampsUser, yCoordUser, tMinUser, tMaxUser, kUser, TsUser, fCodeUser) #sample the time and evaluate interpolation on sampledTime for second user
shift = timeStamps[-1] shiftedSampledTimeUser = [time.__add__(shift) for time in timeStampsUser] totalTimeStamps = timeStamps + shiftedSampledTimeUser totalxCoord = xCoord + xCoordUser totalyCoord = yCoord + yCoordUser plt.figure(1) plt.title('Check') plt.plot(totalTimeStamps) #), xIn, color='blue') #plt.plot(t, x, color='red') plt.show() #interpolateAndPlot(xCoordUser, yCoordUser, timeStampsUser, tMinUser, tMaxUser, kUser, TsUser, fCodeUser) interpolatedXOnTimeUser = interpolateBS(totalTimeStamps, totalxCoord, tMin, tMaxUser, kUser, TsUser, fCodeUser) interpolatedYOnTimeUser = interpolateBS(totalTimeStamps, totalyCoord, tMin, tMaxUser, kUser, TsUser, fCodeUser) sampledTimeUser = np.linspace(tMin, tMaxUser, 1000) interpolatedXOnSampledTimeUser = splev(sampledTimeUser, interpolatedXOnTimeUser) interpolatedYOnSampledTimeUser = splev(sampledTimeUser, interpolatedYOnTimeUser) # end of evina Configuration--------------------------------------------------- fig = plt.figure() ax = fig.gca() #ax.scatter(xCoord, yCoord, c=timeStamps, cmap=cm.seismic) ax.scatter(totalxCoord, totalyCoord, c=totalTimeStamps, cmap=cm.PiYG)