""" Analysis class """ import numpy as np import pandas as pd import matplotlib as plt class Analysis: def __init__(self, angles): # Better to put in Pandas dataframe self.xAngles = pd.Series({'High' : angles[0][0], 'Low' : angles[0][1],}) self.yAngles = pd.Series({'High' : angles[1][0], 'Low' : angles[1][1]}) self.results = pd.DataFrame({'Mean' : np.zeros(2), 'Error': np.zeros(2)}) #TODO: Determine mean and std self.rmNone() self.Angles(self.xAngles['High'], self.xAngles['Low'], call=0) self.Angles(self.yAngles['High'], self.yAngles['Low'], call=1) #TODO: Plot def rmNone(self): self.xAngles['High'] = np.array([x for x in self.xAngles['High'] if x is not None]) self.xAngles['Low'] = np.array([x for x in self.xAngles['Low'] if x is not None]) self.yAngles['High'] = np.array([x for x in self.yAngles['High'] if x is not None]) self.yAngles['Low'] = np.array([x for x in self.yAngles['Low'] if x is not None]) def Angles(self, high, low, call=0): highRev = high[::-1] lowRev = low[::-1] highBound = highRev[0] lowBound = lowRev[0] print(highBound,lowBound) for a,b in zip(highRev[1:], lowRev[1:]): if a < highBound and a > lowBound: highBound = a if b < highBound and b > lowBound: lowBound = b error = (highBound - lowBound)/2 mean = highBound - error self.results['Mean'][call] = mean self.results['Error'][call] = error def Plot(self): ... if __name__ == "__main__": high = np.array([6,8,7,10,None]) low = np.array([5,4,1,3,None]) ''' a = pd.DataFrame({'H' : high}) a['H'] = np.array([x for x in a['H'] if x is not None]) print(a['H']) ''' angles = [[high, low], [high, low]] A = Analysis(angles) print(A.results)