Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
04055bba
Commit
04055bba
authored
Aug 31, 2020
by
Pierre Paleo
Browse files
Use DataUrl for first argument
parent
c38ea44a
Changes
1
Hide whitespace changes
Inline
Side-by-side
nabu/resources/dataset_analyzer.py
View file @
04055bba
...
...
@@ -213,7 +213,7 @@ class FlatFieldLoader:
"""
def
__init__
(
self
,
h5_file
,
h5_path
,
image_keys
,
image_type
,
self
,
data_url
,
image_keys
,
image_type
,
reduction_method
=
"mean"
,
lookup_files
=
None
,
logger
=
None
):
"""
...
...
@@ -221,10 +221,8 @@ class FlatFieldLoader:
Parameters
-----------
h5_file: str
File name of the HDF5 file.
h5_path: str
HDF5 path to the data volume.
data_url: silx.io.url.DataUrl
A DataUrl object containing the URL to the volume data.
image_keys: list of int
List of keys corresponding to each image of the data volume.
See Nexus Format specification, NXtomo, "image_key".
...
...
@@ -238,8 +236,7 @@ class FlatFieldLoader:
logger: Logger object, optional
Logging object
"""
self
.
h5_file
=
h5_file
self
.
h5_path
=
h5_path
self
.
data_url
=
data_url
self
.
image_keys
=
image_keys
self
.
_set_image_type
(
image_type
)
self
.
_set_reduction_method
(
reduction_method
)
...
...
@@ -275,7 +272,7 @@ class FlatFieldLoader:
"""
Attempt at loading already computed "final" darks and flats from existing files.
"""
basedir
=
os
.
path
.
dirname
(
self
.
h5_file
)
basedir
=
os
.
path
.
dirname
(
self
.
data_url
.
file_path
()
)
existing_data
=
None
for
fpath
in
self
.
lookup_files
:
existing_data
=
self
.
load_existing_flatfield
(
fpath
)
...
...
@@ -348,8 +345,8 @@ class FlatFieldLoader:
"""
Get a data chunk from the data volume whose path was specified at class instantiation.
"""
with
HDF5File
(
self
.
h5_file
,
"r"
,
swmr
=
True
)
as
f
:
data_raw
=
f
[
self
.
h5
_path
][
data_slice
]
with
HDF5File
(
self
.
data_url
.
file_path
()
,
"r"
,
swmr
=
True
)
as
f
:
data_raw
=
f
[
self
.
data_url
.
data
_path
()
][
data_slice
]
return
data_raw
...
...
@@ -384,7 +381,7 @@ class FlatFieldLoader:
return
existing_imgs
img_slices
=
self
.
get_data_slices
(
self
.
image_keys
,
val_to_nxkey
[
self
.
image_type
])
if
img_slices
==
[]:
self
.
logger
.
error
(
"No %s found in %s"
%
(
self
.
image_type
,
self
.
h5_file
))
self
.
logger
.
error
(
"No %s found in %s"
%
(
self
.
image_type
,
self
.
data_url
.
file_path
()
))
return
None
res
=
{}
for
data_slice
in
img_slices
:
...
...
Write
Preview
Supports
Markdown
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