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
6862d27c
Commit
6862d27c
authored
3 years ago
by
Alexis GAMELIN
Browse files
Options
Downloads
Patches
Plain Diff
Add option to Plot/Streak BunchSpectrum to normalise the spectrum data
parent
d9f2c4be
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tracking/monitors/plotting.py
+16
-2
16 additions, 2 deletions
tracking/monitors/plotting.py
with
16 additions
and
2 deletions
tracking/monitors/plotting.py
+
16
−
2
View file @
6862d27c
...
@@ -13,6 +13,7 @@ import matplotlib as mpl
...
@@ -13,6 +13,7 @@ import matplotlib as mpl
import
seaborn
as
sns
import
seaborn
as
sns
import
h5py
as
hp
import
h5py
as
hp
import
random
import
random
from
scipy.stats
import
gmean
def
plot_beamdata
(
filenames
,
dataset
=
"
mean
"
,
dimension
=
"
tau
"
,
stat_var
=
"
mean
"
,
def
plot_beamdata
(
filenames
,
dataset
=
"
mean
"
,
dimension
=
"
tau
"
,
stat_var
=
"
mean
"
,
x_var
=
"
time
"
,
turn
=
None
,
legend
=
None
):
x_var
=
"
time
"
,
turn
=
None
,
legend
=
None
):
...
@@ -629,7 +630,8 @@ def plot_wakedata(filename, bunch_number, wake_type="Wlong", start=0,
...
@@ -629,7 +630,8 @@ def plot_wakedata(filename, bunch_number, wake_type="Wlong", start=0,
return
fig2
return
fig2
def
plot_bunchspectrum
(
filenames
,
bunch_number
,
dataset
=
"
incoherent
"
,
dim
=
"
tau
"
,
def
plot_bunchspectrum
(
filenames
,
bunch_number
,
dataset
=
"
incoherent
"
,
dim
=
"
tau
"
,
turns
=
None
,
fs
=
None
,
log_scale
=
True
,
legend
=
None
):
turns
=
None
,
fs
=
None
,
log_scale
=
True
,
legend
=
None
,
norm
=
False
):
"""
"""
Plot coherent and incoherent spectrum data.
Plot coherent and incoherent spectrum data.
...
@@ -659,6 +661,9 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
...
@@ -659,6 +661,9 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
legend : list of str, optional
legend : list of str, optional
Legend to add for each file.
Legend to add for each file.
The default is None.
The default is None.
norm : bool, optional
If True, normalise the data of each spectrum by its geometric mean.
The default is False.
Return
Return
------
------
...
@@ -711,6 +716,8 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
...
@@ -711,6 +716,8 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
for
idx
in
turn_index
:
for
idx
in
turn_index
:
y_var
=
group
[
dataset
][
dim_dict
[
dim
],:,
idx
]
y_var
=
group
[
dataset
][
dim_dict
[
dim
],:,
idx
]
if
norm
is
True
:
y_var
=
y_var
/
gmean
(
y_var
)
ax
.
plot
(
x_var
,
y_var
)
ax
.
plot
(
x_var
,
y_var
)
if
log_scale
is
True
:
if
log_scale
is
True
:
...
@@ -731,7 +738,8 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
...
@@ -731,7 +738,8 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
return
fig
return
fig
def
streak_bunchspectrum
(
filename
,
bunch_number
,
dataset
=
"
incoherent
"
,
def
streak_bunchspectrum
(
filename
,
bunch_number
,
dataset
=
"
incoherent
"
,
dim
=
"
tau
"
,
fs
=
None
,
log_scale
=
True
,
fmin
=
None
,
fmax
=
None
,
turns
=
None
):
dim
=
"
tau
"
,
fs
=
None
,
log_scale
=
True
,
fmin
=
None
,
fmax
=
None
,
turns
=
None
,
norm
=
False
):
"""
"""
Plot 3D data recorded by the BunchSpectrumMonitor.
Plot 3D data recorded by the BunchSpectrumMonitor.
...
@@ -759,6 +767,9 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -759,6 +767,9 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
If not None, the plot is limitted to values smaller than fmax.
If not None, the plot is limitted to values smaller than fmax.
turns : array, optional
turns : array, optional
If not None, only the turn numbers in the turns array are plotted.
If not None, only the turn numbers in the turns array are plotted.
norm : bool, optional
If True, normalise the data of each spectrum by its geometric mean.
The default is False.
Returns
Returns
-------
-------
...
@@ -808,6 +819,9 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -808,6 +819,9 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
ind
=
(
x_var
>
fmin
)
&
(
x_var
<
fmax
)
ind
=
(
x_var
>
fmin
)
&
(
x_var
<
fmax
)
x_var
=
x_var
[
ind
]
x_var
=
x_var
[
ind
]
data
=
data
[
ind
,:]
data
=
data
[
ind
,:]
if
norm
is
True
:
data
=
data
/
gmean
(
data
)
ylabel
=
"
Turn number
"
ylabel
=
"
Turn number
"
...
...
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