Ejemplo n.º 1
0
def pack(pqdict):
    """Pack a pixel quality dictionary into a 16-bit pixel quality value.

    Arguments:
        pqdict: pixel quality dictionary

    Returns:
         Packed pixel quality value (usually a 16-bit integer.)
    """

    return sum((v << bits.lowest_set(PQ_BITMASKS[k])) for k,v in pqdict.iteritems())
Ejemplo n.º 2
0
def unpack(pqvalue):
    """Unpack a 16-bit (integer) pixel quality value.

    Arguments:
        pqvalue: pixel quality value (usually a 16-bit integer)

    Returns:
        Dictionary containing unpacked values for each pixel quality metric.
    """

    return {k : ((pqvalue & v) >> bits.lowest_set(v)) for k,v in PQ_BITMASKS.iteritems()}
Ejemplo n.º 3
0
def pack(pqdict):
    """Pack a pixel quality dictionary into a 16-bit pixel quality value.

    Arguments:
        pqdict: pixel quality dictionary

    Returns:
         Packed pixel quality value (usually a 16-bit integer.)
    """

    return sum(
        (v << bits.lowest_set(PQ_BITMASKS[k])) for k, v in pqdict.iteritems())
Ejemplo n.º 4
0
def unpack(pqvalue):
    """Unpack a 16-bit (integer) pixel quality value.

    Arguments:
        pqvalue: pixel quality value (usually a 16-bit integer)

    Returns:
        Dictionary containing unpacked values for each pixel quality metric.
    """

    return {
        k: ((pqvalue & v) >> bits.lowest_set(v))
        for k, v in PQ_BITMASKS.iteritems()
    }
Ejemplo n.º 5
0
 def test_bitmasks(self):
     m = sum([v for v in PQ_BITMASKS.itervalues()])
     self.assertEqual(bits.lowest_set(m), 0)
     self.assertEqual(bits.length(m), 16)
     self.assertEqual(m, 0b1111111111111111)
     print ' Bitmasks total (all ones): ', bin(m), m
Ejemplo n.º 6
0
Archivo: pq.py Proyecto: sixy6e/stash
 def test_bitmasks(self):
     m = sum([v for v in PQ_BITMASKS.itervalues()])
     self.assertEqual(bits.lowest_set(m), 0)
     self.assertEqual(bits.length(m), 16)
     self.assertEqual(m, 0b1111111111111111)
Ejemplo n.º 7
0
 def test_bitmasks(self):
     m = sum([v for v in PQ_BITMASKS.itervalues()])
     self.assertEqual(bits.lowest_set(m), 0)
     self.assertEqual(bits.length(m), 16)
     self.assertEqual(m, 0b1111111111111111)
Ejemplo n.º 8
0
 def test_bitmasks(self):
     m = sum([v for v in PQ_BITMASKS.itervalues()])
     self.assertEqual(bits.lowest_set(m), 0)
     self.assertEqual(bits.length(m), 16)
     self.assertEqual(m, 0b1111111111111111)
     print ' Bitmasks total (all ones): ', bin(m), m