Esempio n. 1
0
    def __init__(self, driver_id):
        print("driver : %s created" % (driver_id))
        self.driver_id = driver_id
        self.driver_path = os.path.join(data_path, str(driver_id))
        # print self.driver_path
        trips = onlyfiles = [
            f for f in listdir(self.driver_path)
            if isfile(join(self.driver_path, f))
        ]
        self.nptrips = []
        self.nptripsdict = {}
        counter = 0
        for trip in trips:
            if trip.split('.')[1] != 'npy':
                # print "for trip %s"%trip
                tripnum = int(trip.split('.')[0])
                fn = join(self.driver_path, trip)
                data = np.genfromtxt(fn,
                                     dtype=float,
                                     delimiter=',',
                                     skip_header=1)
                data = sigut.removeRotation(data)
                data = self.augmentTripData(data, AUGMENT_TRIP_DATA)

                self.nptripsdict[tripnum] = data
                counter += 1
                # if counter == 20: break
                # print counter
                # break
        for tripnum in np.arange(1, 201):
            self.nptrips.append(self.nptripsdict[tripnum])

        self.aggregateCatData()
        def __init__(self, driver_id):
                print "driver : %s created"%(driver_id)
                self.driver_id = driver_id
                self.driver_path = os.path.join(data_path,str(driver_id))
                # print self.driver_path
                trips = onlyfiles = [ f for f in listdir(self.driver_path) if isfile(join(self.driver_path,f)) ]
                self.nptrips = []
                self.nptripsdict = {}
                counter = 0                
                for trip in trips:
                        if trip.split('.')[1] != 'npy':
                            # print "for trip %s"%trip
                            tripnum = int(trip.split('.')[0])
                            fn = join(self.driver_path,trip)
                            data = np.genfromtxt(fn, dtype=float, delimiter=',', skip_header=1)
                            data = sigut.removeRotation(data)
                            data = self.augmentTripData(data, AUGMENT_TRIP_DATA)
                            
                            self.nptripsdict[tripnum] = data                        
                            counter += 1
                            # if counter == 20: break
                            # print counter
                            # break
                for tripnum in np.arange(1,201):
                        self.nptrips.append(self.nptripsdict[tripnum])

                self.aggregateCatData()
Esempio n. 3
0
    def interpAroundId(self, idtest, trip, Nsteps, nmid, samples):
        newzero = trip[idtest, :]
        # import pdb
        # pdb.set_trace()
        ndist = trip[:, self.headers['cum_d']] - newzero[self.headers['cum_d']]
        # print ndist[idtest]

        res = np.zeros((Nsteps, 2), dtype=np.float)
        res[:, 0] = np.interp(samples, ndist, trip[:, self.headers['x']])
        res[:, 1] = np.interp(samples, ndist, trip[:, self.headers['y']])
        # res[:,2] = np.interp(samples,  ndist, trip[:,4])
        res = sigut.removeRotation(res, removeBias=True)
        shifted = -res[:, 1]
        res = np.c_[res, shifted]

        return res
        def interpAroundId(     self, idtest, trip, Nsteps, nmid, samples):
                newzero = trip[idtest,:]        
                # import pdb
                # pdb.set_trace()       
                ndist = trip[:, self.headers['cum_d']] - newzero[self.headers['cum_d']]
                # print ndist[idtest]

                res = np.zeros((Nsteps, 2), dtype=np.float)
                res[:,0] = np.interp(samples,  ndist, trip[:,self.headers['x']])
                res[:,1] = np.interp(samples,  ndist, trip[:,self.headers['y']])
                # res[:,2] = np.interp(samples,  ndist, trip[:,4])
                res = sigut.removeRotation(res, removeBias=True)
                shifted = -res[:,1]
                res = np.c_[res, shifted]

                return res