-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c050867
commit 4b489ad
Showing
9 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from . import file_formats | ||
|
||
|
||
def load_data(path, fmt=None, h5out=None) | ||
"""Load experimental data | ||
|
||
Parameters | ||
---------- | ||
path: str | ||
Path to experimental data file or folder | ||
fmt: str | ||
The file format to use (see `file_formats.formats`). | ||
If set to `None`, the file format will be guessed. | ||
h5out: str | ||
Path to an hdf5 output file where all data | ||
will be written. If set to `None`, nothing | ||
is written to disk. | ||
meta_data: dict | ||
Meta data (see `qpimage.meta.VALID_META_KEYS`) | ||
|
||
Returns | ||
------- | ||
dataobj: `file_formats.Group` or `file_formats.Single` | ||
A qpformat data object with unified access to the | ||
experimental data. | ||
""" | ||
if fmt is None: | ||
fmt = file_formats.guess_format(path) | ||
|
||
dataobj = file_formats.formats_dict[fmt](path) | ||
|
||
if h5out is not None: | ||
# TODO: | ||
# - store data in h5file using qimage | ||
pass | ||
|
||
return dataobj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from .group_folder import GroupFolder | ||
from .group_hdf5_qpimage import GroupHdf5Qimage | ||
from .group_zip_tif_phasics import GroupZipTifPhasics | ||
from .single_hdf5_qimage import SingleHdf5Qimage | ||
from .single_tif_phasics import SingleTifPhasics | ||
|
||
|
||
def guess_format(path): | ||
"""Determine the file format of a folder or a file""" | ||
for fmt in formats: | ||
if fmt.verify(path): | ||
return path | ||
|
||
|
||
# the order is important for | ||
formats = [GroupFolder, | ||
GroupZipTifPhasics, | ||
GroupHdf5Qimage, | ||
SingleHdf5Qimage, | ||
SingleTifPhasics, | ||
] | ||
|
||
|
||
# convenience dictionary | ||
formats_dict = {} | ||
for _fmt in formats: | ||
formats_dict[_fmt.name] = _fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import abc | ||
|
||
class Group(object): | ||
__meta__ = abs.ABCMeta | ||
|
||
@abc.abstractmethod | ||
def verify(path): | ||
"""Verify that `path` has this file format | ||
Returns `True` if the file format matches. | ||
""" | ||
|
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import abc | ||
|
||
class Single(object): | ||
__meta__ = abs.ABCMeta | ||
|
||
@abc.abstractmethod | ||
def verify(path): | ||
"""Verify that `path` has this file format | ||
Returns `True` if the file format matches. | ||
""" | ||
|
Empty file.
Empty file.