From 55ac9919edc5cdeae0c7f48a6a1b9b3b8806e8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Sat, 2 Sep 2017 16:12:29 +0200 Subject: Import python-fabio_0.5.0+dfsg.orig.tar.gz [dgit import orig python-fabio_0.5.0+dfsg.orig.tar.gz] --- MANIFEST.in | 22 + PKG-INFO | 211 + README.rst | 183 + copyright | 173 + doc/Makefile | 130 + doc/make.bat | 170 + doc/source/Changelog.rst | 137 + doc/source/_static/placeholder | 1 + doc/source/api/modules.rst | 297 + doc/source/conf.py | 240 + doc/source/coverage.rst | 56 + doc/source/getting_started.rst | 289 + doc/source/img/viewer.png | Bin 0 -> 183305 bytes doc/source/index.rst | 29 + doc/source/install.rst | 337 + doc/source/man/fabio_viewer.rst | 11 + doc/source/mathjax.py | 69 + doc/source/performances.rst | 44 + doc/source/tutorials/Nexus2cbf.ipynb | 1062 ++ doc/source/tutorials/Nexus2cbf.rst | 180 + doc/source/tutorials/convert_CBF.rst | 62 + doc/source/tutorials/index.rst | 14 + fabio.egg-info/SOURCES.txt | 217 + fabio/GEimage.py | 367 + fabio/HiPiCimage.py | 140 + fabio/OXDimage.py | 570 + fabio/TiffIO.py | 1247 ++ fabio/__init__.py | 87 + fabio/adscimage.py | 143 + fabio/app/__init__.py | 0 fabio/app/convert.py | 400 + fabio/app/setup.py | 39 + fabio/app/viewer.py | 1523 ++ fabio/benchmark/__init__.py | 95 + fabio/benchmark/setup.py | 39 + fabio/binaryimage.py | 133 + fabio/bruker100image.py | 404 + fabio/brukerimage.py | 432 + fabio/cbfimage.py | 846 + fabio/compression.py | 456 + fabio/converters.py | 95 + fabio/datIO.py | 90 + fabio/directories.py | 60 + fabio/dm3image.py | 253 + fabio/edfimage.py | 982 + fabio/eigerimage.py | 206 + fabio/ext/__init__.py | 0 fabio/ext/_cif.c | 20245 +++++++++++++++++++++ fabio/ext/_cif.pyx | 149 + fabio/ext/byte_offset.c | 22778 ++++++++++++++++++++++++ fabio/ext/byte_offset.pyx | 358 + fabio/ext/cf_io.c | 6727 +++++++ fabio/ext/cf_io.pyx | 119 + fabio/ext/include/ccp4_pack.h | 94 + fabio/ext/include/columnfile.h | 55 + fabio/ext/include/msvc/stdint.h | 247 + fabio/ext/mar345_IO.c | 31475 +++++++++++++++++++++++++++++++++ fabio/ext/mar345_IO.pyx | 715 + fabio/ext/setup.py | 66 + fabio/ext/src/ccp4_pack.c | 888 + fabio/ext/src/cf_iomodule.c | 79 + fabio/ext/src/columnfile.c | 225 + fabio/fabioformats.py | 173 + fabio/fabioimage.py | 604 + fabio/fabioutils.py | 693 + fabio/file_series.py | 436 + fabio/fit2dimage.py | 169 + fabio/fit2dmaskimage.py | 153 + fabio/fit2dspreadsheetimage.py | 102 + fabio/hdf5image.py | 174 + fabio/jpeg2kimage.py | 159 + fabio/jpegimage.py | 120 + fabio/kcdimage.py | 192 + fabio/mar345image.py | 394 + fabio/marccdimage.py | 344 + fabio/mpaimage.py | 131 + fabio/mrcimage.py | 188 + fabio/nexus.py | 387 + fabio/numpyimage.py | 199 + fabio/openimage.py | 217 + fabio/pilatusimage.py | 113 + fabio/pixiimage.py | 171 + fabio/pnmimage.py | 230 + fabio/raxisimage.py | 339 + fabio/readbytestream.py | 114 + fabio/setup.py | 48 + fabio/speimage.py | 313 + fabio/templateimage.py | 131 + fabio/test/__init__.py | 56 + fabio/test/profile_all.py | 85 + fabio/test/setup.py | 39 + fabio/test/testGEimage.py | 84 + fabio/test/testOXDimage.py | 190 + fabio/test/testXSDimage.py | 102 + fabio/test/test_all.py | 118 + fabio/test/test_all_images.py | 104 + fabio/test/test_file_series.py | 126 + fabio/test/test_filename_steps.py | 83 + fabio/test/test_flat_binary.py | 91 + fabio/test/test_nexus.py | 80 + fabio/test/testadscimage.py | 114 + fabio/test/testbruker100image.py | 105 + fabio/test/testbrukerimage.py | 227 + fabio/test/testcbfimage.py | 176 + fabio/test/testcompression.py | 135 + fabio/test/testedfimage.py | 390 + fabio/test/testeigerimage.py | 87 + fabio/test/testfabioconvert.py | 196 + fabio/test/testfabioimage.py | 233 + fabio/test/testfilenames.py | 127 + fabio/test/testfit2dimage.py | 103 + fabio/test/testfit2dmaskimage.py | 159 + fabio/test/testhdf5image.py | 106 + fabio/test/testheadernotsingleton.py | 80 + fabio/test/testjpeg2kimage.py | 173 + fabio/test/testjpegimage.py | 170 + fabio/test/testkcdimage.py | 97 + fabio/test/testmar345image.py | 208 + fabio/test/testmccdimage.py | 124 + fabio/test/testmpaimage.py | 76 + fabio/test/testnumpyimage.py | 108 + fabio/test/testopenheader.py | 69 + fabio/test/testopenimage.py | 242 + fabio/test/testpilatusimage.py | 78 + fabio/test/testpnmimage.py | 95 + fabio/test/testraxisimage.py | 121 + fabio/test/testspeimage.py | 163 + fabio/test/testtifimage.py | 185 + fabio/test/utilstest.py | 288 + fabio/third_party/__init__.py | 1 + fabio/third_party/argparse.py | 50 + fabio/third_party/gzip.py | 60 + fabio/third_party/ordereddict.py | 50 + fabio/third_party/setup.py | 48 + fabio/third_party/six.py | 52 + fabio/tifimage.py | 341 + fabio/utils/__init__.py | 0 fabio/utils/mathutils.py | 58 + fabio/utils/pilutils.py | 129 + fabio/utils/setup.py | 39 + fabio/xsdimage.py | 168 + run_tests.py | 337 + setup.cfg | 5 + setup.py | 705 + stdeb.cfg | 8 + version.py | 103 + 146 files changed, 110802 insertions(+) create mode 100644 MANIFEST.in create mode 100644 PKG-INFO create mode 100644 README.rst create mode 100644 copyright create mode 100644 doc/Makefile create mode 100644 doc/make.bat create mode 100644 doc/source/Changelog.rst create mode 100644 doc/source/_static/placeholder create mode 100644 doc/source/api/modules.rst create mode 100644 doc/source/conf.py create mode 100644 doc/source/coverage.rst create mode 100644 doc/source/getting_started.rst create mode 100644 doc/source/img/viewer.png create mode 100644 doc/source/index.rst create mode 100644 doc/source/install.rst create mode 100644 doc/source/man/fabio_viewer.rst create mode 100644 doc/source/mathjax.py create mode 100644 doc/source/performances.rst create mode 100644 doc/source/tutorials/Nexus2cbf.ipynb create mode 100644 doc/source/tutorials/Nexus2cbf.rst create mode 100644 doc/source/tutorials/convert_CBF.rst create mode 100644 doc/source/tutorials/index.rst create mode 100644 fabio.egg-info/SOURCES.txt create mode 100644 fabio/GEimage.py create mode 100644 fabio/HiPiCimage.py create mode 100644 fabio/OXDimage.py create mode 100644 fabio/TiffIO.py create mode 100644 fabio/__init__.py create mode 100644 fabio/adscimage.py create mode 100644 fabio/app/__init__.py create mode 100644 fabio/app/convert.py create mode 100644 fabio/app/setup.py create mode 100755 fabio/app/viewer.py create mode 100644 fabio/benchmark/__init__.py create mode 100644 fabio/benchmark/setup.py create mode 100644 fabio/binaryimage.py create mode 100644 fabio/bruker100image.py create mode 100644 fabio/brukerimage.py create mode 100644 fabio/cbfimage.py create mode 100644 fabio/compression.py create mode 100644 fabio/converters.py create mode 100644 fabio/datIO.py create mode 100644 fabio/directories.py create mode 100644 fabio/dm3image.py create mode 100644 fabio/edfimage.py create mode 100644 fabio/eigerimage.py create mode 100644 fabio/ext/__init__.py create mode 100644 fabio/ext/_cif.c create mode 100644 fabio/ext/_cif.pyx create mode 100644 fabio/ext/byte_offset.c create mode 100644 fabio/ext/byte_offset.pyx create mode 100644 fabio/ext/cf_io.c create mode 100644 fabio/ext/cf_io.pyx create mode 100644 fabio/ext/include/ccp4_pack.h create mode 100644 fabio/ext/include/columnfile.h create mode 100644 fabio/ext/include/msvc/stdint.h create mode 100644 fabio/ext/mar345_IO.c create mode 100644 fabio/ext/mar345_IO.pyx create mode 100644 fabio/ext/setup.py create mode 100644 fabio/ext/src/ccp4_pack.c create mode 100644 fabio/ext/src/cf_iomodule.c create mode 100644 fabio/ext/src/columnfile.c create mode 100644 fabio/fabioformats.py create mode 100644 fabio/fabioimage.py create mode 100644 fabio/fabioutils.py create mode 100644 fabio/file_series.py create mode 100644 fabio/fit2dimage.py create mode 100644 fabio/fit2dmaskimage.py create mode 100644 fabio/fit2dspreadsheetimage.py create mode 100644 fabio/hdf5image.py create mode 100644 fabio/jpeg2kimage.py create mode 100644 fabio/jpegimage.py create mode 100644 fabio/kcdimage.py create mode 100644 fabio/mar345image.py create mode 100644 fabio/marccdimage.py create mode 100644 fabio/mpaimage.py create mode 100644 fabio/mrcimage.py create mode 100644 fabio/nexus.py create mode 100644 fabio/numpyimage.py create mode 100644 fabio/openimage.py create mode 100644 fabio/pilatusimage.py create mode 100644 fabio/pixiimage.py create mode 100644 fabio/pnmimage.py create mode 100644 fabio/raxisimage.py create mode 100644 fabio/readbytestream.py create mode 100644 fabio/setup.py create mode 100644 fabio/speimage.py create mode 100644 fabio/templateimage.py create mode 100755 fabio/test/__init__.py create mode 100755 fabio/test/profile_all.py create mode 100644 fabio/test/setup.py create mode 100644 fabio/test/testGEimage.py create mode 100644 fabio/test/testOXDimage.py create mode 100755 fabio/test/testXSDimage.py create mode 100755 fabio/test/test_all.py create mode 100644 fabio/test/test_all_images.py create mode 100644 fabio/test/test_file_series.py create mode 100644 fabio/test/test_filename_steps.py create mode 100644 fabio/test/test_flat_binary.py create mode 100644 fabio/test/test_nexus.py create mode 100644 fabio/test/testadscimage.py create mode 100644 fabio/test/testbruker100image.py create mode 100644 fabio/test/testbrukerimage.py create mode 100755 fabio/test/testcbfimage.py create mode 100755 fabio/test/testcompression.py create mode 100755 fabio/test/testedfimage.py create mode 100644 fabio/test/testeigerimage.py create mode 100644 fabio/test/testfabioconvert.py create mode 100644 fabio/test/testfabioimage.py create mode 100644 fabio/test/testfilenames.py create mode 100644 fabio/test/testfit2dimage.py create mode 100644 fabio/test/testfit2dmaskimage.py create mode 100644 fabio/test/testhdf5image.py create mode 100644 fabio/test/testheadernotsingleton.py create mode 100644 fabio/test/testjpeg2kimage.py create mode 100644 fabio/test/testjpegimage.py create mode 100755 fabio/test/testkcdimage.py create mode 100644 fabio/test/testmar345image.py create mode 100644 fabio/test/testmccdimage.py create mode 100644 fabio/test/testmpaimage.py create mode 100755 fabio/test/testnumpyimage.py create mode 100644 fabio/test/testopenheader.py create mode 100644 fabio/test/testopenimage.py create mode 100644 fabio/test/testpilatusimage.py create mode 100755 fabio/test/testpnmimage.py create mode 100644 fabio/test/testraxisimage.py create mode 100644 fabio/test/testspeimage.py create mode 100755 fabio/test/testtifimage.py create mode 100644 fabio/test/utilstest.py create mode 100644 fabio/third_party/__init__.py create mode 100644 fabio/third_party/argparse.py create mode 100644 fabio/third_party/gzip.py create mode 100644 fabio/third_party/ordereddict.py create mode 100644 fabio/third_party/setup.py create mode 100644 fabio/third_party/six.py create mode 100644 fabio/tifimage.py create mode 100644 fabio/utils/__init__.py create mode 100644 fabio/utils/mathutils.py create mode 100644 fabio/utils/pilutils.py create mode 100644 fabio/utils/setup.py create mode 100644 fabio/xsdimage.py create mode 100755 run_tests.py create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 stdeb.cfg create mode 100644 version.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a2003af --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,22 @@ +include README.rst +include MANIFEST.in +include version.py +include run_tests.py +include copyright +exclude MANIFEST +include stdeb.cfg +recursive-include fabio/ext *.c *.h *.pyx +recursive-include pylint * +recursive-include scripts * +recursive-exclude build * +recursive-exclude dist * +recursive-exclude test/tiftest * +recursive-exclude test/testimages * +recursive-exclude testimages * +recursive-exclude fabio.egg-info * + + +#Include doc without checkpoints +recursive-include doc * +recursive-exclude doc .ipynb_checkpoints/*.ipynb + diff --git a/PKG-INFO b/PKG-INFO new file mode 100644 index 0000000..4738ffa --- /dev/null +++ b/PKG-INFO @@ -0,0 +1,211 @@ +Metadata-Version: 1.1 +Name: fabio +Version: 0.5.0 +Summary: Image IO for fable +Home-page: http://github.com/silx-kit/fabio +Author: Henning Sorensen, Erik Knudsen, Jon Wright, Regis Perdreau, Jérôme Kieffer, Gael Goret, Brian Pauw +Author-email: fable-talk@lists.sourceforge.net +License: MIT +Download-URL: https://github.com/silx-kit/fabio/releases +Description: FabIO: Fable Input/Output library + ================================= + + Main websites: + + * http://fable.sf.net + * https://github.com/silx-kit/fabio + + + |Build Status| |Appveyor Status| + + ---- + + 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 20 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) + + Getting FabIO + ------------- + + FabIO is available from `PyPI `_. + + `Debian/Ubuntu packages `_, and + `wheels `_ are available + for windows, linux and MacOSX from the silx repository: + + Documentation is available at `PythonHosted `_, + Continuous documentation at `ReadTheDocs `_ and + Nightly build documentation at `silx `_. + + Citation: + --------- + The 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 files + ---------------------------------------- + Fabio is expected to handle gzip and bzip2 compressed files transparently. + Following a query about the performance of reading compressed data, some + benchmarking details have been collected at fabio_compressed_speed. + This means that when your python was configured and built you needed the + bzip and gzip modules to be present (eg libbz2-dev package for ubuntu) + Using fabio in your own python programs + Example:: + + >>> import fabio + >>> obj = fabio.edfimage("mydata0000.edf") + >>> obj.data.shape + (2048, 2048) + >>> obj.header["Omega"] + 23.5 + + + Design Specifications + --------------------- + Name: Fabio = Fable Input/Output + + Idea: + ..... + 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 FabioImage + ................ + Needs a name which will not to be confused with an RGB color image. + + Class attributes: + + * data -> 2D array + * header -> ordered dictionary + * rows, columns, dim1, dim2 -> data.shape (properties determined on the fly) + * header_keys -> property for list(header.keys()), formerly used to retain the order of the header + * bytecode -> 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 slice + * rebin(fact) -> rebins data, adjusts dims + * toPIL16() -> returns a PILimage + * getheader() -> returns self.header + * resetvals() -> resets the statistics + * getmean() -> (computes) returns self.m + * getmin() -> (computes) returns self.minval + * getmax() -> (computes) returns self.maxval + * getstddev() -> (computes) returns self.stddev + * read() -> 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 fileserie + + Other 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). This is present in fabian but requires that images are edfs. + + + Known file formats + ------------------ + + * Bruker: + + + BrukerImage + + Bruker100Image + + KcdImage: Nonius KappaCCD diffractometer + + * Mar Research: + + + MarccdImage (fileformat derived from Tiff) + + Mar345Image imaging plate with PCK compression + + * Dectris: + + + CbfImage (implements a fast byte offset de/compression scheme in python/cython) + + PilatusImage (fileformat derived from Tiff) + * EigerImage (derived from HDF5/NeXus format) + + * ESRF: + + + EdfImage: The ESRF data Format + + XsdImage: XML serialized image from EDNA + + Fit2dImage: Fit2d binary format + + Fit2dmaskImage: Fit2d Mask format + + Fit2dSpreadsheetImage: Fit2d ascii tables (spread-sheet) + + * ADSC: + + + AdscImage + + * GE detector at APS + + + GEimage + + * PNM + + + PnmImage + + * Tiff + + + TifImage + + TiffIO from PyMca + + * D3M + + + D3mImage + + * Hamamatsu + + + HiPiCImage + + * Oxford Diffraction Sapphire 3 + + + OXDimage uncompressed + + OXDimage with TY1 byte offset compression + + OXDimage with TY5 byte offset compression (experimental) + + * Nonius -> now owned by Bruker + + * HDF5: generic format for stack of images + + Hdf5Image + + EigerImage + + * Raw Binary without compression + + Installation + ------------ + + Please see doc/source/INSTALL.rst + + Changelog + --------- + + Please see doc/source/Changelog.rst + + .. |Build Status| image:: https://travis-ci.org/silx-kit/fabio.svg?branch=master + :target: https://travis-ci.org/silx-kit/fabio + .. |Appveyor Status| image:: https://ci.appveyor.com/api/projects/status/4k6lol1vq30qhf66/branch/master?svg=true + :target: https://ci.appveyor.com/project/ESRF/fabio/branch/master + +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Environment :: Console +Classifier: Intended Audience :: End Users/Desktop +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: MacOS :: MacOS X +Classifier: Operating System :: Microsoft :: Windows +Classifier: Operating System :: POSIX +Classifier: Programming Language :: Python +Classifier: Programming Language :: Cython +Classifier: Programming Language :: C +Classifier: Topic :: Scientific/Engineering :: Chemistry +Classifier: Topic :: Scientific/Engineering :: Bio-Informatics +Classifier: Topic :: Scientific/Engineering :: Physics +Classifier: Topic :: Scientific/Engineering :: Visualization +Classifier: Topic :: Software Development :: Libraries :: Python Modules diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..64cf2cd --- /dev/null +++ b/README.rst @@ -0,0 +1,183 @@ +FabIO: Fable Input/Output library +================================= + +Main websites: + + * http://fable.sf.net + * https://github.com/silx-kit/fabio + + +|Build Status| |Appveyor Status| + +---- + +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 20 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) + +Getting FabIO +------------- + +FabIO is available from `PyPI `_. + +`Debian/Ubuntu packages `_, and +`wheels `_ are available +for windows, linux and MacOSX from the silx repository: + +Documentation is available at `PythonHosted `_, +Continuous documentation at `ReadTheDocs `_ and +Nightly build documentation at `silx `_. + +Citation: +--------- +The 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 files +---------------------------------------- +Fabio is expected to handle gzip and bzip2 compressed files transparently. +Following a query about the performance of reading compressed data, some +benchmarking details have been collected at fabio_compressed_speed. +This means that when your python was configured and built you needed the +bzip and gzip modules to be present (eg libbz2-dev package for ubuntu) +Using fabio in your own python programs +Example:: + + >>> import fabio + >>> obj = fabio.edfimage("mydata0000.edf") + >>> obj.data.shape + (2048, 2048) + >>> obj.header["Omega"] + 23.5 + + +Design Specifications +--------------------- +Name: Fabio = Fable Input/Output + +Idea: +..... +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 FabioImage +................ +Needs a name which will not to be confused with an RGB color image. + +Class attributes: + +* data -> 2D array +* header -> ordered dictionary +* rows, columns, dim1, dim2 -> data.shape (properties determined on the fly) +* header_keys -> property for list(header.keys()), formerly used to retain the order of the header +* bytecode -> 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 slice +* rebin(fact) -> rebins data, adjusts dims +* toPIL16() -> returns a PILimage +* getheader() -> returns self.header +* resetvals() -> resets the statistics +* getmean() -> (computes) returns self.m +* getmin() -> (computes) returns self.minval +* getmax() -> (computes) returns self.maxval +* getstddev() -> (computes) returns self.stddev +* read() -> 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 fileserie + +Other 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). This is present in fabian but requires that images are edfs. + + +Known file formats +------------------ + +* Bruker: + + + BrukerImage + + Bruker100Image + + KcdImage: Nonius KappaCCD diffractometer + +* Mar Research: + + + MarccdImage (fileformat derived from Tiff) + + Mar345Image imaging plate with PCK compression + +* Dectris: + + + CbfImage (implements a fast byte offset de/compression scheme in python/cython) + + PilatusImage (fileformat derived from Tiff) + * EigerImage (derived from HDF5/NeXus format) + +* ESRF: + + + EdfImage: The ESRF data Format + + XsdImage: XML serialized image from EDNA + + Fit2dImage: Fit2d binary format + + Fit2dmaskImage: Fit2d Mask format + + Fit2dSpreadsheetImage: Fit2d ascii tables (spread-sheet) + +* ADSC: + + + AdscImage + +* GE detector at APS + + + GEimage + +* PNM + + + PnmImage + +* Tiff + + + TifImage + + TiffIO from PyMca + +* D3M + + + D3mImage + +* Hamamatsu + + + HiPiCImage + +* Oxford Diffraction Sapphire 3 + + + OXDimage uncompressed + + OXDimage with TY1 byte offset compression + + OXDimage with TY5 byte offset compression (experimental) + +* Nonius -> now owned by Bruker + +* HDF5: generic format for stack of images + + Hdf5Image + + EigerImage + +* Raw Binary without compression + +Installation +------------ + +Please see doc/source/INSTALL.rst + +Changelog +--------- + +Please see doc/source/Changelog.rst + +.. |Build Status| image:: https://travis-ci.org/silx-kit/fabio.svg?branch=master + :target: https://travis-ci.org/silx-kit/fabio +.. |Appveyor Status| image:: https://ci.appveyor.com/api/projects/status/4k6lol1vq30qhf66/branch/master?svg=true + :target: https://ci.appveyor.com/project/ESRF/fabio/branch/master diff --git a/copyright b/copyright new file mode 100644 index 0000000..74a36c9 --- /dev/null +++ b/copyright @@ -0,0 +1,173 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: fabio +Upstream-Contact: Jérôme Kieffer +Source: https://github.com/silx-kit/fabio/releases/tag/v0.4.0 +Files-Excluded: third_party + +Files: * +Copyright: 2007-2009 Henning O. Sorensen & Erik Knudsen + Center for Fundamental Research: Metal Structures in Four Dimensions + Risoe National Laboratory + Frederiksborgvej 399 + DK-4000 Roskilde + email:erik.knudsen@risoe.dk + 2009-2016 Jonathan P. Wright, Jerome Kieffer and Gael Goret + European Synchrotron Radiation Facility + 6 rue Jules Horowitz + 38000 Grenoble, France +License: MIT + +Files: debian/* +Copyright: 2011 Jerome Kieffer + 2013-2014 Picca Frederic-Emmanuel +License: GPL-2.0+ + +Files: fabio/raxisimage.py +Copyright: 2013-2014 Brian R. Pauw +License: MIT + +Files: fabio/mpaimage.py +Copyright: 2017 Jesse Hopkins (CHESS, USA) +License: MIT + +Files: fabio/ext/src/ccp4_pack.c + fabio/ext/inlcude/ccp4_pack.h +Copyright: 1995 Jan Pieter Abrahams + MRC Cambridge (UK) + 2007-2009 Henning O. Sorensen & Erik Knudsen + Risoe National Laboratory (DK) + 2012-2016 European Synchrotron Radiation Facility (FR) +License: LGPL-3.0+ + +Files: fabio/speimage + fabio/test/testspeimage +Copyright: 2016 University Köln, Germany +License: MIT + +Files: src/stdint.h +Copyright: 2006-2008 Alexander Chemeris +License: BSD-3 + +Files: third_party/ordereddict.py +Copyright: 2009 Raymond Hettinger +License: MIT + +Files: third_party/argparse.py +Copyright: 2006-2009 Steven J. Bethard . +License: Apache 2.0 + +Files: third_party/six.py +Copyright: 2010-2014 Benjamin Peterson +License: MIT + +License: GPL-2.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + +License: GPL-3.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +License: LGPL-3.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU Lesser General + Public License version 3 can be found in "/usr/share/common-licenses/LGPL-3". + +License: BSD-3 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + 3. The name of the author may be used to endorse or promote products + derived from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: MIT + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + +License: Apache2 + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy + of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + + diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..dbb4797 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,130 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/FabIO.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/FabIO.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/FabIO" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/FabIO" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..4b7fdee --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,170 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\FabIO.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\FabIO.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/doc/source/Changelog.rst b/doc/source/Changelog.rst new file mode 100644 index 0000000..a7ab501 --- /dev/null +++ b/doc/source/Changelog.rst @@ -0,0 +1,137 @@ +Changelog +========= + +FabIO-0.5.0 (08/2017): +...................... + +- All source files are now under MIT license (re-implement PCK/packbits in Cython) +- Context manager for fabio.open + automatic closing of file. +- Iterator over all frames in a file. +- Debian packaging for debian 8 and 9. +- Use (patched-) ordered dictionaries for storing headers. +- Many clean up and bug-fixes +- New formats: mpa, jpeg and jpeg2000 +- Provide "convert" and "viewer" scripts in the fabio-bin debian package. + + +FabIO-0.4.0 (07/2016): +...................... + +- Write support for Bruker100 (contribution from Sigmund Neher) +- Read support for Princeton instrumentation cameras (contribution from Clemens Percher) +- Read support for FIT2D binary format +- Read support for Eiger detector (Dectris) and generic HDF5 (partial) +- Switch ESRF-contributed file formats to MIT license (more liberal) +- Drop support for python 2.6, 3.2 and 3.3. Supports only 2.7 and 3.4+ +- Include TiffIO into core of FabIO (no more third-party) +- Refactor mar345 (contributed by Henri Payno) +- Enhanced byte-offset compression using Cython +- Move master repository to silx-kit (https://github.com/silx-kit) + +FabIO-0.3.0 (12/2015): +...................... + +- Migrate to PEP8 for class names. +- Use a factory & registry instead of fiddling in sys.modules for instance creation +- dim1, dim2, bpp and bytecode are properties. Use their private version while reading. +- FabioImage.header["filename"] has disappeared. Use FabioImage.filename instead. +- Automatic backported package down to debian-8 +- Compatibility checked with 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5 +- Continuous integration based on appveyor (windows) and travis (linux) +- Support for numpy 2d-array and PNM saving +- Move away from Sourceforge -> Github. + +FabIO-0.2.2 (07/2015): +...................... + +- work on the auto-documentation on ReadTheDocs (see http://fabio.readthedocs.org) +- fix regression when reading BytesIO +- Python3 compatibility +- prepare multiple package for debian + +FabIO-0.2.1 (02/2015): +...................... + +- Fix issues with variable endianness (tested PPC, PPC64le, i386, x86-64, ARM processors) +- Optimization of byte-offset reader (about 20% faster on some processors) + +FabIO-0.2.0 (01/2015): +...................... + +- Compatibility with Python3 (tested on Python 2.6, 2.7, 3.2 and 3.4) +- Support for Mar555 flat panel +- Optimization of CBF reader (about 2x faster) +- include tests into installed module (and download in /tmp) + +FabIO-0.1.4: +............ +- Work on compatibility with Python3 +- Specific debian support with test images included but no auto-generated files +- Image viewer (fabio_viewer) based on Qt4 (Thanks for Gaël Goret) +- Reading images from HDF5 datasets +- Read support for "MRC" images +- Read support for "Pixi detector (Thanks for Jon Wright) +- Read support for "Raxis" images from Rigaku (Thanks to Brian Pauw) +- Write support for fit2d mask images +- Drop support for python 2.5 + Cythonization of other algorithms + +FabIO-0.1.3: +............ +- Fixed a memory-leak in mar345 module +- Improved support for bruker format (writer & reader) +- Fixed a bug in EDF headers (very long headers) +- Provide template for new file-formats +- Fix a bug related to PIL in new MacOSX +- Allow binary-images to be read from end + +FabIO-0.1.2 (04/2013): +...................... + +- Fixed a bug in fabioimage.write (impacted all writers) +- added Sphinx documentation "python setup.py build_doc" +- PyLint compliance of some classes (rename, ...) +- tests from installer with "python setup.py build test" + +FabIO-0.1.1: +............ + +- Merged Mar345 image reader and writer with cython bindings (towards python3 compliance) +- Improve CBF image writing under windows +- Bz2, Gzip and Flat files are managed through a common way ... classes are more (python v2.5) or less (python v2.7) overloaded +- Fast EDF reading if one assumes offsets are the same between files, same for ROIs + +FabIO-0.1.0: +............ + +- OXD reader improved and writer implemented +- Mar345 reader improved and writer implemented +- CBF writer implemented +- Clean-up of the code & bug fixes +- Move towards python3 +- Make PIL optional dependency +- Preliminary Python3 support (partial). + +FabIO-0.0.8: +............ + +- Support for Tiff using TiffIO module from V.A.Solé +- Clean-up of the code & bug fixes + +FabIO-0.0.7 (03/2011): +...................... + +- Support for multi-frames EDF files +- Support for XML images/2D arrays used in EDNA +- new method: fabio.open(filename) that is an alias for fabio.openimage.openimage(filename) + +FabIO-0.0.6 (01/2011): +...................... + +- Support for CBF files from Pilatus detectors +- Support for KCD files from Nonius Kappa CCD images +- write EDF with their native data type (instead of uint16 by default) + +FabIO-0.0.4 (2009): +................... + +- Support for EDF and many other formats \ No newline at end of file diff --git a/doc/source/_static/placeholder b/doc/source/_static/placeholder new file mode 100644 index 0000000..7784424 --- /dev/null +++ b/doc/source/_static/placeholder @@ -0,0 +1 @@ +#This empty file is there to keep the directory in Git \ No newline at end of file diff --git a/doc/source/api/modules.rst b/doc/source/api/modules.rst new file mode 100644 index 0000000..da9bd35 --- /dev/null +++ b/doc/source/api/modules.rst @@ -0,0 +1,297 @@ +FabIO Package +============= + +.. toctree:: + :maxdepth: 4 + + +:mod:`fabio` Package +-------------------- + +.. automodule:: fabio + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.fabioimage` Module +------------------------------ + +.. automodule:: fabio.fabioimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.fabioutils` Module +------------------------------ + +.. automodule:: fabio.fabioutils + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.file_series` Module +------------------------------- + +.. automodule:: fabio.file_series + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.openimage` Module +----------------------------- + +.. automodule:: fabio.openimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.adscimage` Module +----------------------------- + +.. automodule:: fabio.adscimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.binaryimage` Module +------------------------------- + +.. automodule:: fabio.binaryimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.bruker100image` Module +---------------------------------- + +.. automodule:: fabio.bruker100image + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.brukerimage` Module +------------------------------- + +.. automodule:: fabio.brukerimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.cbfimage` Module +---------------------------- + +.. automodule:: fabio.cbfimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.dm3image` Module +---------------------------- + +.. automodule:: fabio.dm3image + :members: + :undoc-members: + :show-inheritance: + + +:mod:`fabio.edfimage` Module +---------------------------- + +.. automodule:: fabio.edfimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.eigerimage` Module +------------------------------ + +.. automodule:: fabio.eigerimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.fit2dimage` Module +------------------------------ + +.. automodule:: fabio.fit2dimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.fit2dmaskimage` Module +---------------------------------- + +.. automodule:: fabio.fit2dmaskimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.fit2dspreadsheetimage` Module +----------------------------------------- + +.. automodule:: fabio.fit2dspreadsheetimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.GEimage` Module +--------------------------- + +.. automodule:: fabio.GEimage + :members: + :undoc-members: + :show-inheritance: + + +:mod:`fabio.hdf5image` Module +----------------------------- + +.. automodule:: fabio.hdf5image + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.HiPiCimage` Module +------------------------------ + +.. automodule:: fabio.HiPiCimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.kcdimage` Module +---------------------------- + +.. automodule:: fabio.kcdimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.mar345image` Module +------------------------------- + +.. automodule:: fabio.mar345image + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.mrcimage` Module +---------------------------- + +.. automodule:: fabio.mrcimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.marccdimage` Module +------------------------------- + +.. automodule:: fabio.marccdimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.numpyimage` Module +------------------------------ + +.. automodule:: fabio.numpyimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.OXDimage` Module +---------------------------- + +.. automodule:: fabio.OXDimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.pilatusimage` Module +-------------------------------- + +.. automodule:: fabio.pilatusimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.pixiimage` Module +----------------------------- + +.. automodule:: fabio.pixiimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.pnmimage` Module +---------------------------- + +.. automodule:: fabio.pnmimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.raxisimage` Module +------------------------------ + +.. automodule:: fabio.raxisimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.tifimage` Module +---------------------------- + +.. automodule:: fabio.tifimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.xsdimage` Module +---------------------------- + +.. automodule:: fabio.xsdimage + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.compression` Module +------------------------------- + +.. automodule:: fabio.compression + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.converters` Module +------------------------------ + +.. automodule:: fabio.converters + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.datIO` Module +------------------------- + +.. automodule:: fabio.datIO + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.TiffIO` Module +-------------------------- + +.. automodule:: fabio.TiffIO + :members: + :undoc-members: + :show-inheritance: + +:mod:`fabio.readbytestream` Module +---------------------------------- + +.. automodule:: fabio.readbytestream + :members: + :undoc-members: + :show-inheritance: + \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..de980fa --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,240 @@ +# -*- coding: utf-8 -*- +# +# FabIO documentation build configuration file, created by +# sphinx-quickstart on Fri Mar 15 09:03:50 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import glob +import subprocess + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +try: + import sphinx.ext.mathjax +except: + print("Not using math extension for sphinx") + sys.path.append(os.path.dirname(os.path.abspath(__file__))) + import mathjax + import sphinx.ext + sphinx.ext.mathjax = mathjax + sys.modules["sphinx.ext.mathjax"] = mathjax + +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.mathjax', + 'sphinxcontrib.programoutput', +] + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'FabIO' +from fabio._version import strictversion, version, __date__ as fabio_date +year = fabio_date.split("/")[-1] +copyright = u'2006-%s, Henning Sorensen, Erik Knudsen, Jon Wright, Gael Goret, Brian Pauw and Jerome Kieffer' % (year) + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. + +# The full version, including alpha/beta/rc tags. +release = strictversion + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'FabIOdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = {'papersize': 'a4paper', + 'pointsize': '10pt'} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'FabIO.tex', u'FabIO Documentation', + u'H. Sorensen, E. Knudsen, J. Wright, \\\\ G. Goret, B. Pauw and J. Kieffer', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +latex_logo = "img/viewer.png" + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Additional stuff for the LaTeX preamble. +# latex_preamble = '' + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'fabio', u'FabIO Documentation', + [u'Henning Sorensen, Erik Knudsen, Jon Wright, \\\\ Gael Goret, B. Pauw and Jerome Kieffer'], 1) +] +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' diff --git a/doc/source/coverage.rst b/doc/source/coverage.rst new file mode 100644 index 0000000..28ae5a8 --- /dev/null +++ b/doc/source/coverage.rst @@ -0,0 +1,56 @@ +Test coverage report for fabio +============================== + +Measured on *fabio* version 0.5.0, 29/08/2017 + +.. csv-table:: Test suite coverage + :header: "Name", "Stmts", "Exec", "Cover" + :widths: 35, 8, 8, 8 + + "GEimage.py", "103", "58", "56.3 %" + "HiPiCimage.py", "62", "12", "19.4 %" + "OXDimage.py", "355", "328", "92.4 %" + "TiffIO.py", "816", "574", "70.3 %" + "__init__.py", "33", "25", "75.8 %" + "_version.py", "34", "32", "94.1 %" + "adscimage.py", "78", "49", "62.8 %" + "binaryimage.py", "56", "20", "35.7 %" + "bruker100image.py", "243", "164", "67.5 %" + "brukerimage.py", "204", "171", "83.8 %" + "cbfimage.py", "522", "223", "42.7 %" + "compression.py", "250", "189", "75.6 %" + "converters.py", "18", "15", "83.3 %" + "directories.py", "23", "18", "78.3 %" + "dm3image.py", "138", "20", "14.5 %" + "edfimage.py", "591", "391", "66.2 %" + "eigerimage.py", "103", "56", "54.4 %" + "fabioformats.py", "79", "61", "77.2 %" + "fabioimage.py", "314", "241", "76.8 %" + "fabioutils.py", "362", "286", "79.0 %" + "file_series.py", "143", "63", "44.1 %" + "fit2dimage.py", "92", "77", "83.7 %" + "fit2dmaskimage.py", "77", "74", "96.1 %" + "fit2dspreadsheetimage.py", "42", "10", "23.8 %" + "hdf5image.py", "88", "49", "55.7 %" + "jpeg2kimage.py", "81", "28", "34.6 %" + "jpegimage.py", "47", "45", "95.7 %" + "kcdimage.py", "110", "83", "75.5 %" + "mar345image.py", "270", "248", "91.9 %" + "marccdimage.py", "67", "60", "89.6 %" + "mpaimage.py", "55", "50", "90.9 %" + "nexus.py", "190", "96", "50.5 %" + "numpyimage.py", "65", "52", "80.0 %" + "openimage.py", "89", "57", "64.0 %" + "pilatusimage.py", "38", "33", "86.8 %" + "pixiimage.py", "98", "27", "27.6 %" + "pnmimage.py", "135", "86", "63.7 %" + "raxisimage.py", "103", "93", "90.3 %" + "speimage.py", "163", "158", "96.9 %" + "tifimage.py", "166", "64", "38.6 %" + "xsdimage.py", "98", "72", "73.5 %" + "convert.py", "213", "30", "14.1 %" + "mathutils.py", "11", "6", "54.5 %" + "pilutils.py", "46", "30", "65.2 %" + + "fabio total", "6871", "4524", "65.8 %" + diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst new file mode 100644 index 0000000..c58b4af --- /dev/null +++ b/doc/source/getting_started.rst @@ -0,0 +1,289 @@ +Getting Started +=============== + +FabIO is a Python module for reading and handling data from two-dimensional X-ray +detectors. + + +FabIO is a Python module written for easy and transparent reading +of raw two-dimensional data from various X-ray detectors. The +module provides a function for reading any image and returning a +FabioImage object which contains both metadata (header information) +and the raw data. All FabioImage object offer additional methods to +extract information about the image and to open other detector +images from the same data series. + + +Introduction +------------ + +One obstacle when writing software to analyse data collected from a +two-dimensional detector is to read the raw data into the program, +not least because the data can be stored in many different formats +depending on the instrument used. To overcome this problem we +decided to develop a general module, FabIO (FABle I/O), to handle +reading and writing of two-dimensional data. The code-base was +initiated by merging parts of our fabian imageviewer and +ImageD11 peak-search programs and has been developed +since 2007 as part of the TotalCryst program suite for +analysis of 3DXRD microscopy data. During integration into +a range of scientific programs like the FABLE graphical interface, +EDNA and the fast azimuthal integration library, +pyFAI; FabIO has gained several features like handling +multi-frame image formats as well as writing many of the file +formats. + + +FabIO Python module +------------------- + +Python is a scripting language that is very popular among +scientists and which also allows well structured applications and +libraries to be developed. + +Philosophy +.......... + +The intention behind this development was to create a Python module +which would enable easy reading of 2D data images, from any +detector without having to worry about the file format. Therefore +FabIO just needs a file name to open a file and it determines the +file format automatically and deals with gzip and bzip2 +compression transparently. Opening a file returns an object +which stores the image in memory as a 2D NumPy array +and the metadata, called header, in a Python dictionary. +Beside the data and header attributes, some methods are +provided for reading the previous or next image in a series of +images as well as jumping to a specific file number. For the user, +these auxiliary methods are intended to be independent of the image +format (as far as is reasonably possible). + +FabIO is written in an object-oriented style (with classes) but +aims at being used in a scripting environment: special care has +been taken to ensure the library remains easy to use. Therefore no +knowledge of object-oriented programming is required to get full +benefits of the library. As the development is done in a +collaborative and decentralized way; a comprehensive test suite has +been added to reduce the number of regressions when new features +are added or old problems are repaired. The software is very +modular and allows new classes to be added for handling other data +formats easily. FabIO and its source-code are freely available to +everyone on-line, licensed under the GNU General Public +License version 3 (GPLv3). FabIO is also available directly from +popular Linux distributions like Debian and Ubuntu. + +Implementation +.............. + +The main language used in the development of FabIO is Python; +however, some image formats are compressed and require +compression algorithms for reading and writing data. When such +algorithms could not be implemented efficiently using Python or +NumPy native modules were developed, in i.e. standard C code +callable from Python (sometimes generated using Cython). +This code has to be compiled for each computer architecture and +offers excellent performance. FabIO is only dependent on the NumPy +module and has extra features if two other optional Python modules +are available. For reading XML files (that are used in EDNA) the +Lxml module is required and the Python Image Library, PIL +is needed for producing a PIL image for displaying the image +in graphical user interfaces and several image-processing +operations that are not re-implemented in FabIO. A variety of +useful image processing is also available in the scipy.ndimage +module and in scikits-image. + +Images can also be displayed in a convenient interactive manner +using matplotlib and an IPython shell , which +is mainly used for developing data analysis algorithms. Reading and +writing procedure of the various TIFF formats is based on the +TiffIO code from PyMCA. + +In the Python shell, the `fabio` module must be imported prior to +reading an image in one of the supported file formats (see Table +`Supported formats`, hereafter). +The `fabio.open` function creates an instance of the +Python class `fabioimage`, from the name of a file. This instance, +named `img` hereafter, stores the image data in `img.data` as a 2D +NumPy array. Often the image file contains more information than +just the intensities of the pixels, e.g. information about how the +image is stored and the instrument parameters at the time of the +image acquisition, these metadata are usually stored in the file +header. Header information, are available in `img.header` as a +Python dictionary where keys are strings and values are usually +strings or numeric values. + +Information in the header about the binary part of the image +(compression, endianness, shape) are interpreted however, other +metadata are exposed as they are recorded in the file. FabIO allows +the user to modify and, where possible, to save this information +(the table `Supported formats` summarizes writable formats). +Automatic translation +between file-formats, even if desirable, is sometimes impossible +because not all format have the capability to be extended with +additional metadata. Nevertheless FabIO is capable of converting +one image data-format into another by taking care of the numerical +specifics: for example float arrays are converted to integer arrays +if the output format only accepts integers. + +FabIO methods +............. + +One strength of the implementation in an object oriented language +is the possibility to combine functions (or methods) together with +data appropriate for specific formats. In addition to the header +information and image data, every `fabioimage` instance (returned +by `fabio.open`) has methods inherited from `fabioimage` which +provide information about the image minimum, maximum and mean +values. In addition there are methods which return the file number, +name etc. Some of the most important methods are specific for +certain formats because the methods are related to how frames in a +sequence are handled; these methods are `img.next()`, +`img.previous()`, and `img.getframe(n)`. The behaviour of such +methods varies depending on the image format: for single-frame +format (like mar345), `img.next()` will return the image in next +file; for multi-frame format (like GE), `img.next()` will return +the next frame within the same file. For formats which are possibly +multi-framed like EDF, the behaviour depends on the actual number +of frames per file (accessible via the `img.nframes` attribute). + +Usage +----- + +Examples +........ + +In this section we have collected some basic examples of how FabIO +can be employed. + +Opening an image: + +.. code-block:: python + + import fabio + im100 = fabio.open('Quartz_0100.tif') # Open image file + print(im0.data[1024,1024]) # Check a pixel value + im101 = im100.next() # Open next image + im270 = im1.getframe(270) # Jump to file number 270: Quartz_0270.tif + +Normalising the intensity to a value in the header: + +.. code-block:: python + + img = fabio.open('exampleimage0001.edf') + print(img.header) + {'ByteOrder': 'LowByteFirst', + 'DATE (scan begin)': 'Mon Jun 28 21:22:16 2010', + 'ESRFCurrent': '198.099', + ... + } + # Normalise to beam current and save data + srcur = float(img.header['ESRFCurrent']) + img.data *= 200.0/srcur + img.write('normed_0001.edf') + +Interactive viewing with matplotlib: + +.. code-block:: python + + from matplotlib import pyplot # Load matplotlib + pyplot.imshow(img.data) # Display as an image + pyplot.show() # Show GUI window + +Future and perspectives +----------------------- + +The Hierarchical Data Format version 5 (`hdf5`) is a data format which +is increasingly popular for storage of X-ray and neutron data. To +name a few facilities the synchrotron Soleil and the neutron +sources ISIS, SNS and SINQ already use HDF extensively through the +NeXus format. For now, mainly processed or curated data are +stored in this format but new detectors (Eiger from Dectris) are natively +saving data in HDF5. FabIO will rely on H5Py, which +already provides a good HDF5 binding for Python, as an external +dependency, to be able to read and write such HDF5 files. +This starts to be available in version 0.4.0. + +Conclusion +---------- + +FabIO gives an easy way to read and write 2D images when using the +Python computer language. It was originally developed for X-ray +diffraction data but now gives an easy way for scientists to access +and manipulate their data from a wide range of 2D X-ray detectors. +We welcome contributions to further improve the code and hope to +add more file formats in the future. + +Acknoledgements +............... + +We acknowledge Andy Götz and Kenneth Evans for extensive +testing when including the FabIO reader in the Fable image viewer +(Götz et al., 2007).We also thank V. Armando Solé for assistance with +his TiffIO reader and Carsten Gundlach for deployment of FabIO at +the beamlines i711 and i811, MAX IV, and providing bug reports. We +finally acknowledge our colleagues who have reported bugs and +helped to improve FabIO. Financial support was granted by the EU +6th Framework NEST/ADVENTURE project TotalCryst (Poulsen et +al., 2006). + + +Citation +........ + + +Knudsen, E. B., Sørensen, H. O., Wright, J. P., Goret, G. & Kieffer, J. (2013). J. Appl. Cryst. 46, 537-539. + +http://dx.doi.org/10.1107/S0021889813000150 + + +List of file formats that FabIO can read and write +.................................................. + +In alphabetical order. The listed filename extensions are typical examples. +FabIO tries to deduce the actual format from the file itself and only +uses extensions as a fallback if that fails. + +.. csv-table:: Supported formats + :header: "Python Module", "Detector / Format", "Extension", "Read", "Multi-image", "Write" + :widths: 30, 30, 20, 10, 15, 10 + + "ADSC", "ADSC Quantum", ".img ", "Yes", "No", "Yes" + "Bruker86", "Bruker formats", ".sfrm ", "Yes", "No", "Yes" + "Bruker100", "Bruker formats", ".sfrm ", "Yes", "No", "Yes" + "CBF", "CIF binary files", ".cbf ", "Yes", "No", "Yes" + "DM3", "Gatan Digital Micrograph ", ".dm3 ", "Yes", "No", "No" + "EDF", "ESRF data format ", ".edf ", "Yes", "Yes ", "Yes" + "EDNA-XML", "Used by EDNA", ".xml ", "Yes", "No", "No" + "Eiger", "Dectris format", ".h5", "Yes", "Yes", "Yes" + "Fit2D", "Fit2D binary format", ".f2d", "Yes", "No", "No" + "Fit2D mask", "Fit2D mask", ".msk ", "Yes", "No", "Yes" + "Fit2D spreadsheet", "Fit2D Ascii format", ".spr ", "Yes", "No", "Yes" + "GE", "General Electric", "No", "Yes", "Yes ", "No" + "JPEG", "Joint Photographic Experts Group", ".jpg", "Yes", "No", "No" + "JPEG2k", "JPEG 2000", ".jpx", "Yes", "No", "No" + "Hdf5", "Needs the dataset path", ".h5", "Yes", "Yes", "No" + "HiPiC", "Hamamatsu CCD", ".tif ", "Yes", "No", "No" + "kcd", "Nonius KappaCCD", ".kccd ", "Yes", "No", "No" + "marccd", "MarCCD/Mar165", ".mccd ", "Yes", "No", "No" + "mar345", "Mar345 image plate", ".mar3450 ", "Yes", "No", "Yes" + "mpa", "Multi-wire detector", ".mpa", "yes", "No", "No" + "numpy", "numpy 2D array", "npy ", "Yes", "No", "Yes" + "OXD", "Oxford Diffraction", ".img ", "Yes", "No", "Yes" + "Pixi", "pixi", ". ", "Yes", "No", "No" + "pilatus", "Dectris Pilatus Tiff", ".tif ", "Yes", "No", "Yes" + "PNM", "Portable aNy Map", ".pnm ", "Yes", "No", "Yes" + "Raxis", "Rigaku Saxs format", ".img", "Yes", "No", "No" + "spe", "Princeton instrumentation", ".spe", "Yes, "Yes", "No" + "TIFF", "Tagged Image File Format", ".tif ", "Yes", "No", "Yes" + +Adding new file formats +....................... + +We hope it will be relatively easy to add new file formats to FabIO in the future. +Please refere at the *fabio/templateimage.py* file in the source which describes +how to add a new format. + + + + + diff --git a/doc/source/img/viewer.png b/doc/source/img/viewer.png new file mode 100644 index 0000000..a6cf3e0 Binary files /dev/null and b/doc/source/img/viewer.png differ diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..ad7daec --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,29 @@ +.. FabIO documentation master file, created by + sphinx-quickstart on Fri Mar 15 09:03:50 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to FabIO's documentation! +================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + getting_started + install + tutorials/index + performances + Changelog + man/fabio_viewer + api/modules + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/source/install.rst b/doc/source/install.rst new file mode 100644 index 0000000..7df5a42 --- /dev/null +++ b/doc/source/install.rst @@ -0,0 +1,337 @@ +:Author: Jérôme Kieffer +:Date: 29/08/2017 +:Keywords: Installation procedure +:Target: System administrators + +Installation +============ + +FabIO can, as any Python module, be installed from its sources, +available on the `Python cheese shop `_ +but we advice to use binary wheels packages provided for the most common platforms: +Windows, MacOSX. For Debian Linux and its derivatives (Ubuntu, Mint, ...), FabIO +is part of the distributions and itss package is named *python-fabio* and can be installed via: + +.. code:: + + sudo apt-get install python-fabio + +If you are using MS Windows or MacOSX; binary version (as wheel packages) are +PIP-installable. +PIP is the Python Installer Program, similar to ``apt-get`` for Python. +It runs under any architecture. +Since Python 2.7.10 and 3.4, PIP is installed together with Python itself. +If your Python is elder, PIP can be simply `downloaded `_ +and executed using your standard Python: + +.. code:: + + python get-pip.py + pip install fabio + +Installation under windows +-------------------------- + +Install `Python `_ from the official web page. +I would recommend Python 2.7 in 64 bits version if your operating system allows it. +Python3 (>=3.4) is OK. + +If you are looking for an integrated scientific Python distribution on Windows, +`WinPython `_ is a good one, the Python2.7, 64 bit +version is advised. + +It comes with pip pre-installed and configured. + +Installation using PIP: +....................... + +If you use a Python2 elder than 2.7.10 or a Python3 <3.4, you will need +`Download PIP `_. +Then install the wheel package manager and all dependencies for : + +:: + + python get-pip.py + pip install setuptools + pip install wheel + pip install fabio + +Note: for now, PyQt4 is not yet pip-installable. you will need to get it from riverbankcomputing: +http://www.riverbankcomputing.co.uk/software/pyqt/download + +Manual installation under windows +................................. + +You will find all the `scientific Python stack packaged for Windows `_ on Christoph +Gohlke' page (including FabIO): + +Pay attention to the Python version (both number and architecture). +**DO NOT MIX 32 and 64 bits version**. +To determine the version and architecture width of the Python interpreter: + +.. code-block:: python + + >>> import sys + >>> print(sys.version) + 2.7.9 (default, Mar 1 2015, 12:57:24) + >>> print("%s bits"%(8 * tuple.__itemsize__)) + 64 bits + +Installation from sources +......................... + +* Retrieve the sources from github: + + + `The master development branch `_ + + `The latest release `_ + +* unzip the file in a directory +* open a console (cmd.exe) in this directory. +* install the required dependencies using PIP:: + + pip install -r ci/requirements_appveyor.txt --trusted-host www.silx.org + +Get the compiler and install it +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The version of the compiler and the version of the Microsoft SDK +have to match the Python version you are using. Here are a couple of examples: + +* Python2.7: `Microsoft compiler 2008 `_ +* Python 3.5: `Microsoft Visual studio community edition 2015 `_ + +Compile the sources +^^^^^^^^^^^^^^^^^^^ + +:: + + python setup.py build + python setup.py test + pip install . + +Testing version of FabIO +........................ + +Continuous integration runs the complete test suite on multiple operating +systems and python version. +Under Windows, this is done using the +`AppVeyor cloud service `_ +Select the environment which matches your setup like +**Environment: PYTHON=C:\Python34-x64, PYTHON_VERSION=3.4.3, PYTHON_ARCH=64** +and go to **artifacts** where wheels and MSI-installers are available. + + +Installation on MacOSX +---------------------- + +Python 2.7, 64 bits and numpy are natively available on MacOSX. + +Install via PIP +............... + +Since MacOSX 10.11 (El-Captain), PIP is available as part of the standard python installation. +For elder MacOSX, `download PIP and run `_. +Then install FabIO directly: + +.. code:: + + sudo pip install fabio + + +**Note:** for now, PyQt4, used by the *fabio-viewer* is not yet pip-installable. +You will need to get it from +`riverbankcomputing `_. + +Compile from sources +.................... + +Get the compiler +^^^^^^^^^^^^^^^^ +Apple provides for free Xcode which contains the compiler needed to build binary extensions. +Xcode can be installed from the App-store. + +Compile the sources +^^^^^^^^^^^^^^^^^^^ + +Once done, follow the classical procedure (similar to Windows or Linux): + +* Retrieve the sources from github: + + + `The master development branch `_ + + `The latest release `_ + +* unzip the file in a directory +* open a terminal in the unzipped archive directory +* run:: + + sudo pip install -r ci/requirements_travis.txt --trusted-host www.silx.org + python setup.py build + python setup.py test + sudo pip install . + + +Manual Installation for any operating system +-------------------------------------------- + +Install the dependencies +........................ + +Most Linux distribution come with a Python environment configured. Complete +it with the needed dependencies. + +* Python 2.7 or 3.4+ +* numpy - http://www.numpy.org + +For full functionality of FabIO the following modules need to be installed: + +* Pillow (python imaging library) - http://www.pythonware.com +* lxml (library for reading XSDimages) +* PyQt4 for the fabio_viewer program + +Once done, follow the classical procedure (similar to Windows or MacOSX): + +* Retrieve the sources from github: + + + `The master development branch `_ + + `The latest release `_ + +* unzip the file in a directory +* open a terminal in the unzipped archive directory +* run:: + + sudo pip install -r ci/requirements_travis.txt --trusted-host www.silx.org + python setup.py build + python setup.py test + sudo pip install . + + +Most likely you will need to gain root privileges (with sudo in front of the +command) to install packages. + +Development versions +-------------------- +The newest development version can be obtained by checking it out from the git repository: + +:: + + git clone https://github.com/silx-kit/fabio + cd fabio + python setup.py build test + sudo pip install . + +For Ubuntu/Debian users, you will need: + +* python-imaging +* python-imaging-tk +* python-numpy +* python-dev + +:: + + sudo apt-get install python-imaging python-imaging-tk python-numpy + +Automatic debian packaging +.......................... + +Debian 6 and 7: +^^^^^^^^^^^^^^^ +We provide a debian-package builder based on stdeb, building a package for Python2: + +:: + + sudo apt-get install python-stdeb + ./build-deb.sh + +which builds a debian package and installs them in a single command. +Handy for testing, but very clean, see hereafter + +Debian 8 and newer +^^^^^^^^^^^^^^^^^^ + +The same script, *build-deb.sh*, will create *real* debian packages: +It will build a bunch of 6 debian packages:: + +* *fabio-bin*: the GUI for visualizing diffraction images +* *fabio-doc*: the documumentation package +* *python3-fabio*: library built for Python3 +* *python3-fabio-dbg*: debug symbols for Python3 +* *python-fabio*: library built for Python2 +* *python-fabio-dbg*: debug symbols for Python2 + +For this, you need a complete debian build environment: + +:: + + sudo apt-get install cython cython-dbg cython3 cython3-dbg debhelper dh-python \ + python-all-dev python-all-dbg python-h5py \ + python-lxml python-lxml-dbg python-matplotlib python-matplotlib-dbg python-numpy\ + python-numpy-dbg python-qt4 python-qt4-dbg python-sphinx \ + python-sphinxcontrib.programoutput python-tk python-tk-dbg python3-all-dev python3-all-dbg \ + python3-lxml python3-lxml-dbg python3-matplotlib \ + python3-matplotlib-dbg python3-numpy python3-numpy-dbg python3-pyqt4 python3-pyqt4-dbg \ + python3-sphinx python3-sphinxcontrib.programoutput \ + python3-tk python3-tk-dbg python3-pil-dbg python3-setuptools devscripts + + ./build-deb.sh + +This script works the same way with Debian-9 stretch and newer. + +Test suite +---------- + +FabIO has a comprehensive test-suite to ensure non regression. +When you run the test for the first time, many test images will be download and converted into various compressed format like gzip and bzip2 (this takes a lot of time). + +Be sure you have an internet connection and your proxy setting are correctly defined in the environment variable *http_proxy*. +For example if you are behind a firewall/proxy: + +Under Linux and MacOSX:: + + export http_proxy=http://proxy.site.org:3128 + +Under Windows:: + + set http_proxy=http://proxy.site.org:3128 + +Where *proxy.site.org* and *3128* correspond to the proxy server and port on your network. +At ESRF, you can get this piece of information by phoning to the hotline: 24-24. + +Many tests are there to deal with malformed files, don't worry if the programs complains in warnings about "bad files", +it is done on purpose to ensure robustness in FabIO. + + +Run test suite from installation directory +.......................................... + +To run the test: + +:: + + python setup.py build test + + +Run test suite from installed version +..................................... + +Within Python (or ipython): + +.. code-block:: python + + >>> import fabio + >>> fabio.tests() + + +Test coverage +............. + +FabIO comes with 37 test-suites (179 tests in total) representing a coverage of 66%. +This ensures both non regression over time and ease the distribution under different platforms: +FabIO runs under Linux, MacOSX and Windows (in each case in 32 and 64 bits) with Python versions 2.7, 3.4, 3.6 and 3.6. +Under linux it has been tested on i386, x86_64, arm, ppc, ppc64le. +FabIO may run on other untested systems but without warranty. + +.. toctree:: + :maxdepth: 2 + + coverage + diff --git a/doc/source/man/fabio_viewer.rst b/doc/source/man/fabio_viewer.rst new file mode 100644 index 0000000..e2a5411 --- /dev/null +++ b/doc/source/man/fabio_viewer.rst @@ -0,0 +1,11 @@ +FabIO Viewer +============ + +fabio_viewer is a simple diffraction image viewer based on matplotlib and PyQt4. + +.. image:: ../img/viewer.png + +.. command-output:: fabio_viewer --help + :nostderr: + + diff --git a/doc/source/mathjax.py b/doc/source/mathjax.py new file mode 100644 index 0000000..fb3ff4a --- /dev/null +++ b/doc/source/mathjax.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +""" + sphinx.ext.mathjax + ~~~~~~~~~~~~~~~~~~ + + Allow `MathJax `_ to be used to display math in + Sphinx's HTML writer -- requires the MathJax JavaScript library on your + webserver/computer. + + :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from docutils import nodes + +from sphinx.application import ExtensionError +from sphinx.ext.mathbase import setup_math as mathbase_setup + + +def html_visit_math(self, node): + self.body.append(self.starttag(node, 'span', '', CLASS='math')) + self.body.append(self.builder.config.mathjax_inline[0] + + self.encode(node['latex']) + + self.builder.config.mathjax_inline[1] + '') + raise nodes.SkipNode + +def html_visit_displaymath(self, node): + self.body.append(self.starttag(node, 'div', CLASS='math')) + if node['nowrap']: + self.body.append(self.builder.config.mathjax_display[0] + + node['latex'] + + self.builder.config.mathjax_display[1]) + self.body.append('') + raise nodes.SkipNode + + parts = [prt for prt in node['latex'].split('\n\n') if prt.strip()] + for i, part in enumerate(parts): + part = self.encode(part) + if i == 0: + # necessary to e.g. set the id property correctly + if node['number']: + self.body.append('(%s)' % + node['number']) + if '&' in part or '\\\\' in part: + self.body.append(self.builder.config.mathjax_display[0] + + '\\begin{split}' + part + '\\end{split}' + + self.builder.config.mathjax_display[1]) + else: + self.body.append(self.builder.config.mathjax_display[0] + part + + self.builder.config.mathjax_display[1]) + self.body.append('\n') + raise nodes.SkipNode + +def builder_inited(app): + if not app.config.mathjax_path: + raise ExtensionError('mathjax_path config value must be set for the ' + 'mathjax extension to work') + app.add_javascript(app.config.mathjax_path) + + +def setup(app): + mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) + app.add_config_value('mathjax_path', + 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?' + 'config=TeX-AMS-MML_HTMLorMML', False) + app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html') + app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html') + app.connect('builder-inited', builder_inited) + diff --git a/doc/source/performances.rst b/doc/source/performances.rst new file mode 100644 index 0000000..de93956 --- /dev/null +++ b/doc/source/performances.rst @@ -0,0 +1,44 @@ +Benchmarks +========== + +Those benchmarks have been done with all data already in cache using a Intel Xeon E5520 @ 2.27GHz +running Debian 7 and FabIO 0.2.2... Those data are now out-dated. + +.. table:: Execution time for reading a file, benchmarked using the *timeit* module. + :class: w + + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | FabIO module | Filename | Size | Py2.7 v0.1.4 | Py2.7 v0.2.0 | Py3.2 v0.2.0 | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | adscimage | mb_LP_1_001.img | 9 Mpix | 1.16 s | 1.12 s | 2.67 s | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | brukerimage | Cr8F8140k103.0026 | 256kpix| 796 µs | 795 µs | 1.43 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | cbfimage | run2_1_00148.cbf | 6 Mpix | 173 ms | 70.8 ms | 70.8 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | edfimage | F2K_Seb_Lyso0675.edf | 4 Mpix | 512 µs | 597 µs | 595 µs | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | fit2dmaskimage| fit2d_click.msk | 1 Mpix | 30.4 ms | 30.5 ms | 28.4 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | GEimage |GE_aSI_detector_image_1529 | 4 Mpix | 5.37 ms | 5.44 ms | 4.3 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | kcdimage | i01f0001.kcd | 360kpix| 130 ms | 121 ms | 292 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | mar345image | example.mar2300 | 5 Mpix | 78 ms | 77 ms | 77 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | marccdimage | corkcont2_H_0089.mccd | 4 Mpix | 9.28 ms | 9.01 ms | 17.2 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | OXDimage | b191_1_9_1.img | 256kpix| 5.75 ms | 5.67 ms | 8.35 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | pnmimage | image0001.pgm | 1 Mpix | 3.29 ms | 3.25 ms | 5.71 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | raxisimage | mgzn-20hpt.img | 3 Mpix | 53.5 ms | 57.1 ms | 69.2 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | tifimage | oPPA_5grains_0001.tif | 4 Mpix | 59.9 ms | 58.4 ms | 105 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + | xsdimage | XSDataImage.xml | 256kpix| 13.3 ms | 12.9 ms | 18.4 ms | + +---------------+---------------------------+--------+--------------+--------------+--------------+ + +The Python3 version is sometimes twice slower then the Python2 version. +As the codebase is the same this regression is not due to FabIO but to the programming language itself. +The Performances obtained using Python3.4+ is now again close to the one of Python2.7. diff --git a/doc/source/tutorials/Nexus2cbf.ipynb b/doc/source/tutorials/Nexus2cbf.ipynb new file mode 100644 index 0000000..b14afaf --- /dev/null +++ b/doc/source/tutorials/Nexus2cbf.ipynb @@ -0,0 +1,1062 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Nexus -> CBF #\n", + "In this tutorial we will see how to export a Nexus archive produced by the Eiger detector from Dectris into a bunch of CBF files, similar to the one generated by Pilatus detectors, using the FabIO library to write images (and h5py which actually reads them).\n", + "\n", + "**Nota:** HDF5 files produced by Nexus detector use a specific LZ4/bitshuffle plugin for reading/writing. They require recent version of hdf5 (>= 1.8.10 ), h5py (>= 2.5.0) and those plugins installed:\n", + "\n", + "* https://github.com/nexusformat/HDF5-External-Filter-Plugins/tree/master/LZ4 \n", + "* https://github.com/kiyo-masui/bitshuffle\n", + "\n", + "Under Windows, those plugins can easily be installed via this repository which provides binary DLLs: \n", + "https://github.com/silx-kit/hdf5plugin\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "#Run as first to set the plugin path, very important to handle Eiger data:\n", + "import os\n", + "os.environ[\"HDF5_PLUGIN_PATH\"]=\"/usr/lib/x86_64-linux-gnu/hdf5/plugins\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import fabio" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this example we will use the Eiger 4M dataset which can be obtained from Dectris: \n", + "https://www.dectris.com/datasets.html. You may register to get download access." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Eiger dataset with 1800 frames from collect_01_00001_master.h5\n" + ] + } + ], + "source": [ + "images = fabio.open(\"collect_01_00001_master.h5\")\n", + "print(images)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": false + }, + "source": [ + "Each \"EigerImage\" object contains a list to the corresponding HDF5 opened with h5py.\n", + "So one can retrieve all metadata associated:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "beam_center_x: 1051.0\n", + "beam_center_y: 1001.0\n", + "bit_depth_readout: 32\n", + "count_time: 0.099996\n", + "countrate_correction_applied: 0\n", + "description: b'Dectris Eiger 4M'\n", + "detectorSpecific: unprintable\n", + "detector_distance: 0.00733\n", + "detector_number: b'E-08-0102'\n", + "detector_readout_time: 3.78e-06\n", + "efficiency_correction_applied: 0\n", + "flatfield_correction_applied: 1\n", + "frame_time: 0.1\n", + "geometry: unprintable\n", + "pixel_mask_applied: 0\n", + "sensor_material: b'Si'\n", + "sensor_thickness: 0.00032\n", + "threshold_energy: 5635.65\n", + "virtual_pixel_correction_applied: 1\n", + "x_pixel_size: 7.5e-05\n", + "y_pixel_size: 7.5e-05\n" + ] + } + ], + "source": [ + "header = {}\n", + "for key, value in images.h5[\"entry/instrument/detector\"].items():\n", + " try:\n", + " val = value[()]\n", + " except:\n", + " print(\"%s: unprintable\"%key)\n", + " else:\n", + " print(\"%s: %s\"%(key, val))\n", + " header[key] = val\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": false + }, + "source": [ + "Now we can translate every single image into a CBF file, here we do only a dozen of then:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "collect_01_00001_0000.cbf\n", + "collect_01_00001_0001.cbf\n", + "collect_01_00001_0002.cbf\n", + "collect_01_00001_0003.cbf\n", + "collect_01_00001_0004.cbf\n", + "collect_01_00001_0005.cbf\n", + "collect_01_00001_0006.cbf\n", + "collect_01_00001_0007.cbf\n", + "collect_01_00001_0008.cbf\n", + "collect_01_00001_0009.cbf\n", + "collect_01_00001_0010.cbf\n", + "collect_01_00001_0011.cbf\n" + ] + } + ], + "source": [ + "for idx, frame in enumerate(images):\n", + " cbf = fabio.cbfimage.cbfimage(header=header,data=frame.data)\n", + " fname = \"collect_01_00001_%04i.cbf\"%idx\n", + " cbf.write(fname)\n", + " print(fname)\n", + " if idx>10: \n", + " break" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is how to display an image using the notebook backend: " + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Populating the interactive namespace from numpy and matplotlib\n" + ] + } + ], + "source": [ + "%pylab nbagg" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/scisoft/users/jupyter/jupy34/lib/python3.4/site-packages/ipykernel/__main__.py:1: RuntimeWarning: divide by zero encountered in log\n", + " if __name__ == '__main__':\n" + ] + }, + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " this.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width);\n", + " canvas.attr('height', height);\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('