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
c0c79518
Commit
c0c79518
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Plot harmonics
parent
83bfa9c0
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plotting/common.py
+61
-0
61 additions, 0 deletions
plotting/common.py
plotting/spill.py
+0
-57
0 additions, 57 deletions
plotting/spill.py
with
61 additions
and
57 deletions
plotting/common.py
+
61
−
0
View file @
c0c79518
...
...
@@ -58,3 +58,64 @@ def ax_set(ax, swap_xy=False, **kwargs):
else
:
ax
.
set
(
**
kwargs
)
def
plot_harmonics
(
ax
,
f
,
df
=
0
,
*
,
n
=
20
,
time
=
False
,
swap_axis
=
False
,
**
plot_kwargs
):
"""
Add vertical lines or spans indicating the location of the frequencies / frequency bands and their harmonics
:param ax: Axis to plot onto
:param f: Frequency or list of frequencies
:param df: Bandwidth or list of bandwidths
:param n: Number of harmonics to plot
:param time: If true, plot multiples of period T=1/f
:param swap_axis: If True, swap plot axis (i.e. plot horizontal spans)
:param plot_kwargs: Keyword arguments to be passed to plotting method
"""
if
not
hasattr
(
f
,
'
__iter__
'
):
f
=
[
f
]
if
not
hasattr
(
df
,
'
__iter__
'
):
df
=
[
df
]
*
len
(
f
)
#kwargs = dict(zorder=-1, color='gray', alpha=0.5, lw=1)
kwargs
=
dict
(
zorder
=-
1
,
color
=
'
gray
'
,
lw
=
1
)
kwargs
.
update
(
plot_kwargs
)
for
i
in
range
(
1
,
n
+
1
):
for
j
,
(
fi
,
dfi
)
in
enumerate
(
zip
(
f
,
df
)):
if
dfi
==
0
:
method
=
(
ax
.
axhline
if
swap_axis
else
ax
.
axvline
)
args
=
[
i
/
fi
]
if
time
else
[
i
*
fi
]
else
:
method
=
(
ax
.
axhspan
if
swap_axis
else
ax
.
axvspan
)
args
=
[
i
/
(
fi
+
dfi
/
2
),
i
/
(
fi
-
dfi
/
2
)]
if
time
else
[
i
*
(
fi
-
dfi
/
2
),
i
*
(
fi
+
dfi
/
2
)]
#method(*args, **kwargs)
method
(
*
args
,
**
dict
(
dict
(
alpha
=
1
-
np
.
log
(
1
+
(
np
.
e
-
1
)
*
(
i
-
1
)
/
n
)),
**
kwargs
))
kwargs
.
pop
(
'
label
'
,
None
)
def
plot_revolution_harmonics
(
ax
,
f0
,
**
kwargs
):
"""
See plot_harmonics
"""
plot_harmonics
(
ax
,
f0
,
0
,
**
dict
(
dict
(
label
=
'
Revolution harmonics
'
,
color
=
'
lightgray
'
,
alpha
=
1
,
zorder
=-
3
,
ls
=
'
:
'
),
**
kwargs
))
def
plot_tune_harmonics
(
ax
,
f0
,
q
,
dq
=
0
,
*
,
n
=
20
,
time
=
False
,
swap_axis
=
False
,
**
plot_kwargs
):
"""
Add vertical lines or spans indicating the location of the frequencies / frequency bands and their harmonics
:param ax: Axis to plot onto
:param f0: Revolution frequency to which the tune parameters refer
:param q: Tune or list of tunes
:param dq: Bandwidth or list of bandwidths in tune units
:param n: Number of harmonics to plot
:param time: If true, plot multiples of period T=1/f
:param swap_axis: If True, swap plot axis (i.e. plot horizontal spans)
:param plot_kwargs: Keyword arguments to be passed to plotting method
"""
if
not
hasattr
(
q
,
'
__iter__
'
):
q
=
[
q
]
if
not
hasattr
(
dq
,
'
__iter__
'
):
dq
=
[
dq
]
*
len
(
q
)
plot_harmonics
(
ax
,
f0
*
np
.
array
(
q
),
f0
*
np
.
array
(
dq
),
n
=
n
,
time
=
time
,
swap_axis
=
swap_axis
,
**
plot_kwargs
)
def
plot_excitation_harmonics
(
ax
,
f0
,
q
,
dq
,
**
kwargs
):
"""
See plot_tune_harmonics
"""
plot_tune_harmonics
(
ax
,
f0
,
q
,
dq
,
**
dict
(
dict
(
label
=
'
Excitation harmonics
'
,
ls
=
'
--
'
,
color
=
'
k
'
),
**
kwargs
))
def
plot_3rd_order_harmonics
(
ax
,
f0
,
**
kwargs
):
"""
See plot_tune_harmonics
"""
plot_tune_harmonics
(
ax
,
f0
,
1
/
3
,
0
,
**
dict
(
dict
(
label
=
'
1/3 resonance harmonics
'
,
color
=
'
red
'
,
zorder
=-
2
),
**
kwargs
))
This diff is collapsed.
Click to expand it.
plotting/spill.py
+
0
−
57
View file @
c0c79518
...
...
@@ -233,60 +233,3 @@ def plot_spill_frequency_spectrum_2D(ax, spill_data, nseg, fmax=100e3, log=True,
def
plot_harmonics
(
ax
,
f
,
df
=
0
,
*
,
n
=
20
,
time
=
False
,
swap_axis
=
False
,
**
plot_kwargs
):
"""
Add vertical lines or spans indicating the location of the frequencies / frequency bands and its harmonics
:param ax: Axis to plot onto
:param f: Frequency or list of frequencies
:param df: Bandwidth or list of bandwidths
:param n: Number of harmonics to plot
:param time: If true, plot multiples of period T=1/f
:param swap_axis: If True, swap plot axis (i.e. plot horizontal spans)
:param plot_kwargs: Keyword arguments to be passed to plotting method
"""
if
not
hasattr
(
f
,
'
__iter__
'
):
f
=
[
f
]
if
not
hasattr
(
df
,
'
__iter__
'
):
df
=
[
df
]
*
len
(
f
)
kwargs
=
dict
(
zorder
=-
1
,
color
=
'
gray
'
,
alpha
=
0.5
,
lw
=
1
)
kwargs
.
update
(
plot_kwargs
)
for
i
in
range
(
1
,
n
+
1
):
for
j
,
(
fi
,
dfi
)
in
enumerate
(
zip
(
f
,
df
)):
if
dfi
==
0
:
method
=
(
ax
.
axhline
if
swap_axis
else
ax
.
axvline
)
args
=
[
i
/
fi
]
if
time
else
[
i
*
fi
]
else
:
method
=
(
ax
.
axhspan
if
swap_axis
else
ax
.
axvspan
)
args
=
[
i
/
(
fi
+
dfi
/
2
),
i
/
(
fi
-
dfi
/
2
)]
if
time
else
[
i
*
(
fi
-
dfi
/
2
),
i
*
(
fi
+
dfi
/
2
)]
method
(
*
args
,
**
kwargs
)
kwargs
.
pop
(
'
label
'
,
None
)
def
plot_revolution_harmonics
(
ax
,
f0
,
**
kwargs
):
"""
See plot_harmonics
"""
plot_harmonics
(
ax
,
f0
,
0
,
**
dict
(
dict
(
label
=
'
Revolution harmonics
'
,
color
=
'
lightgray
'
,
alpha
=
1
,
zorder
=-
3
,
ls
=
'
:
'
),
**
kwargs
))
def
plot_tune_harmonics
(
ax
,
f0
,
q
,
dq
=
0
,
*
,
n
=
20
,
time
=
False
,
swap_axis
=
False
,
**
plot_kwargs
):
"""
Add vertical lines or spans indicating the location of the frequencies / frequency bands and its harmonics
:param ax: Axis to plot onto
:param f0: Revolution frequency to which the tune parameters refer
:param q: Tune or list of tunes
:param dq: Bandwidth or list of bandwidths in tune units
:param n: Number of harmonics to plot
:param time: If true, plot multiples of period T=1/f
:param swap_axis: If True, swap plot axis (i.e. plot horizontal spans)
:param plot_kwargs: Keyword arguments to be passed to plotting method
"""
if
not
hasattr
(
q
,
'
__iter__
'
):
q
=
[
q
]
if
not
hasattr
(
dq
,
'
__iter__
'
):
dq
=
[
dq
]
*
len
(
q
)
plot_harmonics
(
ax
,
f0
*
np
.
array
(
q
),
f0
*
np
.
array
(
dq
),
n
=
n
,
time
=
time
,
swap_axis
=
swap_axis
,
**
plot_kwargs
)
def
plot_excitation_harmonics
(
ax
,
f0
,
q
,
dq
,
**
kwargs
):
"""
See plot_tune_harmonics
"""
plot_tune_harmonics
(
ax
,
f0
,
q
,
dq
,
**
dict
(
dict
(
label
=
'
Excitation harmonics
'
),
**
kwargs
))
def
plot_3rd_order_harmonics
(
ax
,
f0
,
**
kwargs
):
"""
See plot_tune_harmonics
"""
plot_tune_harmonics
(
ax
,
f0
,
1
/
3
,
0
,
**
dict
(
dict
(
label
=
'
1/3 resonance harmonics
'
,
color
=
'
red
'
,
zorder
=-
2
),
**
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