Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
52f09cb1
Commit
52f09cb1
authored
Mar 09, 2020
by
Pierre Paleo
Browse files
[hdf5tomoscan] convert to static method for re-usability
parent
6054c45f
Pipeline
#22679
passed with stages
in 2 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/hdf5scan.py
View file @
52f09cb1
...
...
@@ -615,13 +615,19 @@ class HDF5TomoScan(TomoScanBase):
else
:
return
None
def
_get_compacted_projections
(
self
):
@
staticmethod
def
_get_compacted_projections
(
projections
):
"""
Regroup urls to get the data more efficiently.
Build a structure mapping projections indices to information on
how to load the data: `{indices_set: data_location}`
where `data_location` contains contiguous indices.
Parameters
-----------
projections: dict
Dictionary where the key is an integer and the value is a silx `DataUrl`.
Returns
--------
merged_projections: dict
...
...
@@ -645,9 +651,9 @@ class HDF5TomoScan(TomoScanBase):
def
merge_slices
(
slice1
,
slice2
):
return
slice
(
slice1
.
start
,
slice2
.
stop
)
sorted_files_indices
=
sorted
(
self
.
projections
.
keys
())
sorted_files_indices
=
sorted
(
projections
.
keys
())
idx0
=
sorted_files_indices
[
0
]
first_url
=
self
.
projections
[
idx0
]
first_url
=
projections
[
idx0
]
merged_indices
=
[
[
idx0
]
...
...
@@ -662,7 +668,7 @@ class HDF5TomoScan(TomoScanBase):
pos
=
0
curr_fp
,
curr_dp
,
curr_slice
=
data_location
[
pos
]
for
idx
in
sorted_files_indices
[
1
:]:
url
=
self
.
projections
[
idx
]
url
=
projections
[
idx
]
next_slice
=
_convert_to_slice
(
url
.
data_slice
())
if
(
url
.
file_path
()
==
curr_fp
)
and
(
url
.
data_path
()
==
curr_dp
)
and
is_contiguous_slice
(
curr_slice
,
next_slice
):
merged_indices
[
pos
].
append
(
idx
)
...
...
@@ -695,7 +701,7 @@ class HDF5TomoScan(TomoScanBase):
is the corresponding `silx.io.url.DataUrl` with merged data_slice
"""
if
self
.
_projections_compacted
is
None
:
self
.
_projections_compacted
=
self
.
_get_compacted_projections
()
self
.
_projections_compacted
=
self
.
_get_compacted_projections
(
self
.
projections
)
return
self
.
_projections_compacted
def
__str__
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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