FabIO module
Center for Fundamental Research: Metal Structures in Four Dimensions Risoe National Laboratory Frederiksborgvej 399 DK-4000 Roskilde email:erik.knudsen@risoe.dk
and Jon Wright, Jerome Kieffer: ESRF
Bases: object
A common object for images in fable Contains a numpy array (.data) and dict of meta data (.header)
Empty for fabioimage but may be populated by others classes, especially for format accepting only integers
Empty for fabioimage but may be populated by others classes
Retrieves the name of the class :return: the name of the class
Convert a fabioimage object into another fabioimage object (with possible conversions) :param dest: destination type “EDF”, “edfimage” or the class itself
Sums up a region of interest if len(coords) == 4 -> convert coords to slices if len(coords) == 2 -> use as slices floor -> ? removed as unused in the function.
Convert a len(4) set of coords into a len(2) tuple (pair) of slice objects the latter are immutable, meaning the roi can be cached
Method reading Region of Interest. This implementation is the trivial one, just doing read and crop
Rebin the data and adjust dims :param x_rebin_fact: x binning factor :param y_rebin_fact: y binning factor :param keep_I: shall the signal increase ? :type x_rebin_fact: int :type y_rebin_fact: int :type keep_I: boolean
General purpose utilities functions for fabio
Bases: bz2.BZ2File
Wrapper with lock
Bases: file
wrapper for “file” with locking
Bases: object
The ‘meaning’ of a filename ...
Bases: gzip.GzipFile
Just a wrapper forgzip.GzipFile providing the correct seek capabilities for python 2.5
Bases: StringIO.StringIO
just an interface providing the name and mode property to a StringIO
BugFix for MacOSX mainly
Bases: fabio.fabioutils.File
wrapper for “File” with locking
Try to construct the filename for a given frame
Function for backward compatibility. Deprecated
used to deprecate a function/method: prints a lot of warning messages to enforce the modifaction of the code
# try to figure out a file number # guess it starts at the back
Parameters: |
|
---|---|
Returns: | True of False whether name is pure ascii or not |
Workaround that int(‘1.0’) raises an exception
Parameters: | s – string to be converted to integer |
---|
cant see how to do without reversing strings Match 1 or more digits going backwards from the end of the string
Bases: list
Represents a series of files to iterate has an idea of a current position to do next and prev
Much like the others, but created from a string filename
A generator function that creates a file series starting from a a fabioimage. Iterates through all images in a file (if more than 1), then proceeds to the next file as determined by fabio.next_filename.
Parameters: |
|
---|
Suggested usage:
for obj in new_file_series( ... ):
if not isinstance(obj, fabio.fabioimage.fabioimage ):
# deal with errors like missing images, non readable files, etc
# e.g.
traceback.print_exception(obj[0], obj[1], obj[2])
Created from a fabio image first and last are file numbers
Bases: fabio.file_series.file_series
mydata0001.edf = “mydata” + 0001 + ”.edf” mydata0002.edf = “mydata” + 0002 + ”.edf” mydata0003.edf = “mydata” + 0003 + ”.edf”
mods for fabio by JPW
Bases: fabio.fabioimage.fabioimage
Read an image in ADSC format (quite similar to edf?)
Authors: Gael Goret, Jerome Kieffer, ESRF, France Emails: gael.goret@esrf.fr, jerome.kieffer@esrf.fr
Brian Richard Pauw <brian@stack.nl>
Binary files images are simple none-compressed 2D images only defined by their : data-type, dimensions, byte order and offset
This simple library has been made for manipulating exotic/unknown files format.
Bases: fabio.fabioimage.fabioimage
This simple library has been made for manipulating exotic/unknown files format.
Binary files images are simple none-compressed 2D images only defined by their : data-type, dimensions, byte order and offset
if offset is set to a negative value, the image is read using the last data but n data in the file, skipping any header.
Read a binary image
Parameters: |
|
---|
Writer by Jérôme Kieffer, ESRF, Grenoble, France
Bases: fabio.fabioimage.fabioimage
Read and eventually write ID11 bruker (eg smart6500) images
TODO: int32 -> float32 conversion according to the “linear” keyword. This is done and works but we need to check with other program that we are appliing the right formula and not the reciprocal one.
Does some basic population of the headers so that the writing is possible
Cif Binary Files images are 2D images written by the Pilatus detector and others. They use a modified (simplified) byte-offset algorithm.
CIF is a library for manipulating Crystallographic information files and tries to conform to the specification of the IUCR
Bases: dict
This is the CIF class, it represents the CIF dictionary; and as a a python dictionary thus inherits from the dict built in class.
Returns True if the key (string) exist in the array called loop
Check if the key exists in the CIF and is non empty. :param sKey: CIF key :type sKey: string :param cif: CIF dictionary :return: True if the key exists in the CIF dictionary and is non empty :rtype: boolean
Check if the key exists in the CIF dictionary. :param sKey: CIF key :type sKey: string :param cif: CIF dictionary :return: True if the key exists in the CIF dictionary and is non empty :rtype: boolean
Check if all characters in a string are ascii,
Parameters: | _strIn (python string) – input string |
---|---|
Returns: | boolean |
Return type: | boolean |
Load the powder diffraction CHIPLOT file and returns the pd_CIF dictionary in the object
Parameters: | _strFilename (string) – the name of the file to open |
---|---|
Returns: | the CIF object corresponding to the powder diffraction |
Return type: | dictionary |
Load the CIF file and populates the CIF dictionary into the object :param _strFilename: the name of the file to open :type _strFilename: string :param _strFilename: the name of the file to open :type _strFilename: string :return: None
Load the CIF file and populates the CIF dictionary into the object :param _strFilename: the name of the file to open :type _strFilename: string :param _strFilename: the name of the file to open :type _strFilename: string :return: None
Transforms the CIF object in string then write it into the given file :param _strFilename: the of the file to be written :param linesep: line separation used (to force compatibility with windows/unix) :param binary: Shall we write the data as binary (True only for imageCIF/CBF) :type param: string
Bases: fabio.fabioimage.fabioimage
Read the Cif Binary File data format
Center for Fundamental Research: Metal Structures in Four Dimensions Risoe National Laboratory Frederiksborgvej 399 DK-4000 Roskilde email:erik.knudsen@risoe.dk
Bases: fabio.fabioimage.fabioimage
Read and try to write the dm3 data format
License: GPLv2+
Bases: object
A class representing a single frame in an EDF file
Unpack a binary blob according to the specification given in the header
Returns: | dataset as numpy.ndarray |
---|
Unpack a binary blob according to the specification given in the header
Returns: | dataset as numpy.ndarray |
---|
Parameters: |
|
---|---|
Returns: | ascii header block |
Return type: | python string with the concatenation of the ascii header and the binary data block |
Bases: fabio.fabioimage.fabioimage
Read and try to write the ESRF edf data format
Method used add a frame to an EDF file :param frame: frame to append to edf image :type frame: instance of Frame :return: None
property: capsHeader of EDF file, i.e. the keys of the header in UPPER case.
Empty for fabioimage but may be populated by others classes
property: data of EDF file
Method used to remove a frame from an EDF image. by default the last one is removed. :param frameNb: frame number to remove, by default the last. :type frameNb: integer :return: None
This is a special method that will read and return the data from another file ... The aim is performances, ... but only supports uncompressed files.
Returns: | data from another file using positions from current edfimage |
---|
Method reading Region of Interest of another file based on metadata available in current edfimage. The aim is performances, ... but only supports uncompressed files.
Returns: | ROI-data from another file using positions from current edfimage |
---|---|
Return type: | numpy 2darray |
getter for edf headers keys in upper case :return: data for current frame :rtype: dict
property: header of EDF file
property: header_keys of EDF file
Getter for number of frames
Enforces the propagation of the header_keys to the list of frames :param _data: numpy array representing data
Enforces the propagation of the data to the list of frames :param _data: numpy array representing data
Enforces the propagation of the header_keys to the list of frames :param _listtHeader: list of the (ordered) keys in the header :type _listtHeader: python list
Setter for number of frames ... should do nothing. Here just to avoid bugs
Author: Andy Hammersley, ESRF Translation into python/fabio: Jon Wright, ESRF
Bases: fabio.fabioimage.fabioimage
Read and try to write Andy Hammersley’s mask format
Bases: fabio.fabioimage.fabioimage
Read a fit2d ascii format
Bases: fabio.fabioimage.fabioimage
Center for Fundamental Research: Metal Structures in Four Dimensions Risoe National Laboratory Frederiksborgvej 399 DK-4000 Roskilde email:erik.knudsen@risoe.dk
Information about the file format from Masakatzu Kobayashi is highly appreciated
Bases: fabio.fabioimage.fabioimage
Read HiPic images e.g. collected with a Hamamatsu CCD camera
kcd images are 2D images written by the old KappaCCD diffractometer built by Nonius in the 1990’s Based on the edfimage.py parser.
Bases: fabio.fabioimage.fabioimage
marccdimage can read MarCCD and MarMosaic images including header info.
JPW : Use a parser in case of typos (sorry?)
given a format and header interpret it
Reads the header definition in c and makes the format string to pass to struct.unpack
Bases: fabio.tifimage.tifimage
Read in data in mar ccd format, also MarMosaic images, including header info
Reads Oxford Diffraction Sapphire 3 images
Bases: fabio.fabioimage.fabioimage
Oxford Diffraction Sapphire 3 images reader/writer class
Bases: fabio.tifimage.tifimage
Read in Pilatus format, also pilatus images, including header info
Bases: fabio.fabioimage.fabioimage
FabIO class for dealing with TIFF images. In facts wraps TiffIO from V. Armando Solé (available in PyMca) or falls back to PIL
License: GPLv3+
Bases: object
Bases: fabio.fabioimage.fabioimage
Images in TIF format Wraps TiffIO
XSDimge are XML files containing numpy arrays
Bases: fabio.fabioimage.fabioimage
Read the XSDataImage XML File data format
FabIO library containing compression and decompression algorithm for various
Compress a dataset into a string using the byte_offet algorithm
Parameters: | data – ndarray |
---|---|
Returns: | string/bytes with compressed data |
test = numpy.array([0,1,2,127,0,1,2,128,0,1,2,32767,0,1,2,32768,0,1,2,2147483647,0,1,2,2147483648,0,1,2,128,129,130,32767,32768,128,129,130,32768,2147483647,2147483648])
Modified CCP4 pck compressor used in MAR345 images
Parameters: | data – numpy.ndarray (square array) |
---|---|
Returns: | compressed stream |
Modified byte offset compressor used in Oxford Diffraction images
Parameters: | data – numpy.ndarray with the input data (integers!) |
---|---|
Returns: | 3-tuple of strings: raw_8,raw_16,raw_32 containing raw data with integer of the given size |
Parameters: |
|
---|---|
Returns: | 1D-ndarray |
Parameters: |
|
---|---|
Returns: | 1D-ndarray |
Analyze a stream of char with any length of exception (2,4, or 8 bytes integers)
Parameters: |
|
---|---|
Returns: | 1D-ndarray |
Analyze a stream of char with any length of exception (2,4, or 8 bytes integers)
Parameters: |
|
---|---|
Returns: | 1D-ndarray |
Decompress a chunk of data using the bzip2 algorithm from Python
Decompress a chunk of data using the gzip algorithm from Python or alternatives if possible
Modified byte offset decompressor used in Oxford Diffraction images
Parameters: |
|
---|---|
Returns: | numpy.ndarray |
Modified CCP4 pck decompressor used in MAR345 images
Parameters: | stream – string or file |
---|---|
Returns: | numpy.ndarray (square array) |
Modified byte offset decompressor used in Oxford Diffraction images
Parameters: |
|
---|---|
Returns: | numpy.ndarray |
Converter module. This is for the moment empty (populated only with almost pass through anonymous functions) but aims to be populated with more sofisticated translators ...
Center for Fundamental Research: Metal Structures in Four Dimensions Risoe National Laboratory Frederiksborgvej 399 DK-4000 Roskilde email:erik.knudsen@risoe.dk
and Jon Wright, ESRF
Bases: fabio.datIO.fabiodata
Concrete fabiodata class
Reads a bytestream
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