def histogram(self, number_concentration=True):
        """Read and reset the histogram. As of v1.3.0, histogram
        values are reported in particle number concentration (#/cc) by default.

        :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values.

        :type number_concentration: boolean

        :rtype: dictionary

        :Example:

        >>> alpha.histogram()
        {
            'Temperature': None,
            'Pressure': None,
            'Bin 0': 0,
            'Bin 1': 0,
            'Bin 2': 0,
            ...
            'Bin 15': 0,
            'SFR': 3.700,
            'Bin1MToF': 0,
            'Bin3MToF': 0,
            'Bin5MToF': 0,
            'Bin7MToF': 0,
            'PM1': 0.0,
            'PM2.5': 0.0,
            'PM10': 0.0,
            'Sampling Period': 2.345,
            'Checksum': 0
        }
        """
        resp = []
        data = {}

        # Send the command byte
        self.cnxn.xfer([0x30])

        # Wait 10 ms
        sleep(10e-3)

        # read the histogram
        for i in range(62):
            r = self.cnxn.xfer([0x00])[0]
            resp.append(r)

        # convert to real things and store in dictionary!
        data['Bin 0']           = self._16bit_unsigned(resp[0], resp[1])
        data['Bin 1']           = self._16bit_unsigned(resp[2], resp[3])
        data['Bin 2']           = self._16bit_unsigned(resp[4], resp[5])
        data['Bin 3']           = self._16bit_unsigned(resp[6], resp[7])
        data['Bin 4']           = self._16bit_unsigned(resp[8], resp[9])
        data['Bin 5']           = self._16bit_unsigned(resp[10], resp[11])
        data['Bin 6']           = self._16bit_unsigned(resp[12], resp[13])
        data['Bin 7']           = self._16bit_unsigned(resp[14], resp[15])
        data['Bin 8']           = self._16bit_unsigned(resp[16], resp[17])
        data['Bin 9']           = self._16bit_unsigned(resp[18], resp[19])
        data['Bin 10']          = self._16bit_unsigned(resp[20], resp[21])
        data['Bin 11']          = self._16bit_unsigned(resp[22], resp[23])
        data['Bin 12']          = self._16bit_unsigned(resp[24], resp[25])
        data['Bin 13']          = self._16bit_unsigned(resp[26], resp[27])
        data['Bin 14']          = self._16bit_unsigned(resp[28], resp[29])
        data['Bin 15']          = self._16bit_unsigned(resp[30], resp[31])
        data['Bin1 MToF']       = self._calculate_mtof(resp[32])
        data['Bin3 MToF']       = self._calculate_mtof(resp[33])
        data['Bin5 MToF']       = self._calculate_mtof(resp[34])
        data['Bin7 MToF']       = self._calculate_mtof(resp[35])

        # Bins associated with firmware versions 14 and 15(?)
        if self.firmware['version'] < 16.:
            data['Temperature']     = self._calculate_temp(resp[36:40])
            data['Pressure']        = self._calculate_pressure(resp[40:44])
            data['Sampling Period'] = self._calculate_period(resp[44:48])
            data['Checksum']        = self._16bit_unsigned(resp[48], resp[49])
            data['PM1']             = self._calculate_float(resp[50:54])
            data['PM2.5']           = self._calculate_float(resp[54:58])
            data['PM10']            = self._calculate_float(resp[58:])

        else:
            data['SFR']             = self._calculate_float(resp[36:40])

            # Alright, we don't know whether it is temp or pressure since it switches..
            tmp = self._calculate_pressure(resp[40:44])
            if tmp > 98000:
                data['Temperature'] = None
                data['Pressure']    = tmp
            else:
                tmp = self._calculate_temp(resp[40:44])
                if tmp < 500:
                    data['Temperature'] = tmp
                    data['Pressure']    = None
                else:
                    data['Temperature'] = None
                    data['Pressure']    = None

            data['Sampling Period'] = self._calculate_float(resp[44:48])
            data['Checksum']        = self._16bit_unsigned(resp[48], resp[49])
            data['PM1']             = self._calculate_float(resp[50:54])
            data['PM2.5']           = self._calculate_float(resp[54:58])
            data['PM10']            = self._calculate_float(resp[58:])

        # Calculate the sum of the histogram bins
        histogram_sum = data['Bin 0'] + data['Bin 1'] + data['Bin 2']   + \
                data['Bin 3'] + data['Bin 4'] + data['Bin 5'] + data['Bin 6']   + \
                data['Bin 7'] + data['Bin 8'] + data['Bin 9'] + data['Bin 10']  + \
                data['Bin 11'] + data['Bin 12'] + data['Bin 13'] + data['Bin 14'] + \
                data['Bin 15']

        # Check that checksum and the least significant bits of the sum of histogram bins
        # are equivilant
        if (histogram_sum & 0x0000FFFF) != data['Checksum']:
            logger.warning("Data transfer was incomplete")
            return None

        # If histogram is true, convert histogram values to number concentration
        if number_concentration is True:
            _conv_ = data['SFR'] * data['Sampling Period'] # Divider in units of ml (cc)

            data['Bin 0']   = data['Bin 0'] / _conv_
            data['Bin 1']   = data['Bin 1'] / _conv_
            data['Bin 2']   = data['Bin 2'] / _conv_
            data['Bin 3']   = data['Bin 3'] / _conv_
            data['Bin 4']   = data['Bin 4'] / _conv_
            data['Bin 5']   = data['Bin 5'] / _conv_
            data['Bin 6']   = data['Bin 6'] / _conv_
            data['Bin 7']   = data['Bin 7'] / _conv_
            data['Bin 8']   = data['Bin 8'] / _conv_
            data['Bin 9']   = data['Bin 9'] / _conv_
            data['Bin 10']  = data['Bin 10'] / _conv_
            data['Bin 11']  = data['Bin 11'] / _conv_
            data['Bin 12']  = data['Bin 12'] / _conv_
            data['Bin 13']  = data['Bin 13'] / _conv_
            data['Bin 14']  = data['Bin 14'] / _conv_
            data['Bin 15']  = data['Bin 15'] / _conv_

        sleep(0.1)

        return data
