<div>I'm somewhat new to Python... and programming in general. I know enough to be dangerous for sure. I have a feeling the solution to this is simple. I'm having trouble getting 'self' to initialize or work in a class application. I keep getting the message:</div> <div> </div> <div> LogFile = self.BasicSummary ( )<BR>NameError: name 'self' is not defined</div> <div> </div> <div>Code looks like this:</div> <div> </div> <div>from data_decode import *</div> <div>class DataAnalysis:<BR> <BR> def PainInTheArse ( self , i , InvI ):<BR> """This is a filter I made to overcome<BR> some problems I was having with sine
wave<BR> analysis"""<BR> TemporaryData = [ ]<BR> for a in range ( int ( InvI [ i ] ) , len ( InvI ) ):<BR> if a < 0:<BR> a = 0<BR> b = a +
1<BR> try:<BR> TemporaryData.append ( InvI [ a + i ] )<BR> if ( InvI [ b + i ] < 0 and InvI [ b + i + 1 ] > 0 ):<BR> TemporaryData.append ( InvI [ a + i + 1 ]
)<BR> break<BR> except IndexError:<BR> continue<BR> return TemporaryData</div> <div> def GetTheInvIData ( self , InvI ):</div> <div> """"Function determines zero-crossing, and
then<BR> calculates the +/- peaks to get an average """<BR> CurrentMaxList = [ ]<BR> CurrentMinList = [ ]<BR> for i in range ( 0 , len ( InvI ) ):<BR> try:<BR> if ( InvI [ i ] <= 0 and InvI [ i + 1 ] > 0
):<BR> TemporaryData = self. PainInTheArse ( i , InvI )<BR> BetterData = self.FilterTheBS ( TemporaryData )<BR> CurrentMaxList.append ( max ( BetterData )
)<BR> CurrentMinList.append ( min ( BetterData ) )<BR> except IndexError: <BR> continue</div> <div> MeanCurrentMax = sum ( CurrentMaxList ) / len ( CurrentMaxList
)<BR> MeanCurrentMin = sum ( CurrentMinList ) / len ( CurrentMinList )<BR> InvIPeakToPeak = MeanCurrentMax - MeanCurrentMin<BR> EstPeak = InvIPeakToPeak / 2<BR> return EstPeak</div> <div> </div> <div> def FilterTheBS ( self , TemporaryData ):<BR> """This is another filter I made to overcome<BR> some problems I was having with sine
wave<BR> analysis"""<BR> BetterData = [ ]<BR> UselessData = [ ]<BR> for i in range ( 0 , len ( TemporaryData ) ):<BR> try:<BR> if TemporaryData [ i ] == TemporaryData [ i + 1
]:<BR> UselessData.append ( TemporaryData [ i ] )<BR> else:<BR> BetterData.append ( TemporaryData [ i ] )<BR> except
IndexError:<BR> BetterData.append ( TemporaryData [ i ] )<BR> continue<BR> return BetterData</div> <div> def BasicSummary ( self ):<BR> <BR> DDC = DecodeData( )</div> <div> try:</div>
<div> MeanCurrent_A = float ( ( self.GetTheInvIData ( DDC.InvIa ) ) )<BR> MeanCurrent_B = float ( ( self.GetTheInvIData ( DDC.InvIb ) ) )<BR> MeanCurrent_C = float ( ( self.GetTheInvIData ( DDC.InvIc ) ) )<BR> except ValueError:<BR> print'KaFlewie!'<BR> LogFile = []<BR> LogFile.append ('DEVICE CURRENT
SUMMARY:\n')<BR> LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % ( MeanCurrent_A ) )<BR> LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % ( MeanCurrent_B ) )<BR> </div> <div> return LogFile<BR> <BR> LogFile = self.BasicSummary ( )</div> <div> for a in LogFile:<BR> print a</div> <div> <BR> <BR>any and all advice is welcome</div> <div> </div> <div>Rick</div>