def load(self, fileList): loader = DataLoader() self.standard = loader.read(fileList[0]) self.sampleSize = len(self.standard) data = [] # extend all data to same length for dataFile in fileList: line = loader.read(dataFile) dist, path = dtwDistance(self.standard, line) lineData = dtwExtend(line, path) data.append(lineData) self.data = data
def testResizing(): testdata = config.data['datafile']['test'] dl = DataLoader() data = dl.read(testdata[0]) print len(data) newdata = BoxStretch(data, 600) ml = MagneticLine() ml.addLine(data, "origin") ml.addLine(newdata, "newline") ml.show()
def testGraphing(): # import scipy.misc.imresize testdata = config.data['datafile']['test'] dl = DataLoader() l = dl.read(testdata[0]) l2 = dl.read(testdata[1]) l3 = dl.read(testdata[2]) ml = MagneticLine() # l = np.array(l) # l1 = np.kron(l, [0.5, 0.5]) # l2 = np.kron(l, [1, 1]) # l3 = np.kron(l, [1.5, 1.5]) # l2 = np.array(l2) # l2 = np.kron(l2, [1,2]) ml.addLine(l, "a0") # ml.addLine(l1, "a1") ml.addLine(l2, "a1") ml.addLine(l3, "b0") ml.show()
def testGraphing(): testdata = config.data['datafile']['test'] dl = DataLoader() l = dl.read(testdata[0]) l2 = dl.read(testdata[1]) l3 = dl.read(testdata[2]) ml = MagneticLine() dist, path = dtwDistance(l, l2) lineData = dtwExtend(l2, path) print path # l = np.array(l) # l1 = np.kron(l, [0.5, 0.5]) # l2 = np.kron(l, [1, 1]) # l3 = np.kron(l, [1.5, 1.5]) # l2 = np.array(l2) # l2 = np.kron(l2, [1,2]) ml.addLine(l, "a0") # ml.addLine(l1, "a1") ml.addLine(l2, "a1") ml.addLine(lineData, "b0") ml.show()
def main(): loader = DataLoader() data = loader.read(config.data["datafile"]["test"][0]) context = zmq.Context() publisher = context.socket(zmq.REQ) publisher.connect("tcp://127.0.0.1:9988") index = 20 path_particles_count = len(data) while True: currPos = float(index) / path_particles_count * 18.18 publisher.send(json.dumps({"data": data[index - 5 : index], "id": 1, "currPos": currPos})) recv = publisher.recv() print json.loads(recv) time.sleep(0.5) index += 5
from config.Config import config from data.DataLoader import DataLoader from algorithm.Dtw import dtwCalculate testdatafilename = config.data['datafile']['test'] dl = DataLoader() line1 = dl.read(testdatafilename[0]) sub = line1[100:105] dist, position= dtwCalculate(sub, line1)
def loadFileGraph(self, filename): filepath = './data/' + filename if os.path.isfile(filepath): loader = DataLoader() self.setLine(loader.read(filepath)) self.draw()