Skip to content

Commit

Permalink
Merge pull request #3539 from tifuchs/fio_support
Browse files Browse the repository at this point in the history
LGTM

CI fails due to another issue with `pywin32` with `pyside2`.
  • Loading branch information
t20100 authored Nov 2, 2021
2 parents 4b8b9e5 + c812017 commit 84e2716
Show file tree
Hide file tree
Showing 7 changed files with 866 additions and 6 deletions.
35 changes: 35 additions & 0 deletions doc/source/modules/io/fioh5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

.. currentmodule:: silx.io

:mod:`fioh5`: h5py-like API to FIO file
----------------------------------------

.. automodule:: silx.io.fioh5


Classes
+++++++

- :class:`FioH5`
- :class:`FioFile`

.. autoclass:: FioH5
:members:
:show-inheritance:
:undoc-members:
:inherited-members: name, basename, attrs, h5py_class, parent,
get, keys, values, items,
:special-members: __getitem__, __len__, __contains__, __enter__, __exit__, __iter__
:exclude-members: add_node

.. autoclass:: FioFile

.. autoclass:: silx.io.commonh5.Group
:show-inheritance:
:undoc-members:
:members: name, basename, file, attrs, h5py_class, parent,
get, keys, values, items, visit, visititems
:special-members: __getitem__, __len__, __contains__, __iter__
:exclude-members: add_node

.. autofunction:: is_fiofile
1 change: 1 addition & 0 deletions doc/source/modules/io/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
specfile.rst
specfilewrapper.rst
spech5.rst
fioh5.rst
url.rst
utils.rst
h5py_utils.rst
Expand Down
34 changes: 29 additions & 5 deletions src/silx/app/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import silx.io
from silx.io.specfile import is_specfile
from silx.io.fioh5 import is_fiofile
from silx.io import fabioh5

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -167,6 +168,26 @@ def contains_specfile(filenames):
return False


def contains_fiofile(filenames):
"""Return True if any file in a list are FIO files.
:param List[str] filenames: list of filenames
"""
for fname in filenames:
if is_fiofile(fname):
return True
return False


def are_all_fiofile(filenames):
"""Return True if all files in a list are FIO files.
:param List[str] filenames: list of filenames
"""
for fname in filenames:
if not is_fiofile(fname):
return False
return True


def main(argv):
"""
Main function to launch the converter as an application
Expand All @@ -178,11 +199,12 @@ def main(argv):
parser.add_argument(
'input_files',
nargs="*",
help='Input files (EDF, TIFF, SPEC...). When specifying multiple '
'files, you cannot specify both fabio images and SPEC files. '
'Multiple SPEC files will simply be concatenated, with one '
'entry per scan. Multiple image files will be merged into '
'a single entry with a stack of images.')
help='Input files (EDF, TIFF, FIO, SPEC...). When specifying '
'multiple files, you cannot specify both fabio images '
'and SPEC (or FIO) files. Multiple SPEC or FIO files will '
'simply be concatenated, with one entry per scan. '
'Multiple image files will be merged into a single '
'entry with a stack of images.')
# input_files and --filepattern are mutually exclusive
parser.add_argument(
'--file-pattern',
Expand Down Expand Up @@ -459,6 +481,7 @@ def check_gzip_compression_opts(value):

if (len(options.input_files) > 1 and
not contains_specfile(options.input_files) and
not contains_fiofile(options.input_files) and
not options.add_root_group) or options.file_pattern is not None:
# File series -> stack of images
input_group = fabioh5.File(file_series=options.input_files)
Expand All @@ -474,6 +497,7 @@ def check_gzip_compression_opts(value):

elif len(options.input_files) == 1 or \
are_all_specfile(options.input_files) or\
are_all_fiofile(options.input_files) or\
options.add_root_group:
# single file, or spec files
h5paths_and_groups = []
Expand Down
2 changes: 1 addition & 1 deletion src/silx/io/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
by *silx* into HDF5 file. Currently, SPEC file and fabio images are the
supported formats.
Read the documentation of :mod:`silx.io.spech5` and :mod:`silx.io.fabioh5` for
Read the documentation of :mod:`silx.io.spech5`, :mod:`silx.io.fioh5` and :mod:`silx.io.fabioh5` for
information on the structure of the output HDF5 files.
Text strings are written to the HDF5 datasets as variable-length utf-8.
Expand Down
Loading

0 comments on commit 84e2716

Please sign in to comment.