'Internal function for reading image data from a file and apply scale
factors to it.  Normally this is used for the entire image, but it
supports alternate offset/shape for Section support.'

def _get_scaled_image_data(self, offset, shape):

    code = BITPIX2DTYPE[self._orig_bitpix]
    raw_data = self._get_raw_data(shape, code, offset)
    raw_data.dtype = raw_data.dtype.newbyteorder('>')
    if (self._do_not_scale_image_data or ((self._orig_bzero == 0) and (self._orig_bscale == 1) and (self._blank is None))):
        return raw_data
    try:
        if self._file.strict_memmap:
            raise ValueError('Cannot    load    a    memory-mapped    image:    BZERO/BSCALE/BLANK    header    keywords    present.    Set    memmap=False.')
    except AttributeError:
        pass
    data = None
    if (not ((self._orig_bzero == 0) and (self._orig_bscale == 1))):
        data = self._convert_pseudo_unsigned(raw_data)
    if (data is None):
        blanks = None
        if ((self._blank is not None) and (self._bitpix > 0)):
            blanks = (raw_data.flat == self._blank)
            if (blanks.sum() < (len(blanks) / 8)):
                blanks = np.where(blanks)
        new_dtype = self._dtype_for_bitpix()
        if (new_dtype is not None):
            data = np.array(raw_data, dtype=new_dtype)
        elif ((self._file is not None) and self._file.memmap):
            data = raw_data.copy()
        elif (not raw_data.flags.writeable):
            data = raw_data.copy()
        else:
            data = raw_data
        del raw_data
        if (self._orig_bscale != 1):
            np.multiply(data, self._orig_bscale, data)
        if (self._orig_bzero != 0):
            data += self._orig_bzero
        if self._blank:
            data.flat[blanks] = np.nan
    return data
