def init(self, args): Intercom_empty.init(self, args) zeros = np.zeros(self.frames_per_chunk) coeffs = wt.wavedec(zeros, wavelet=wavelet, level=levels, mode=padding) arr, self.coeffs_slices = wt.coeffs_to_array(coeffs)
def init(self, args): Intercom_empty.init(self, args) self.skipped_bitplanes = [0]*self.cells_in_buffer # Number of levels of the DWT levels = 4 # Wavelet used Biorthogonal 3.5 #Referencia http://wavelets.pybytes.com/wavelet/bior3.5/ wavelet = 'bior3.5' #padding = "symmetric" padding = "periodization"
def init(self, args): Intercom_empty.init(self, args) self.precision_bits = 32 self.precision_type = np.int32 self.number_of_bitplanes_to_send = self.precision_bits * self.number_of_channels print("{}".format(self.number_of_bitplanes_to_send)) print("intercom_bitplanes: transmitting by bitplanes") self.max_number_of_bitplanes_to_send = self.number_of_bitplanes_to_send self.number_of_received_bitplanes = self.max_number_of_bitplanes_to_send self.levels = 4 # Number of levels of the DWT self.wavelet = 'bior3.5' # Wavelet Biorthogonal 3.5 self.padding = "periodization" # Signal extension procedure used in self.get_coeffs_bitplanes()
def init(self, args): Intercom_empty.init(self, args) self.samples = 0 #Create empty chunk for slice calcultation empty_channel = np.zeros(self.frames_per_chunk + overlap) #Calc coefficient of empty chunk self.coeffs_empty = wt.wavedec(empty_channel, wavelet=wavelet, level=levels, mode=padding) #Calc coefficient array and slice structure self.arr_empty, self.slice_structure = wt.coeffs_to_array( self.coeffs_empty) #Create empty coefficient array buffer self._buffer_coeffs = [None] * self.cells_in_buffer for i in range(self.cells_in_buffer): self._buffer_coeffs[i] = self.generate_zero_arr() #Set variables for previous, current and next chunk for considering overlapping samples self._last = self.generate_zero_chunk() self._current = self.generate_zero_chunk() self._next = self.generate_zero_chunk() #Increase max bitplanes to 64 (2 channels) self.max_NOBPTS = 32 * self.number_of_channels self.NOBPTS = self.max_NOBPTS self.NORB = self.max_NOBPTS #Create empty coefficiente array as template self.arr_temp = np.zeros((len(self.arr_empty), 2), dtype=np.int32) #Set packet size depending on overlapping bitplanes if (overlap > 0): self.packet_format = f"!HBB{(len(self.arr_empty)//8)+1}B" else: self.packet_format = f"!HBB{(len(self.arr_empty)//8)}B" #Some status messages for development #sys.stderr.write("\nFPC{}".format(self.frames_per_chunk)); sys.stderr.flush() #sys.stderr.write("\nFPCMAS{}".format(self.frames_per_chunk + overlap)); sys.stderr.flush() #sys.stderr.write("\nCOEFFS{}".format(len(self.coeffs_empty))); sys.stderr.flush() #sys.stderr.write("\narr_empty{}".format(self.arr_empty.shape)); sys.stderr.flush() #set buffer for skipped bitplanes self.skipped_bitplanes = [0] * self.cells_in_buffer
def init(self, args): Intercom_empty.init(self, args) self.max_NOBPTS = self.number_of_channels * 32 # Initialize an empty array for coefficients self.coeffs = pywt.wavedec(np.zeros(self.frames_per_chunk), "db1", mode="per", level=4) array, self.coeff_slices = pywt.coeffs_to_array(self.coeffs) self.buffer_send = np.zeros((len(array), 2), dtype=np.int32) self.buffer_coeffs = [None] * self.cells_in_buffer for cell in range(self.cells_in_buffer): self.buffer_coeffs[cell] = np.zeros((self.frames_per_chunk, 2), dtype=np.int32)
def init(self, args): Intercom_empty.init(self, args) #We increase the number of bitplanes to send to 32 per channel self.max_NOBPTS = 32*self.number_of_channels #We create the structure to store the coefficients zeros = np.zeros(self.frames_per_chunk) self.coeffs = pywt.wavedec(zeros, wavelet=wavelet, mode=padding, level=level) coeff_temp, self.coeff_slices = pywt.coeffs_to_array(self.coeffs) #We create the buffers to store the coefficients in their correct format self.buffer_send = np.zeros((len(coeff_temp), 2), dtype=np.int32) self.buffer_coeffs = [None]*self.cells_in_buffer for i in range(self.cells_in_buffer): self.buffer_coeffs[i] = np.zeros((self.frames_per_chunk, 2), dtype=np.int32)
def init(self, args): Intercom_empty.init(self, args) self.precision_bits = 32 self.sample_type = np.int32 self.sign_mask = (1 << (self.precision_bits - 1)) self.precision_bits_1 = self.precision_bits - 1 self.magnitude_mask = ((1 << (self.precision_bits_1)) - 1) self.number_of_bitplanes_to_send = self.precision_bits * self.number_of_channels if __debug__: print("intercom_dwt: number_of_bitplanes_to_send={}".format( self.number_of_bitplanes_to_send)) self.max_number_of_bitplanes_to_send = self.number_of_bitplanes_to_send self.number_of_received_bitplanes = self.max_number_of_bitplanes_to_send self.levels = 4 # Number of levels of the DWT self.wavelet = 'bior3.5' # Wavelet Biorthogonal 3.5 self.padding = "periodization" # Signal extension procedure used in self.slices = self.get_coeffs_slices() print("intercom_dwt: using wavelet domain \"{}\"".format(self.wavelet))
def init(self, args): Intercom_empty.init(self, args) # With wavedec we return an ordered list of coefficients arrays with the level of decomposition self.coeffs_empty = pywt.wavedec(np.zeros(self.frames_per_chunk), wavelet='db1', mode="periodization") # With coeffs_to_array we get the Wavelet transform coefficient array and a list of slices corresponding to each coefficient, # we are only using this last part arr_empty, self.slice_structure = pywt.coeffs_to_array( self.coeffs_empty) self._buffer_coeffs = [None] * self.cells_in_buffer # Auxiliar array wich will be of use later self.aux_array = np.zeros( (self.frames_per_chunk, self.number_of_channels), np.int32) for i in range(self.cells_in_buffer): self._buffer_coeffs[i] = np.zeros( (self.frames_per_chunk, self.number_of_channels), np.int32)
def init(self, args): Intercom_empty.init(self, args) self.samples = 0 self.packet_format = f"!HBB{self.frames_per_chunk//8}B" empty_channel = np.zeros(self.frames_per_chunk) self.coeffs_empty = wt.wavedec(empty_channel, wavelet=wavelet, mode=padding) #self.coeffs_empty = wt.wavedec(empty_channel, wavelet=wavelet, level=levels, mode=padding) arr_empty, self.slice_structure = wt.coeffs_to_array(self.coeffs_empty) #self._buffer = [self.generate_zero_chunk()] * self.cells_in_buffer self._buffer_coeffs = [None] * self.cells_in_buffer self.max_NOBPTS = 32 * self.number_of_channels self.NOBPTS = self.max_NOBPTS self.NORB = self.max_NOBPTS self.arr_temp = np.zeros( (self.frames_per_chunk, self.number_of_channels), np.int32) for i in range(self.cells_in_buffer): self._buffer_coeffs[i] = self.generate_zero_arr()
def init(self, args): Intercom_empty.init(self, args) self.packet_format = f"!HH{self.frames_per_chunk//8}HH" self.zeros = 0
def init(self, args): Intercom_empty.init(self, args)