I think you need to make an instance of your class. Try this:
my_class_instance = DataAnalysis()
LogFile = my_class_instance.BasicSummary ( )
On Thu, May 8, 2008 at 7:07 AM, Richard Speaker <
[EMAIL PROTECTED]> wrote:
> 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:
>
> LogFile = self.BasicSummary ( )
> NameError: name 'self' is not defined
>
> Code looks like this:
>
> from data_decode import *
> class DataAnalysis:
>
> def PainInTheArse ( self , i , InvI ):
> """This is a filter I made to overcome
> some problems I was having with sine wave
> analysis"""
> TemporaryData = [ ]
> for a in range ( int ( InvI [ i ] ) , len ( InvI ) ):
> if a < 0:
> a = 0
> b = a + 1
> try:
> TemporaryData.append ( InvI [ a + i ] )
> if ( InvI [ b + i ] < 0 and InvI [ b + i +
> 1 ] > 0 ):
> TemporaryData.append ( InvI [ a + i
> + 1 ] )
> break
> except IndexError:
> continue
> return TemporaryData
> def GetTheInvIData ( self , InvI ):
> Function determines zero-crossing, and then
> calculates the +/- peaks to get an average """
> CurrentMaxList = [ ]
> CurrentMinList = [ ]
> for i in range ( 0 , len ( InvI ) ):
> try:
> if ( InvI [ i ] <= 0 and InvI [ i + 1 ] > 0
> ):
> TemporaryData = self. PainInTheArse
> ( i , InvI )
> BetterData = self.FilterTheBS (
> TemporaryData )
> CurrentMaxList.append ( max (
> BetterData ) )
> CurrentMinList.append ( min (
> BetterData ) )
> except IndexError:
> continue
> MeanCurrentMax = sum ( CurrentMaxList ) / len (
> CurrentMaxList )
> MeanCurrentMin = sum ( CurrentMinList ) / len (
> CurrentMinList )
> InvIPeakToPeak = MeanCurrentMax - MeanCurrentMin
> EstPeak = InvIPeakToPeak / 2
> return EstPeak
>
> def FilterTheBS ( self , TemporaryData ):
> """This is another filter I made to overcome
> some problems I was having with sine wave
> analysis"""
> BetterData = [ ]
> UselessData = [ ]
> for i in range ( 0 , len ( TemporaryData ) ):
> try:
> if TemporaryData [ i ] == TemporaryData [ i
> + 1 ]:
> UselessData.append ( TemporaryData
> [ i ] )
> else:
> BetterData.append ( TemporaryData [
> i ] )
> except IndexError:
> BetterData.append ( TemporaryData [ i ] )
> continue
> return BetterData
> def BasicSummary ( self ):
>
> DDC = DecodeData( )
> try:
> MeanCurrent_A = float ( ( self.GetTheInvIData (
> DDC.InvIa ) ) )
> MeanCurrent_B = float ( ( self.GetTheInvIData (
> DDC.InvIb ) ) )
> MeanCurrent_C = float ( ( self.GetTheInvIData (
> DDC.InvIc ) ) )
> except ValueError:
>print'KaFlewie!'
> LogFile = []
> LogFile.append ('DEVICE CURRENT SUMMARY:\n')
> LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % (
> MeanCurrent_A ) )
> LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % (
> MeanCurrent_B ) )
>
> return LogFile
>
> LogFile = self.BasicSummary ( )
> for a in LogFile:
> print a
>
>
> any and all advice is welcome
>
> Rick
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list