def histogram(self, number_concentration=True):
        """Read and reset the histogram. As of v1.3.0, histogram
        values are reported in particle number concentration (#/cc) by default.

        :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values.

        :type number_concentration: boolean

        :rtype: dictionary

        :Example:

        >>> alpha.histogram()
        {
            'Temperature': None,
            'Pressure': None,
            'Bin 0': 0,
            'Bin 1': 0,
            'Bin 2': 0,
            ...
            'Bin 15': 0,
            'SFR': 3.700,
            'Bin1MToF': 0,
            'Bin3MToF': 0,
            'Bin5MToF': 0,
            'Bin7MToF': 0,
            'PM1': 0.0,
            'PM2.5': 0.0,
            'PM10': 0.0,
            'Sampling Period': 2.345,
            'Checksum': 0
        }
        """
        resp = []
        data = {}

        # Send the command byte
        self.cnxn.xfer([0x30])

        # Wait 10 ms
        sleep(10e-3)

        # read the histogram
        for i in range(62):
            r = self.cnxn.xfer([0x00])[0]
            resp.append(r)

        # convert to real things and store in dictionary!
        data['Bin 0']           = self._16bit_unsigned(resp[0], resp[1])
        data['Bin 1']           = self._16bit_unsigned(resp[2], resp[3])
        data['Bin 2']           = self._16bit_unsigned(resp[4], resp[5])
        data['Bin 3']           = self._16bit_unsigned(resp[6], resp[7])
        data['Bin 4']           = self._16bit_unsigned(resp[8], resp[9])
        data['Bin 5']           = self._16bit_unsigned(resp[10], resp[11])
        data['Bin 6']           = self._16bit_unsigned(resp[12], resp[13])
        data['Bin 7']           = self._16bit_unsigned(resp[14], resp[15])
        data['Bin 8']           = self._16bit_unsigned(resp[16], resp[17])
        data['Bin 9']           = self._16bit_unsigned(resp[18], resp[19])
        data['Bin 10']          = self._16bit_unsigned(resp[20], resp[21])
        data['Bin 11']          = self._16bit_unsigned(resp[22], resp[23])
        data['Bin 12']          = self._16bit_unsigned(resp[24], resp[25])
        data['Bin 13']          = self._16bit_unsigned(resp[26], resp[27])
        data['Bin 14']          = self._16bit_unsigned(resp[28], resp[29])
        data['Bin 15']          = self._16bit_unsigned(resp[30], resp[31])
        data['Bin1 MToF']       = self._calculate_mtof(resp[32])
        data['Bin3 MToF']       = self._calculate_mtof(resp[33])
        data['Bin5 MToF']       = self._calculate_mtof(resp[34])
        data['Bin7 MToF']       = self._calculate_mtof(resp[35])

        # Bins associated with firmware versions 14 and 15(?)
        if self.firmware['version'] < 16.:
            data['Temperature']     = self._calculate_temp(resp[36:40])
            data['Pressure']        = self._calculate_pressure(resp[40:44])
            data['Sampling Period'] = self._calculate_period(resp[44:48])
            data['Checksum']        = self._16bit_unsigned(resp[48], resp[49])
            data['PM1']             = self._calculate_float(resp[50:54])
            data['PM2.5']           = self._calculate_float(resp[54:58])
            data['PM10']            = self._calculate_float(resp[58:])

        else:
            data['SFR']             = self._calculate_float(resp[36:40])

            # Alright, we don't know whether it is temp or pressure since it switches..
            tmp = self._calculate_pressure(resp[40:44])
            if tmp > 98000:
                data['Temperature'] = None
                data['Pressure']    = tmp
            else:
                tmp = self._calculate_temp(resp[40:44])
                if tmp < 500:
                    data['Temperature'] = tmp
                    data['Pressure']    = None
                else:
                    data['Temperature'] = None
                    data['Pressure']    = None

            data['Sampling Period'] = self._calculate_float(resp[44:48])
            data['Checksum']        = self._16bit_unsigned(resp[48], resp[49])
            data['PM1']             = self._calculate_float(resp[50:54])
            data['PM2.5']           = self._calculate_float(resp[54:58])
            data['PM10']            = self._calculate_float(resp[58:])

        # Calculate the sum of the histogram bins
        histogram_sum = data['Bin 0'] + data['Bin 1'] + data['Bin 2']   + \
                data['Bin 3'] + data['Bin 4'] + data['Bin 5'] + data['Bin 6']   + \
                data['Bin 7'] + data['Bin 8'] + data['Bin 9'] + data['Bin 10']  + \
                data['Bin 11'] + data['Bin 12'] + data['Bin 13'] + data['Bin 14'] + \
                data['Bin 15']

        # Check that checksum and the least significant bits of the sum of histogram bins
        # are equivilant
        if (histogram_sum & 0x0000FFFF) != data['Checksum']:
            logger.warning("Data transfer was incomplete")
            return None

        # If histogram is true, convert histogram values to number concentration
        if number_concentration is True:
            _conv_ = data['SFR'] * data['Sampling Period'] # Divider in units of ml (cc)

            data['Bin 0']   = data['Bin 0'] / _conv_
            data['Bin 1']   = data['Bin 1'] / _conv_
            data['Bin 2']   = data['Bin 2'] / _conv_
            data['Bin 3']   = data['Bin 3'] / _conv_
            data['Bin 4']   = data['Bin 4'] / _conv_
            data['Bin 5']   = data['Bin 5'] / _conv_
            data['Bin 6']   = data['Bin 6'] / _conv_
            data['Bin 7']   = data['Bin 7'] / _conv_
            data['Bin 8']   = data['Bin 8'] / _conv_
            data['Bin 9']   = data['Bin 9'] / _conv_
            data['Bin 10']  = data['Bin 10'] / _conv_
            data['Bin 11']  = data['Bin 11'] / _conv_
            data['Bin 12']  = data['Bin 12'] / _conv_
            data['Bin 13']  = data['Bin 13'] / _conv_
            data['Bin 14']  = data['Bin 14'] / _conv_
            data['Bin 15']  = data['Bin 15'] / _conv_

        sleep(0.1)

        return data
