fabio.readbytestream
index
/usr/lib/pymodules/python2.6/fabio/readbytestream.py

Reads a bytestream
 
Authors: Jon Wright    Henning O. Sorensen & Erik Knudsen
         ESRF          Risoe National Laboratory

 
Modules
       
numpy
logging

 
Functions
       
readbytestream(fil, offset, x, y, nbytespp, datatype='int', signed='n', swap='n', typeout=<type 'numpy.uint16'>)
Reads in a bytestream from a file (which may be a string indicating
a filename, or an already opened file (should be "rb"))
offset is the position (in bytes) where the pixel data start
nbytespp = number of bytes per pixel
type can be int or float (4 bytes pp) or double (8 bytes pp)
signed: normally signed data 'y', but 'n' to try to get back the 
right numbers when unsigned data are converted to signed 
(python once had no unsigned numeric types.)
swap, normally do not bother, but 'y' to swap bytes
typeout is the numpy type to output, normally uint16, 
but more if overflows occurred
x and y are the pixel dimensions
 
TODO : Read in regions of interest
 
PLEASE LEAVE THE STRANGE INTERFACE ALONE - 
IT IS USEFUL FOR THE BRUKER FORMAT

 
Data
        DATATYPES = {('double', 'y', 4): <type 'numpy.float64'>, ('float', 'y', 4): <type 'numpy.float32'>, ('int', 'n', 1): <type 'numpy.uint8'>, ('int', 'n', 2): <type 'numpy.uint16'>, ('int', 'n', 4): <type 'numpy.uint32'>, ('int', 'y', 1): <type 'numpy.int8'>, ('int', 'y', 2): <type 'numpy.int16'>, ('int', 'y', 4): <type 'numpy.int32'>}