def raw_counts_to_adu(raw_counts, fixed_offset, meanblck, nreadout):
    """Convert Kepler raw pixel counts photometer ADU.

    Converts raw cadence pixel counts to Analog to Digital Units read off
    the photometer following the Kepler Archive Manual (p23).

    This is necessary because the spacecraft software subtracts
    a mean black value from each channel to have the pixel values
    of all channels center around zero, so that a single compression
    table can be used to compress all pixel values.
    However to avoid negative values, a large positive offset value
    ('LCFXDOFF' or 'SCFXDOFF') is then added that lifts the pixel
    values to a level that matches the range in the compression
    table designed for the pixel counts.
    """
    return raw_counts + nreadout*meanblck - fixed_offset