Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mbtrack2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
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
PA
Collective Effects
mbtrack2
Commits
a34c5150
Commit
a34c5150
authored
3 years ago
by
Alexis GAMELIN
Browse files
Options
Downloads
Patches
Plain Diff
Add a new tool to copy a HDF5 file to a different HDF5 version
parent
20c9a759
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tracking/monitors/__init__.py
+1
-1
1 addition, 1 deletion
tracking/monitors/__init__.py
tracking/monitors/tools.py
+31
-0
31 additions, 0 deletions
tracking/monitors/tools.py
with
32 additions
and
1 deletion
tracking/monitors/__init__.py
+
1
−
1
View file @
a34c5150
...
@@ -25,4 +25,4 @@ from mbtrack2.tracking.monitors.plotting import (plot_bunchdata,
...
@@ -25,4 +25,4 @@ from mbtrack2.tracking.monitors.plotting import (plot_bunchdata,
plot_beamspectrum
,
plot_beamspectrum
,
streak_beamspectrum
)
streak_beamspectrum
)
from
mbtrack2.tracking.monitors.tools
import
merge_files
from
mbtrack2.tracking.monitors.tools
import
(
merge_files
,
copy_files
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tracking/monitors/tools.py
+
31
−
0
View file @
a34c5150
...
@@ -71,5 +71,36 @@ def merge_files(files_prefix, files_number, file_name=None):
...
@@ -71,5 +71,36 @@ def merge_files(files_prefix, files_number, file_name=None):
f
[
group
][
dataset_name
][
tuple
(
slice_list
)]
=
fi
[
group
][
dataset_name
]
f
[
group
][
dataset_name
][
tuple
(
slice_list
)]
=
fi
[
group
][
dataset_name
]
fi
.
close
()
fi
.
close
()
f
.
close
()
f
.
close
()
def
copy_files
(
source
,
copy
,
version
=
None
):
"""
Copy a source hdf5 file into another hdf5 file using a different HDF5
version.
The function assumes that the source file has only a single group layer.
Parameters
----------
source : str
Name of the source file.
copy : str
Name of the copy file.
version : str, optional
Version number of the copy file.
"""
if
version
==
None
:
version
=
'
v108
'
f
=
hp
.
File
(
source
+
"
.hdf5
"
,
"
r
"
)
h
=
hp
.
File
(
copy
+
"
.hdf5
"
,
"
a
"
,
libver
=
(
'
earliest
'
,
version
))
## Copy file
for
group
in
list
(
f
):
h
.
require_group
(
group
)
for
dataset_name
in
list
(
f
[
group
]):
h
[
group
][
dataset_name
]
=
f
[
group
][
dataset_name
][()]
f
.
close
()
h
.
close
()
\ No newline at end of file
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