Package: fabio
Main websites:https://github.com/silx-kit/fabiohttp://fable.sf.net(historical)FabIO is an I/O library for images produced by 2D X-ray detectors and written in Python.
FabIO support images detectors from a dozen of companies (including Mar, Dectris, ADSC, Hamamatsu, Oxford, …),
for a total of 30 different file formats (like CBF, EDF, TIFF, …) and offers an unified interface to their
headers (as a Python dictionary) and datasets (as a numpy ndarray of integers or floats)ContentsInstallationUsageDocumentationChangelogCitationTransparent handling of compressed filesSupported file formatsDesign SpecificationsInstallationFabIO is available fromPyPI:pip install fabioDebian/Ubuntu packages, andwheelsare available
for Windows, Linux and MacOSX from the silx repository.See theinstallation instructionsfor more information.UsageOpen an image>>> import fabio
>>> obj = fabio.open("mydata0000.edf")
>>> obj.data.shape
(2048, 2048)
>>> obj.header["Omega"]
23.5
>>> obj.data
array([...])Save an image (ex: EDF)>>> import fabio
>>> obj = fabio.edfimage.EdfImage(data=[...])
>>> obj.write("mydata0000.edf")DocumentationSee thelatest release documentationfor further details.Documentation of previous versions are available onsilx.ChangelogSeehttp://www.silx.org/doc/fabio/latest/Changelog.htmlCitationThe general philosophy of the library is described in:FabIO: easy access to two-dimensional X-ray detector images in Python; E. B. Knudsen, H. O. Sørensen, J. P. Wright, G. Goret and J. Kieffer Journal of Applied Crystallography, Volume 46, Part 2, pages 537-539.Transparent handling of compressed filesFor FabIO to handle gzip and bzip2 compressed files transparently,bzipandgzipmodules must be present when installing/building Python (e.g.libbz2-devpackage for Ubuntu).Benchmarking details have been collected athttp://www.silx.org/doc/fabio/latest/performances.html.Supported file formatsADSC:AdscImageBruker:BrukerImageBruker100ImageKcdImage: Nonius KappaCCD diffractometerD3MD3mImageDectris:CbfImage (implements a fast byte offset de/compression scheme in python/cython)PilatusImage (fileformat derived from Tiff)EigerImage (derived from HDF5/NeXus format, depends onh5py)ESRF:EdfImage: The ESRF data FormatXsdImage: XML serialized image from EDNAFit2dImage: Fit2d binary formatFit2dmaskImage: Fit2d Mask formatFit2dSpreadsheetImage: Fit2d ascii tables (spread-sheet)LimaImage: image stacks written by the LImA aquisition systemSparseImage: single crystal diffractions images written by pyFAIGeneral ElectricsGEimage (including support for variant used at APS)HamamatsuHiPiCImageHDF5: generic format for stack of images based on h5pyHdf5ImageEigerImageLimaImageSparseImageJPEG image format:JPEG using PILJPEG 2000 using GlymurMar Research:MarccdImage (fileformat derived from Tiff)Mar345Image imaging plate with PCK compressionMPA multiwireMpaImageMedical Research Council file format for 3D electron density and 2D imagesMrcImageNonius -> now owned by BrukerKcdImageNumpy: generic reader for 2D arrays savedNumpyImageOxford Diffraction Sapphire 3OXDimage uncompressed or with TY1 or TY5 compression schemeEsperanto format (with bitfield compression)Pixirad ImagingPixiImagePNMPnmImagePrinceton Instrument SPESpeImageRaw Binary without compressionRigakuRaxisImageDtrekImageTiffTifImage using either:Pillow (external dependency)TiffIO taken from PyMcaDesign SpecificationsName:FabIO = Fable Input/OutputIdea:Have a base class for all our 2D diffraction greyscale images.
This consists of a 2D array (numpy ndarray)
and a python dictionary (actually an ordered dict) of header information in (string key, string value) pairs.Class FabioImageNeeds a name which will not to be confused with an RGB color image.Class attributes, often exposed as properties:data                                          -> 2D arrayheader                                        -> ordered dictionaryrows, columns, dim1, dim2 -> data.shape (propertiy)header_keys               -> property for list(header.keys()), formerly used to retain the order of the headerbytecode                      -> data.typecode() (property)m, minval, maxval, stddev     -> image statistics, could add others, eg roi[slice]Class methods (functions):integrate_area()      -> return sum(self.data) within slicerebin(fact)           -> rebins data, adjusts dimstoPIL16()             -> returns a PILimagegetheader()           -> returns self.headerresetvals()           -> resets the statisticsgetmean()             -> (computes) returns self.mgetmin()              -> (computes) returns self.minvalgetmax()              -> (computes) returns self.maxvalgetstddev()           -> (computes) returns self.stddevread()                        -> read image from file [or stream, or shared memory]write()                       -> write image to file  [or stream, or shared memory]readheader()          -> read only the header [much faster for scanning files]Each individual file format would then inherit all the functionality of this class and just make new read and write methods.There are also fileseries related methods (next(), previous(), …) which returns a FabioImage instance of the next/previous frame in a fileserieOther feature:possibility for using on-the-fly external compression - i.e. if files are
stored as something as .gz, .bz2 etc could decompress them, using an external
compression mechanism (if available).