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
6ba39f00
Commit
6ba39f00
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Add NWA data class and plotting
parent
d59371c3
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.py
+40
-0
40 additions, 0 deletions
data.py
plotting.py
+18
-0
18 additions, 0 deletions
plotting.py
with
58 additions
and
0 deletions
data.py
+
40
−
0
View file @
6ba39f00
...
@@ -307,3 +307,43 @@ class LiberaTBTData(LiberaData):
...
@@ -307,3 +307,43 @@ class LiberaTBTData(LiberaData):
"""
Container for turn-by-turn data from libera-ireg dump
"""
Container for turn-by-turn data from libera-ireg dump
"""
"""
pass
pass
@dataclass
class
NWAData
(
Trace
):
"""
Container for data from Network Analyser save
f - frequency in Hz
m - magnitude
p - phase
"""
f
:
np
.
ndarray
m
:
np
.
ndarray
p
:
np
.
ndarray
f_unit
:
str
=
'
Hz
'
m_unit
:
str
=
'
a.u.
'
p_unit
:
str
=
'
a.u.
'
@classmethod
def
from_file
(
cls
,
magfile
,
phasefile
=
None
,
unwrap
=
False
,
verbose
=
0
):
"""
Read in data from CSV file for magnitude and phase
:param magfile: path to filename with magnitude trace data
:param phasefile: path to filename with phase trace data. If None, phase data is assumed to be the second column in magfile.
:param unwrap: if true, relative phase is unwraped to absolute phase centered around zero
"""
f
,
m
,
*
other
=
np
.
loadtxt
(
magfile
,
skiprows
=
3
,
delimiter
=
'
,
'
).
T
if
phasefile
is
None
:
p
=
other
[
0
]
else
:
fp
,
p
,
*
_
=
np
.
loadtxt
(
phasefile
,
skiprows
=
3
,
delimiter
=
'
,
'
).
T
if
np
.
any
(
f
!=
fp
):
raise
ValueError
(
'
Files provided do not have equal frequency components.
'
)
if
unwrap
:
p
=
np
.
unwrap
(
p
)
p
-=
np
.
mean
(
p
)
return
NWAData
(
f
,
m
,
p
)
This diff is collapsed.
Click to expand it.
plotting.py
+
18
−
0
View file @
6ba39f00
...
@@ -114,6 +114,14 @@ def fiberplot(ax, datasets, *, labels=[None, None], vertical=True):
...
@@ -114,6 +114,14 @@ def fiberplot(ax, datasets, *, labels=[None, None], vertical=True):
ax
.
set
(
xticks
=
yticks
)
ax
.
set
(
xticks
=
yticks
)
else
:
else
:
ax
.
set
(
yticks
=
yticks
)
ax
.
set
(
yticks
=
yticks
)
def
format_axis_radians
(
yaxis
):
yaxis
.
set_major_locator
(
mpl
.
ticker
.
MultipleLocator
(
np
.
deg2rad
(
360
)))
yaxis
.
set_minor_locator
(
mpl
.
ticker
.
MultipleLocator
(
np
.
deg2rad
(
180
)))
yaxis
.
set_major_formatter
(
mpl
.
ticker
.
FuncFormatter
(
lambda
x
,
p
:
'
0
'
if
x
==
0
else
'
$
\\
pi$
'
if
x
==
np
.
pi
else
'
$-
\\
pi$
'
if
x
==-
np
.
pi
else
f
'
$
{
x
/
np
.
pi
:
g
}
\\
pi$
'
))
yaxis
.
set_minor_formatter
(
mpl
.
ticker
.
FuncFormatter
(
lambda
x
,
p
:
'
0
'
if
x
==
0
else
'
$
\\
pi$
'
if
x
==
np
.
pi
else
'
$-
\\
pi$
'
if
x
==-
np
.
pi
else
None
))
...
@@ -146,6 +154,16 @@ def plot_tbt(ax, libera_data, over_time=True, turn_range=None, time_range=None):
...
@@ -146,6 +154,16 @@ def plot_tbt(ax, libera_data, over_time=True, turn_range=None, time_range=None):
ax2
.
set
(
ylabel
=
'
Pickup sum / a.u.
'
,
ylim
=
(
0
,
1e8
))
ax2
.
set
(
ylabel
=
'
Pickup sum / a.u.
'
,
ylim
=
(
0
,
1e8
))
ax2
.
legend
([
lf
,
ls
],
[
'
Revolution frequency
'
,
'
Pickup sum signal
'
],
loc
=
'
center right
'
,
fontsize
=
'
small
'
)
ax2
.
legend
([
lf
,
ls
],
[
'
Revolution frequency
'
,
'
Pickup sum signal
'
],
loc
=
'
center right
'
,
fontsize
=
'
small
'
)
def
plot_btf
(
axf
,
axp
,
data
,
*
,
frev
=
None
,
**
kwargs
):
f
=
data
.
f
*
(
1
/
frev
if
frev
else
1
)
axf
.
plot
(
f
,
data
.
m
,
**
kwargs
)
axp
.
plot
(
f
,
data
.
p
,
**
kwargs
)
axf
.
set
(
ylabel
=
f
'
Magnitude /
{
data
.
m_unit
}
'
,
xlim
=
(
np
.
min
(
f
),
np
.
max
(
f
)))
axp
.
set
(
ylabel
=
f
'
Phase /
{
data
.
p_unit
}
'
,
xlabel
=
'
Stimulus tune
'
if
frev
else
f
'
Stimulus frequency /
{
data
.
f_unit
}
'
)
return
fig
,
(
af
,
ap
)
def
plot_tune_spectrum
(
ax
,
libera_data
,
xy
,
turn_range
=
None
,
time_range
=
None
,
tune_range
=
None
,
fit
=
False
,
smoothing
=
None
,
return_spectrum
=
False
,
**
kwargs
):
def
plot_tune_spectrum
(
ax
,
libera_data
,
xy
,
turn_range
=
None
,
time_range
=
None
,
tune_range
=
None
,
fit
=
False
,
smoothing
=
None
,
return_spectrum
=
False
,
**
kwargs
):
...
...
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