def slideWindow(self, distance): if self.waveStart + distance < 0 or self.waveEnd + distance > self.waveLength or distance == 0: return else: self.waveStart = self.waveStart + distance if distance > 0: self.oldX = self.x[:distance] self.oldY = self.y[:distance] (self.newX, self.newY) = tde.slidePhaseSpace(self.wave, self.waveEnd + 44, distance, self.tauX) self.x = np.concatenate((self.x[distance:], self.newX)) self.y = np.concatenate((self.y[distance:], self.newY)) newPts = ou.getPointObjects(self.newX, self.newY) self.oct.appendPoints(newPts) else: self.oldX = self.x[distance:] self.oldY = self.y[distance:] (self.newX, self.newY) = tde.slidePhaseSpace(self.wave, self.waveStart, distance, self.tauX) self.x = np.concatenate((self.newX, self.x[:distance])) self.y = np.concatenate((self.newY, self.y[:distance])) newPts = ou.getPointObjects(self.newX, self.newY) self.oct.prependPoints(newPts) self.waveEnd = self.waveEnd + distance
def __init__(self,fig,ax): self.fig = fig self.ax = ax self.wave = np.array(Startup()) self.waveStart = 0 self.waveEnd = tde.getWaveEnd(self.waveStart) self.waveLength = self.wave.size [self.x,self.y, self.tauX] = tde.getPhaseData(self.wave, self.waveStart, self.waveEnd) self.oldX = [] self.oldY = [] self.newX = [] self.newY = [] self.points = ou.getPointObjects(self.x,self.y) self.oct = Octree.Octree(5) start = time.perf_counter() self.oct.createOctree(self.points,True) self.drawScatter() self.drawOctree() self.fig.canvas.draw() print(time.perf_counter()-start)
def initRoach(self): self.wave = ss.getRoachPoints() self.waveLength = len(self.wave) self.waveStart = 0 self.waveEnd = tde.getWaveEnd(self.waveStart) (tmpX, tmpY) = zip(*[(point[1], point[2]) for point in self.wave]) bounds = self.getBoundsCreatePoints(tmpX, tmpY) binDepth = 6 self.oct = Octree.Octree(binDepth, bounds, 4, 4) self.oct.createOctree(self.points, True)
def initActivityRecognition(self, sub_idx): #testortrain = ['test','train'] testortrain = ['test'] #iterations = ['1','2','3','4'] iterations = ['1'] self.runtime = 0 self.tot_run = 0 for tot in testortrain: for iteration in iterations: saveLocation = '.\\Data\\Subject' + sub_idx + '\\Subsamples_' + tot + '\\It_' + iteration + '\\' self.windows = ss.getWindowedPoints(sub_idx, iteration, tot) i = 0 for window in self.windows: self.wave = window self.waveStart = 0 self.waveEnd = tde.getWaveEnd(self.waveStart) self.x = [float(i[0]) for i in self.wave] self.y = [float(i[1]) for i in self.wave] self.z = [float(i[2]) for i in self.wave] self.x = np.array(self.x) self.y = np.array(self.y) self.z = np.array(self.z) self.points = ou.getPointObjects(self.x, self.y, self.z) binThreshold = math.ceil(1000 / len(self.points)) binThreshold = min(3, binThreshold) bounds = self.getBoundsThree(self.points) self.oct = Octree.Octree(4, bounds, binThreshold, 10) start = time.perf_counter() self.oct.createOctree(self.points, True) self.runtime += time.perf_counter() - start self.tot_run += 1 # sample = self.oct.getKdSubsamplePoints() # while len(sample) < 3 and self.oct.trajThreshold > 1: # self.oct.decreaseThreshold() # sample = self.oct.getKdSubsamplePoints() # if not os.path.exists(saveLocation): # os.makedirs(saveLocation) # with open(saveLocation + 'joint'+str((i%6)+1)+'window'+str((i//6)+1)+'.csv','w',newline='') as outFile: # writer = csv.writer(outFile) # for point in sample: # writer.writerow(point) # i+=1 # plt.cla() del self.oct
def initMapping(self): self.wave = ss.getMapPoints() self.waveLength = len(self.wave) self.waveStart = 0 self.waveEnd = tde.getWaveEnd(self.waveStart) (tmpX, tmpY) = zip(*[(point[0], point[1]) for point in self.wave]) bounds = self.getBoundsCreatePoints(tmpX, tmpY) #self.visualizePaths() #plt.show() #return binDepth = 11 self.preprocessData(bounds, binDepth) self.ax.set_xlim([bounds.minX, bounds.maxX]) self.ax.set_ylim([bounds.minY, bounds.maxY]) self.oct = Octree.Octree(binDepth, bounds, 10, 100) start_time = time.time() self.oct.createOctree(self.points, True) print("runtime : {}".format(time.time() - start_time))
def initMisc(self): self.wave = ss.getPointsFromFile() self.waveStart = 0 self.waveEnd = tde.getWaveEnd(self.waveStart) self.x = [float(i[0]) for i in self.wave] self.y = [float(i[1]) for i in self.wave] self.z = [float(i[2]) for i in self.wave] self.x = np.array(self.x) self.y = np.array(self.y) self.z = np.array(self.z) self.points = ou.getPointObjects(self.x, self.y, self.z) binThreshold = 2 bounds = self.getBoundsThree(self.points) self.oct = Octree.Octree(4, bounds, binThreshold, 10) start = time.perf_counter() self.oct.createOctree(self.points, True) self.visualizePaths() self.drawOctree() plt.show() sample = self.oct.getKdSubsamplePoints() print(time.perf_counter() - start)