def histogram ( self , number_concentration = True ) : resp = [ ] data = { } # Send the command byte self . cnxn . xfer ( [ 0x30 ] ) # Wait 10 ms sleep ( 10e-3 ) # read the histogram for i in range ( 62 ) : r = self . cnxn . xfer ( [ 0x00 ] ) [ 0 ] resp . append ( r ) # convert to real things and store in dictionary! data [ 'Bin 0' ] = self . _16bit_unsigned ( resp [ 0 ] , resp [ 1 ] ) data [ 'Bin 1' ] = self . _16bit_unsigned ( resp [ 2 ] , resp [ 3 ] ) data [ 'Bin 2' ] = self . _16bit_unsigned ( resp [ 4 ] , resp [ 5 ] ) data [ 'Bin 3' ] = self . _16bit_unsigned ( resp [ 6 ] , resp [ 7 ] ) data [ 'Bin 4' ] = self . _16bit_unsigned ( resp [ 8 ] , resp [ 9 ] ) data [ 'Bin 5' ] = self . _16bit_unsigned ( resp [ 10 ] , resp [ 11 ] ) data [ 'Bin 6' ] = self . _16bit_unsigned ( resp [ 12 ] , resp [ 13 ] ) data [ 'Bin 7' ] = self . _16bit_unsigned ( resp [ 14 ] , resp [ 15 ] ) data [ 'Bin 8' ] = self . _16bit_unsigned ( resp [ 16 ] , resp [ 17 ] ) data [ 'Bin 9' ] = self . _16bit_unsigned ( resp [ 18 ] , resp [ 19 ] ) data [ 'Bin 10' ] = self . _16bit_unsigned ( resp [ 20 ] , resp [ 21 ] ) data [ 'Bin 11' ] = self . _16bit_unsigned ( resp [ 22 ] , resp [ 23 ] ) data [ 'Bin 12' ] = self . _16bit_unsigned ( resp [ 24 ] , resp [ 25 ] ) data [ 'Bin 13' ] = self . _16bit_unsigned ( resp [ 26 ] , resp [ 27 ] ) data [ 'Bin 14' ] = self . _16bit_unsigned ( resp [ 28 ] , resp [ 29 ] ) data [ 'Bin 15' ] = self . _16bit_unsigned ( resp [ 30 ] , resp [ 31 ] ) data [ 'Bin1 MToF' ] = self . _calculate_mtof ( resp [ 32 ] ) data [ 'Bin3 MToF' ] = self . _calculate_mtof ( resp [ 33 ] ) data [ 'Bin5 MToF' ] = self . _calculate_mtof ( resp [ 34 ] ) data [ 'Bin7 MToF' ] = self . _calculate_mtof ( resp [ 35 ] ) # Bins associated with firmware versions 14 and 15(?) if self . firmware [ 'version' ] < 16. : data [ 'Temperature' ] = self . _calculate_temp ( resp [ 36 : 40 ] ) data [ 'Pressure' ] = self . _calculate_pressure ( resp [ 40 : 44 ] ) data [ 'Sampling Period' ] = self . _calculate_period ( resp [ 44 : 48 ] ) data [ 'Checksum' ] = self . _16bit_unsigned ( resp [ 48 ] , resp [ 49 ] ) data [ 'PM1' ] = self . _calculate_float ( resp [ 50 : 54 ] ) data [ 'PM2.5' ] = self . _calculate_float ( resp [ 54 : 58 ] ) data [ 'PM10' ] = self . _calculate_float ( resp [ 58 : ] ) else : data [ 'SFR' ] = self . _calculate_float ( resp [ 36 : 40 ] ) # Alright, we don't know whether it is temp or pressure since it switches.. tmp = self . _calculate_pressure ( resp [ 40 : 44 ] ) if tmp > 98000 : data [ 'Temperature' ] = None data [ 'Pressure' ] = tmp else : tmp = self . _calculate_temp ( resp [ 40 : 44 ] ) if tmp < 500 : data [ 'Temperature' ] = tmp data [ 'Pressure' ] = None else : data [ 'Temperature' ] = None data [ 'Pressure' ] = None data [ 'Sampling Period' ] = self . _calculate_float ( resp [ 44 : 48 ] ) data [ 'Checksum' ] = self . _16bit_unsigned ( resp [ 48 ] , resp [ 49 ] ) data [ 'PM1' ] = self . _calculate_float ( resp [ 50 : 54 ] ) data [ 'PM2.5' ] = self . _calculate_float ( resp [ 54 : 58 ] ) data [ 'PM10' ] = self . _calculate_float ( resp [ 58 : ] ) # Calculate the sum of the histogram bins histogram_sum = data [ 'Bin 0' ] + data [ 'Bin 1' ] + data [ 'Bin 2' ] + data [ 'Bin 3' ] + data [ 'Bin 4' ] + data [ 'Bin 5' ] + data [ 'Bin 6' ] + data [ 'Bin 7' ] + data [ 'Bin 8' ] + data [ 'Bin 9' ] + data [ 'Bin 10' ] + data [ 'Bin 11' ] + data [ 'Bin 12' ] + data [ 'Bin 13' ] + data [ 'Bin 14' ] + data [ 'Bin 15' ] # Check that checksum and the least significant bits of the sum of histogram bins # are equivilant if ( histogram_sum & 0x0000FFFF ) != data [ 'Checksum' ] : logger . warning ( "Data transfer was incomplete" ) return None # If histogram is true, convert histogram values to number concentration if number_concentration is True : _conv_ = data [ 'SFR' ] * data [ 'Sampling Period' ] # Divider in units of ml (cc) data [ 'Bin 0' ] = data [ 'Bin 0' ] / _conv_ data [ 'Bin 1' ] = data [ 'Bin 1' ] / _conv_ data [ 'Bin 2' ] = data [ 'Bin 2' ] / _conv_ data [ 'Bin 3' ] = data [ 'Bin 3' ] / _conv_ data [ 'Bin 4' ] = data [ 'Bin 4' ] / _conv_ data [ 'Bin 5' ] = data [ 'Bin 5' ] / _conv_ data [ 'Bin 6' ] = data [ 'Bin 6' ] / _conv_ data [ 'Bin 7' ] = data [ 'Bin 7' ] / _conv_ data [ 'Bin 8' ] = data [ 'Bin 8' ] / _conv_ data [ 'Bin 9' ] = data [ 'Bin 9' ] / _conv_ data [ 'Bin 10' ] = data [ 'Bin 10' ] / _conv_ data [ 'Bin 11' ] = data [ 'Bin 11' ] / _conv_ data [ 'Bin 12' ] = data [ 'Bin 12' ] / _conv_ data [ 'Bin 13' ] = data [ 'Bin 13' ] / _conv_ data [ 'Bin 14' ] = data [ 'Bin 14' ] / _conv_ data [ 'Bin 15' ] = data [ 'Bin 15' ] / _conv_ sleep ( 0.1 ) return data
Read and reset the histogram. As of v1.3.0, histogram
        values are reported in particle number concentration (#/cc) by default.

        :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values.

        :type number_concentration: boolean

        :rtype: dictionary

        :Example:

        >>> alpha.histogram()
        {
            'Temperature': None,
            'Pressure': None,
            'Bin 0': 0,
            'Bin 1': 0,
            'Bin 2': 0,
            ...
            'Bin 15': 0,
            'SFR': 3.700,
            'Bin1MToF': 0,
            'Bin3MToF': 0,
            'Bin5MToF': 0,
            'Bin7MToF': 0,
            'PM1': 0.0,
            'PM2.5': 0.0,
            'PM10': 0.0,
            'Sampling Period': 2.345,
            'Checksum': 0
        }
Read and reset the histogram . As of v1 . 3 . 0 histogram values are reported in particle number concentration ( # / cc ) by default .