May-24-2018, 06:57 AM
Hello
im trying to manipulate a large amount of data on the form 'date,time, movement'. What i first do in the class Corrections is delete dataerrors. In the next class SunriseSunset i want to inherit these updated lists of date, time and movements to do some plotting
im trying to manipulate a large amount of data on the form 'date,time, movement'. What i first do in the class Corrections is delete dataerrors. In the next class SunriseSunset i want to inherit these updated lists of date, time and movements to do some plotting
bird=open('birds.dat','r') movements=[] date=[] time=[] for n in enumerate(bird): c=n[1].split() date.append(c[0]) time.append(c[1]) movements.append(int(c[2])) class Corrections: def __init__(self, movement,date,time): self.date=date self.movements=movements self.time=time @property def DataError (self): LN=[] for n in range(len(time)-1): LN.append(int(time[n][0:2])*24*60+int(time[n][3:5])*60+int(time[n][6:8])) for k in range(len(LN)-1): if LN[k+1]-LN[k] > 160: LN.insert(k+1,LN[k]+120) date.insert(k+1,date[k]) movements.insert(k+1,movements[k]) for n in range(0, len(movements)-1): if movements[n+1]-movements[n]>4: movements[n+1]=movements[n]+4 if movements[n+1]<movements[n]: movements[n+1]=movements[n] movements=np.diff(movements) self.date=date self.time=LN self.movements=movements class SunriseSunset(Corrections): def __init__(self, givendate, date, movements, time): self.givendate=givendate self.date=date self.movements=movements self.time=time #@property def plotting(self): D=[] T=[] M=[] for i in [i for i,x in enumerate(self.date) if x ==self.givendate]: return i for n in range (0,2161): D.append(self.date[i+n]) M.append(self.movements[i+n]) T.append(self.time[i:i+n]) return self.D, self.M, self.T print(T) print(M) plot(T,M) plt.show() S = SunriseSunset('2015-01-25', date, movements, time)