Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BEA data analysis utils
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
Philipp Niedermayer
BEA data analysis utils
Commits
71a6a3f3
Commit
71a6a3f3
authored
1 year ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Add data backup methods
parent
5e56ef0d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data/tdc.py
+12
-5
12 additions, 5 deletions
data/tdc.py
with
12 additions
and
5 deletions
data/tdc.py
+
12
−
5
View file @
71a6a3f3
...
...
@@ -199,11 +199,18 @@ class TDCSpill:
def
__repr__
(
self
):
return
f
'
TDCSpill(
{
self
.
detector
}
, length=
{
self
.
length
:
g
}
s, counts=
{
self
.
counts
}
)
'
def
to_file
(
self
,
fname
):
"""
Save the spill to a file in compressed npz format
"""
np
.
savez_compressed
(
fname
,
header
=
self
.
header
,
data
=
self
.
data
,
time_offset
=
self
.
time_offset
)
@classmethod
def
from_file
(
self
,
fname
):
"""
Load the spill from a file in compressed npz format
"""
if
not
fname
.
endswith
(
"
.npz
"
):
raise
ValueError
(
"
fname must be a *.npz file. To load *.dat files, use TDCData.from_file(...) instead.
"
)
with
np
.
load
(
fname
)
as
f
:
return
TDCSpill
(
f
[
'
header
'
],
f
[
'
data
'
],
f
[
'
time_offset
'
].
item
())
@dataclass
...
...
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