#NEWLINE# def time_slice( self , t_start , t_stop ) : #NEWLINE# #INDENT# '\n        Creates a new AnalogSignal corresponding to the time slice of the\n        original AnalogSignal between times t_start, t_stop. Note, that for\n        numerical stability reasons if t_start, t_stop do not fall exactly on\n        the time bins defined by the sampling_period they will be rounded to\n        the nearest sampling bins.\n        ' #NEWLINE# if ( self is None ) : #NEWLINE# #INDENT# i = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t_start = t_start . rescale ( self . sampling_period . units ) #NEWLINE# i = ( ( t_start - self . t_start ) / self . sampling_period ) #NEWLINE# i = int ( np . rint ( i . magnitude ) ) #NEWLINE# #UNINDENT# if ( t_stop is None ) : #NEWLINE# #INDENT# j = len ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t_stop = t_stop . rescale ( self . sampling_period . units ) #NEWLINE# j = ( ( t_stop - self . t_start ) / self . sampling_period ) #NEWLINE# j = int ( np . rint ( j . magnitude ) ) #NEWLINE# #UNINDENT# if ( ( i < 0 ) or ( j > len ( self ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 't_start, t_stop have to be withing the analog                               signal duration' ) #NEWLINE# #UNINDENT# obj = super ( BaseAnalogSignal , self ) . __getitem__ ( np . arange ( i , j , 1 ) ) #NEWLINE# obj . t_start = ( self . t_start + ( i * self . sampling_period ) ) #NEWLINE# return obj