blimpy/guppi.py
def read_next_data_block_int8(self):
        """ Read the next block of data and its header

        Returns: (header, data)
            header (dict): dictionary of header metadata
            data (np.array): Numpy array of data, converted into to complex64.
        """
        header, data_idx = self.read_header()
        self.file_obj.seek(data_idx)

        # Read data and reshape

        n_chan = int(header['OBSNCHAN'])
        n_pol = int(header['NPOL'])
        n_bit = int(header['NBITS'])
        n_samples = int(int(header['BLOCSIZE']) / (n_chan * n_pol * (n_bit / 8)))

        d = np.fromfile(self.file_obj, count=header['BLOCSIZE'], dtype='int8')

        # Handle 2-bit and 4-bit data
        if n_bit != 8:
            d = unpack(d, n_bit)

        d = d.reshape((n_chan, n_samples, n_pol))  # Real, imag

        if self._d_x.shape != d[..., 0:2].shape:
            self._d_x = np.ascontiguousarray(np.zeros(d[..., 0:2].shape, dtype='int8'))
            self._d_y = np.ascontiguousarray(np.zeros(d[..., 2:4].shape, dtype='int8'))

        self._d_x[:] = d[..., 0:2]
        self._d_y[:] = d[..., 2:4]
        return header, self._d_x, self._d_y
def read_next_data_block_int8(self):
        """ Read the next block of data and its header

        Returns: (header, data)
            header (dict): dictionary of header metadata
            data (np.array): Numpy array of data, converted into to complex64.
        """
        header, data_idx = self.read_header()
        self.file_obj.seek(data_idx)

        # Read data and reshape

        n_chan = int(header['OBSNCHAN'])
        n_pol = int(header['NPOL'])
        n_bit = int(header['NBITS'])
        n_samples = int(int(header['BLOCSIZE']) / (n_chan * n_pol * (n_bit / 8)))

        d = np.fromfile(self.file_obj, count=header['BLOCSIZE'], dtype='int8')

        # Handle 2-bit and 4-bit data
        if n_bit != 8:
            d = unpack(d, n_bit)

        d = d.reshape((n_chan, n_samples, n_pol))  # Real, imag

        if self._d_x.shape != d[..., 0:2].shape:
            self._d_x = np.ascontiguousarray(np.zeros(d[..., 0:2].shape, dtype='int8'))
            self._d_y = np.ascontiguousarray(np.zeros(d[..., 2:4].shape, dtype='int8'))

        self._d_x[:] = d[..., 0:2]
        self._d_y[:] = d[..., 2:4]
        return header, self._d_x, self._d_y
def read_next_data_block_int8 ( self ) : header , data_idx = self . read_header ( ) self . file_obj . seek ( data_idx ) # Read data and reshape n_chan = int ( header [ 'OBSNCHAN' ] ) n_pol = int ( header [ 'NPOL' ] ) n_bit = int ( header [ 'NBITS' ] ) n_samples = int ( int ( header [ 'BLOCSIZE' ] ) / ( n_chan * n_pol * ( n_bit / 8 ) ) ) d = np . fromfile ( self . file_obj , count = header [ 'BLOCSIZE' ] , dtype = 'int8' ) # Handle 2-bit and 4-bit data if n_bit != 8 : d = unpack ( d , n_bit ) d = d . reshape ( ( n_chan , n_samples , n_pol ) ) # Real, imag if self . _d_x . shape != d [ ... , 0 : 2 ] . shape : self . _d_x = np . ascontiguousarray ( np . zeros ( d [ ... , 0 : 2 ] . shape , dtype = 'int8' ) ) self . _d_y = np . ascontiguousarray ( np . zeros ( d [ ... , 2 : 4 ] . shape , dtype = 'int8' ) ) self . _d_x [ : ] = d [ ... , 0 : 2 ] self . _d_y [ : ] = d [ ... , 2 : 4 ] return header , self . _d_x , self . _d_y
Read the next block of data and its header

        Returns: (header, data)
            header (dict): dictionary of header metadata
            data (np.array): Numpy array of data, converted into to complex64.
Read the next block of data and its header