ImageD11.opendata
index
/sware/exp/fable/standalone/redhate4-a64/lib/python2.5/site-packages/ImageD11/opendata.py

ImageD11 generic file opener
 
Returns a data object
 
Try to determine file type from extension or otherwise first few
bytes???

 
Modules
       
numpy.oldnumeric
bz2
gzip

 
Functions
       
edfheader(file)
Reads the header of edf files into a dictionary
file can be fileobject or filename
getnum(name)
makeedfheader(dataobject)
Writes the FLOAT edf subset a la fit2d
Feel free to improve me!
makename(stem, num, extn, width=4)
Filename creation mydata1234.edf etc
eg stem + num + extn   ... with num being width wide,
openbruker(filename)
Reads a bruker file into a data object
openchi(filename)
opens a chi file and returns a data object
2 columns in resulting array (x,y)
opendata(filename)
Guesses the file type and return a data object
 
Supports edf, edf.gz, edf.bz2, xye, epf, inp, chi
 ... otherwise tries bruker
openedf(filename)
Opens edf files returning data objects
Can be gzipped or bzipped
 
So far only UnsignedShort (eg frelon) or FLOAT (eg fit2d)
openxye(filename)
opens an xye file and returns a data object
3 columns in resulting array (x,y,e)
readbruker(file)
Reads in a Bruker file, returning the data and header
file may be a string or file object
TODO we should later modify to take ROI ranges somehow (xmin,xmax,ymin,ymax)
readbrukerheader(file)
Reads a Bruker file header into a Python dictionary
file=filename or file pointer
readbytestream(file, offset, x, y, nbytespp, datatype='int', signed='n', swap='n', typeout='H')
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 has no unsigned numeric types.)
swap, normally do not bother, but 'y' to swap bytes
typeout is the Numeric 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
writebruker(filename, dataobject)
Writes 16-bit + overflow bruker images based on the headerstring
Assumes you've got a good bruker headerstring in the data
object
writedata(filename, dataobject)
writeedf(filename, dataobject)