def __init__(self, data, window_size_value, window_size_unit, stepper_size, stepper_unit, shift, mark_last_segment=False): super(__SteppedDataVectorSegmenter__, self).__init__(data, window_size_value, window_size_unit, shift, mark_last_segment) self.__stepper_size__ = stepper_size #a flag which marks that a stepper is a simple bit's stepper self.__bits_stepper__ = False if (not self.window_size_unit == None and stepper_unit == None) \ or (self.window_size_unit == None and not stepper_unit == None): raise Exception( 'Window size and stepper size must have both a unit or be without a unit !!!' ) # @IgnorePep8 if stepper_unit: step_unit = get_time_unit(stepper_unit) if not step_unit: raise Exception('Unknown stepper size unit !!! [%s]' % stepper_unit) # @IgnorePep8 multiplier = step_unit.expressInUnit(self.data.signal_unit) self.__step_size_in_signal_unit__ = multiplier * self.__stepper_size__ # @IgnorePep8 else: self.__step_size_in_signal_unit__ = self.__stepper_size__ sum_signal = np.sum(self.data.time_signal) if self.__step_size_in_signal_unit__ > sum_signal: raise Exception('The step size is greater then the signal size !!!' ) # @IgnorePep8 if self.window_size_unit == None and stepper_unit == None: #this means very simple situation when a signal is divided by #self.window_size_value number bits and for this reason #stepped signal size is the same as the signal size itself self.__stepped_signal_size__ = self.signal_size self.__bits_stepper__ = True else: #this creates a list of increased values which differ by #self.__step_size_in_signal_unit__ value #or in other words this is a partition of interval of sum_signal #length by a segment of self.__step_size_in_signal_unit__ length self.__stepped_data__ = np.arange( 0, sum_signal, self.__step_size_in_signal_unit__) self.__stepped_signal_size__ = len(self.__stepped_data__) self.__cumsum_data__ = np.cumsum(self.data.time_signal) self.__stepper_index__ = 0 self.__index_stop_old__ = None
def __init__( self, data, window_size_value, window_size_unit, stepper_size, stepper_unit, shift, mark_last_segment=False ): super(__SteppedDataVectorSegmenter__, self).__init__( data, window_size_value, window_size_unit, shift, mark_last_segment ) self.__stepper_size__ = stepper_size # a flag which marks that a stepper is a simple bit's stepper self.__bits_stepper__ = False if (not self.window_size_unit == None and stepper_unit == None) or ( self.window_size_unit == None and not stepper_unit == None ): raise Exception( "Window size and stepper size must have both a unit or be without a unit !!!" ) # @IgnorePep8 if stepper_unit: step_unit = get_time_unit(stepper_unit) if not step_unit: raise Exception("Unknown stepper size unit !!! [%s]" % stepper_unit) # @IgnorePep8 multiplier = step_unit.expressInUnit(self.data.signal_unit) self.__step_size_in_signal_unit__ = multiplier * self.__stepper_size__ # @IgnorePep8 else: self.__step_size_in_signal_unit__ = self.__stepper_size__ sum_signal = np.sum(self.data.time_signal) if self.__step_size_in_signal_unit__ > sum_signal: raise Exception("The step size is greater then the signal size !!!") # @IgnorePep8 if self.window_size_unit == None and stepper_unit == None: # this means very simple situation when a signal is divided by # self.window_size_value number bits and for this reason # stepped signal size is the same as the signal size itself self.__stepped_signal_size__ = self.signal_size self.__bits_stepper__ = True else: # this creates a list of increased values which differ by # self.__step_size_in_signal_unit__ value # or in other words this is a partition of interval of sum_signal # length by a segment of self.__step_size_in_signal_unit__ length self.__stepped_data__ = np.arange(0, sum_signal, self.__step_size_in_signal_unit__) self.__stepped_signal_size__ = len(self.__stepped_data__) self.__cumsum_data__ = np.cumsum(self.data.time_signal) self.__stepper_index__ = 0 self.__index_stop_old__ = None
def __init__(self, data, window_size_value, window_size_unit, shift=1, mark_last_segment=False): super(__DataVectorSegmenter__, self).__init__(data, window_size_value=window_size_value, window_size_unit=window_size_unit, shift=shift, mark_last_segment=mark_last_segment) if self.window_size_unit: #get time unit of window size self.window_unit = get_time_unit(self.window_size_unit) if not self.window_unit: raise Exception('Unknown window size unit !!! [' + self.window_size_unit + ']') if self.window_unit: #calculate multiplier of conversion between data signal unit #and window size unit multiplier = self.window_unit.expressInUnit(self.data.signal_unit) self.window_size_in_signal_unit = multiplier * self.window_size_value # @IgnorePep8 if not self.data.time == None: #get an array of indexes where time period of an item is #greater than data window size, in this case further processing #is stopped indexes = np.where( self.data.time > self.window_size_in_signal_unit) # @IgnorePep8 if len(indexes[0]) > 0: #raise Exception('Window size is smaller then value in time column [in %s row] !' % (indexes[0][0])) # @IgnorePep8 print( 'Window size is smaller then value in time column [in %s row]. Stop processing !' % (indexes[0][0])) # @IgnorePep8 #mark to stop further processing self.stop = True else: if self.window_size_value > len(self.data.time_signal): raise Exception( 'Poincare window size greater then signal size !!!' ) #@IgnorePep8
def __init__(self, data, window_size_value, window_size_unit, shift=1, mark_last_segment=False): super(__DataVectorSegmenter__, self).__init__( data, window_size_value=window_size_value, window_size_unit=window_size_unit, shift=shift, mark_last_segment=mark_last_segment, ) if self.window_size_unit: # get time unit of window size self.window_unit = get_time_unit(self.window_size_unit) if not self.window_unit: raise Exception("Unknown window size unit !!! [" + self.window_size_unit + "]") if self.window_unit: # calculate multiplier of conversion between data signal unit # and window size unit multiplier = self.window_unit.expressInUnit(self.data.signal_unit) self.window_size_in_signal_unit = multiplier * self.window_size_value # @IgnorePep8 if not self.data.time == None: # get an array of indexes where time period of an item is # greater than data window size, in this case further processing # is stopped indexes = np.where(self.data.time > self.window_size_in_signal_unit) # @IgnorePep8 if len(indexes[0]) > 0: # raise Exception('Window size is smaller then value in time column [in %s row] !' % (indexes[0][0])) # @IgnorePep8 print( "Window size is smaller then value in time column [in %s row]. Stop processing !" % (indexes[0][0]) ) # @IgnorePep8 # mark to stop further processing self.stop = True else: if self.window_size_value > len(self.data.time_signal): raise Exception("Poincare window size greater then signal size !!!") # @IgnorePep8