Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nxtomomill
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tomotools
nxtomomill
Commits
cb9efb9c
Commit
cb9efb9c
authored
4 years ago
by
payno
Browse files
Options
Downloads
Patches
Plain Diff
[patch-nx] add an option embed to include dataset not in the file
parent
8b795fab
No related branches found
No related tags found
1 merge request
!40
[patch-nx] add an option embed to include dataset not in the file
Pipeline
#37558
passed
4 years ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nxtomomill/app/patch_nx.py
+7
-0
7 additions, 0 deletions
nxtomomill/app/patch_nx.py
nxtomomill/utils.py
+26
-0
26 additions, 0 deletions
nxtomomill/utils.py
with
33 additions
and
0 deletions
nxtomomill/app/patch_nx.py
+
7
−
0
View file @
cb9efb9c
...
...
@@ -191,6 +191,12 @@ def main(argv):
help
=
"
Define the set of frames to be mark as alignment.
"
""
+
_INFO_FRAME_INPUT
,
)
parser
.
add_argument
(
"
--embed-data
"
,
default
=
False
,
action
=
"
store_true
"
,
help
=
"
Embed data from url in the file if not already inside
"
,
)
options
=
parser
.
parse_args
(
argv
[
1
:])
...
...
@@ -271,6 +277,7 @@ def main(argv):
flats_start
=
flat_start_url
,
darks_end
=
darks_end_url
,
flats_end
=
flat_end_url
,
embed_data
=
options
.
embed_data
,
logger
=
_logger
,
)
...
...
This diff is collapsed.
Click to expand it.
nxtomomill/utils.py
+
26
−
0
View file @
cb9efb9c
...
...
@@ -45,6 +45,7 @@ import logging
import
h5py
from
collections.abc
import
Iterable
from
silx.utils.enum
import
Enum
as
_Enum
import
uuid
class
ImageKey
(
_Enum
):
...
...
@@ -221,6 +222,7 @@ def add_dark_flat_nx_file(
flats_end
:
typing
.
Union
[
None
,
numpy
.
ndarray
,
DataUrl
]
=
None
,
extras
:
typing
.
Union
[
None
,
dict
]
=
None
,
logger
:
typing
.
Union
[
None
,
logging
.
Logger
]
=
None
,
embed_data
:
bool
=
True
,
):
"""
This will get all data from entry@input_file and patch them with provided
...
...
@@ -269,6 +271,8 @@ def add_dark_flat_nx_file(
* `rotation_angle`
:type extras: Union[None, dict]
:param Union[None, logging.Logger] logger: object for logs
:param bool embed_data: if True then each external data will be copy
under a
'
duplicate_data
'
folder
"""
from
nxtomomill.converter
import
ImageKey
# avoid cyclic import
...
...
@@ -283,6 +287,28 @@ def add_dark_flat_nx_file(
"
{keys}
"
.
format
(
key
=
key
,
keys
=
valid_extra_keys
)
)
if
embed_data
is
True
:
def
embed_url
(
url
):
if
not
isinstance
(
url
,
DataUrl
):
return
url
elif
url
.
file_path
()
==
file_path
:
return
url
else
:
embed_data_path
=
"
/
"
.
join
((
"
/duplicate_data
"
,
str
(
uuid
.
uuid1
())))
with
cwd_context
():
os
.
chdir
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
file_path
)))
with
HDF5File
(
file_path
,
"
a
"
)
as
h5s
:
h5s
[
embed_data_path
]
=
get_data
(
url
)
return
DataUrl
(
file_path
=
file_path
,
data_path
=
embed_data_path
,
scheme
=
"
silx
"
)
darks_start
=
embed_url
(
darks_start
)
darks_end
=
embed_url
(
darks_end
)
flats_start
=
embed_url
(
flats_start
)
flats_end
=
embed_url
(
flats_end
)
# !!! warning: order of dark / flat treatments import
data_names
=
"
flats_start
"
,
"
darks_end
"
,
"
flats_end
"
,
"
darks_start
"
datas
=
flats_start
,
darks_end
,
flats_end
,
darks_start
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment