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
684d60bd
Commit
684d60bd
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Standarized dataclass for topos data
parent
7d3c0365
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
data/__init__.py
+1
-0
1 addition, 0 deletions
data/__init__.py
data/topos.py
+88
-0
88 additions, 0 deletions
data/topos.py
with
89 additions
and
0 deletions
data/__init__.py
+
1
−
0
View file @
684d60bd
...
...
@@ -14,6 +14,7 @@ from .common import *
from
.ipm
import
IPMData
from
.lassie
import
LassieSpillData
from
.libera
import
LiberaData
,
LiberaBBBData
,
LiberaTBTData
from
.topos
import
ToposData
,
ToposBBBData
,
ToposTBTData
from
.nwa
import
NWAData
,
NWADataAverage
from
.tdc
import
TDCSpill
,
TDCData
from
.hitspill
import
HITSpill
,
HITSpillData
...
...
This diff is collapsed.
Click to expand it.
data/topos.py
+
88
−
0
View file @
684d60bd
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dataclasses for Libera BPM data
Classes to work with data from libera hadron beam position monitor system
"""
__author__
=
"
Philipp Niedermayer
"
__contact__
=
"
p.niedermayer@gsi.de
"
__date__
=
"
2022-08-29
"
import
numpy
as
np
from
dataclasses
import
dataclass
from
.common
import
Trace
@dataclass
class
ToposData
(
Trace
):
"""
Container for data from topos
t - time array in seconds
"""
t
:
np
.
ndarray
x
:
np
.
ndarray
y
:
np
.
ndarray
x_unit
:
str
=
'
mm
'
y_unit
:
str
=
'
mm
'
@dataclass
class
ToposBBBData
(
ToposData
):
"""
Container for bunch-by-bunch data from topos
"""
@classmethod
def
from_file
(
cls
,
fname
,
time_offset
=
0
,
verbose
=
0
):
"""
Read in bunch-by-bunch data from a *.bin file saved with topos
:param fname: path to filename
:param time_offset: adds a given time offset (in s) to the timestamps
"""
reader
=
BpmBinaryExportReader
()
t
,
x
,
y
=
reader
.
read
(
fname
)
return
ToposBBBData
(
t
/
1e3
+
time_offset
,
x
,
y
)
def
to_tbt_data
(
self
,
h
,
b
=
None
):
"""
Returns the turn-by-turn data
:param h: the harmonic number of the RF system (number of bunches per turn)
:param b: the bunch index or None for an average
"""
wrap
=
lambda
a
:
a
[:(
len
(
a
)
//
h
)
*
h
].
reshape
(
-
1
,
h
).
mean
(
axis
=
1
)
if
b
is
None
else
a
[
b
::
h
]
return
ToposTBTData
(
t
=
wrap
(
self
.
t
),
x
=
wrap
(
self
.
x
),
y
=
wrap
(
self
.
y
),
x_unit
=
self
.
x_unit
,
y_unit
=
self
.
y_unit
)
def
__repr__
(
self
):
return
f
'
ToposBBBData(n_bunch=
{
len
(
self
.
t
)
}
, t=
{
self
.
t
[
0
]
:
.
3
f
}
..
{
self
.
t
[
-
1
]
:
.
3
f
}
s)
'
@dataclass
class
ToposTBTData
(
ToposData
):
"""
Container for turn-by-turn data from topos
"""
def
__repr__
(
self
):
return
f
'
ToposBBBData(n_turn=
{
len
(
self
.
t
)
}
, t=
{
self
.
t
[
0
]
:
.
3
f
}
..
{
self
.
t
[
-
1
]
:
.
3
f
}
s)
'
#######################################################
#
# Code below thankfully provided by d.vilsmeier@gsi.de
#
import
numpy
as
np
from
io
import
BufferedReader
...
...
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