Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
1fe384e4
Commit
1fe384e4
authored
Apr 07, 2021
by
payno
Browse files
[TomoScanBase] add properties `sequence_name`, `sample_name` and `group_size`
parent
0559c556
Changes
3
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/__init__.py
View file @
1fe384e4
...
...
@@ -28,3 +28,6 @@ __license__ = "MIT"
__date__
=
"09/08/2018"
TYPES
=
[
"EDF"
,
"HDF5"
]
from
.hdf5scan
import
HDF5TomoScan
from
.edfscan
import
EDFTomoScan
tomoscan/esrf/hdf5scan.py
View file @
1fe384e4
...
...
@@ -89,6 +89,14 @@ class HDF5TomoScan(TomoScanBase):
_ROTATION_ANGLE_PATH
=
"sample/rotation_angle"
_SAMPLE_PATH
=
"sample"
_NAME_PATH
=
"sample/name"
_GRP_SIZE_ATTR
=
"group_size"
_SAMPLE_NAME_PATH
=
"sample/sample_name"
_X_TRANS_PATH
=
"sample/x_translation"
_Y_TRANS_PATH
=
"sample/y_translation"
...
...
@@ -160,7 +168,9 @@ class HDF5TomoScan(TomoScanBase):
"unable to find a valid entry for %s"
%
self
.
master_file
)
# for now the default entry is 1_tomo but should change with time
self
.
_name
=
None
self
.
_sample_name
=
None
self
.
_grp_size
=
None
# data caches
self
.
_projections_compacted
=
None
self
.
_flats
=
None
...
...
@@ -355,6 +365,44 @@ class HDF5TomoScan(TomoScanBase):
def
entry
(
self
)
->
str
:
return
self
.
_entry
@
property
def
sequence_name
(
self
):
"""Return the sequence name"""
if
self
.
_name
is
None
and
self
.
master_file
and
os
.
path
.
exists
:
self
.
_check_hdf5scan_validity
()
with
HDF5File
(
self
.
master_file
,
"r"
)
as
h5_file
:
if
self
.
_NAME_PATH
in
h5_file
[
self
.
_entry
]:
self
.
_name
=
h5py_read_dataset
(
h5_file
[
self
.
_entry
][
self
.
_NAME_PATH
]
)
return
self
.
_name
@
property
@
docstring
(
TomoScanBase
.
projections
)
def
sample_name
(
self
):
if
self
.
_sample_name
is
None
and
self
.
master_file
and
os
.
path
.
exists
:
self
.
_check_hdf5scan_validity
()
with
HDF5File
(
self
.
master_file
,
"r"
)
as
h5_file
:
if
self
.
_SAMPLE_NAME_PATH
in
h5_file
[
self
.
_entry
]:
self
.
_sample_name
=
h5py_read_dataset
(
h5_file
[
self
.
_entry
][
self
.
_SAMPLE_NAME_PATH
]
)
return
self
.
_sample_name
@
property
@
docstring
(
TomoScanBase
.
projections
)
def
group_size
(
self
):
if
self
.
_grp_size
is
None
and
self
.
master_file
and
os
.
path
.
exists
:
self
.
_check_hdf5scan_validity
()
with
HDF5File
(
self
.
master_file
,
"r"
)
as
h5_file
:
if
self
.
_SAMPLE_PATH
in
h5_file
[
self
.
_entry
]:
grp
=
h5_file
[
self
.
_entry
][
self
.
_SAMPLE_PATH
]
if
self
.
_GRP_SIZE_ATTR
in
grp
.
attrs
:
self
.
_grp_size
=
h5py_read_dataset
(
grp
.
attrs
[
self
.
_GRP_SIZE_ATTR
]
)
return
self
.
_grp_size
@
property
@
docstring
(
TomoScanBase
.
projections
)
def
projections
(
self
)
->
typing
.
Union
[
dict
,
None
]:
...
...
tomoscan/scanbase.py
View file @
1fe384e4
...
...
@@ -299,6 +299,22 @@ class TomoScanBase:
"""Parse the root folder and files to update informations"""
raise
NotImplementedError
(
"Base class"
)
@
property
def
sequence_name
(
self
):
"""Return the sequence name"""
raise
NotImplementedError
(
"Base class"
)
@
property
def
sample_name
(
self
):
"""Return the sample name"""
raise
NotImplementedError
(
"Base class"
)
@
property
def
group_size
(
self
):
"""Used in the case of zseries for example. Return the number of
sequence expected on the acquisition"""
raise
NotImplementedError
(
"Base class"
)
def
to_dict
(
self
)
->
dict
:
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment