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
850f73a0
Commit
850f73a0
authored
3 years ago
by
Alexis GAMELIN
Browse files
Options
Downloads
Patches
Plain Diff
Fix plotting imports and add options to streak_bunchspectrum
parent
85198411
Branches
ISEI_3_5_1
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tracking/monitors/__init__.py
+3
-2
3 additions, 2 deletions
tracking/monitors/__init__.py
tracking/monitors/plotting.py
+31
-4
31 additions, 4 deletions
tracking/monitors/plotting.py
with
34 additions
and
6 deletions
tracking/monitors/__init__.py
+
3
−
2
View file @
850f73a0
...
@@ -18,8 +18,9 @@ from mbtrack2.tracking.monitors.plotting import (plot_bunchdata,
...
@@ -18,8 +18,9 @@ from mbtrack2.tracking.monitors.plotting import (plot_bunchdata,
plot_profiledata
,
plot_profiledata
,
plot_beamdata
,
plot_beamdata
,
plot_wakedata
,
plot_wakedata
,
plot_tunedata
,
plot_cavitydata
,
plot_cavitydata
,
streak_beamdata
)
streak_beamdata
,
plot_bunchspectrum
,
streak_bunchspectrum
)
from
mbtrack2.tracking.monitors.tools
import
merge_files
from
mbtrack2.tracking.monitors.tools
import
merge_files
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tracking/monitors/plotting.py
+
31
−
4
View file @
850f73a0
...
@@ -13,7 +13,6 @@ import matplotlib as mpl
...
@@ -13,7 +13,6 @@ 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.fft
import
rfftfreq
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
):
...
@@ -732,7 +731,7 @@ def plot_bunchspectrum(filenames, bunch_number, dataset="incoherent", dim="tau",
...
@@ -732,7 +731,7 @@ 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
):
dim
=
"
tau
"
,
fs
=
None
,
log_scale
=
True
,
fmin
=
None
,
fmax
=
None
,
turns
=
None
):
"""
"""
Plot 3D data recorded by the BunchSpectrumMonitor.
Plot 3D data recorded by the BunchSpectrumMonitor.
...
@@ -754,6 +753,12 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -754,6 +753,12 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
log_scale : bool, optional
log_scale : bool, optional
If True, the spectrum plots are shown in y-log scale.
If True, the spectrum plots are shown in y-log scale.
The default is True.
The default is True.
fmin : float, optional
If not None, the plot is limitted to values bigger than fmin.
fmax : float, optional
If not None, the plot is limitted to values smaller than fmax.
turns : array, optional
If not None, only the turn numbers in the turns array are plotted.
Returns
Returns
-------
-------
...
@@ -768,7 +773,20 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -768,7 +773,20 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
freq
=
np
.
array
(
group
[
"
freq
"
])
freq
=
np
.
array
(
group
[
"
freq
"
])
dim_dict
=
{
"
x
"
:
0
,
"
y
"
:
1
,
"
tau
"
:
2
}
dim_dict
=
{
"
x
"
:
0
,
"
y
"
:
1
,
"
tau
"
:
2
}
data
=
group
[
dataset
][
dim_dict
[
dim
],
:,
:]
if
turns
is
None
:
turn_index
=
np
.
where
(
time
==
time
)[
0
]
tmin
=
time
.
min
()
tmax
=
time
.
max
()
else
:
tmin
=
turns
.
min
()
tmax
=
turns
.
max
()
turn_index
=
[]
for
turn
in
turns
:
idx
=
np
.
where
(
time
==
turn
)[
0
][
0
]
turn_index
.
append
(
idx
)
turn_index
=
np
.
array
(
turn_index
)
data
=
group
[
dataset
][
dim_dict
[
dim
],
:,
turn_index
]
if
log_scale
is
True
:
if
log_scale
is
True
:
option
=
mpl
.
colors
.
LogNorm
()
option
=
mpl
.
colors
.
LogNorm
()
...
@@ -782,6 +800,15 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -782,6 +800,15 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
x_var
=
freq
/
fs
x_var
=
freq
/
fs
xlabel
=
r
"
$f/f_{s}$
"
xlabel
=
r
"
$f/f_{s}$
"
if
fmin
is
None
:
fmin
=
x_var
.
min
()
if
fmax
is
None
:
fmax
=
x_var
.
max
()
ind
=
(
x_var
>
fmin
)
&
(
x_var
<
fmax
)
x_var
=
x_var
[
ind
]
data
=
data
[
ind
,:]
ylabel
=
"
Turn number
"
ylabel
=
"
Turn number
"
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
...
@@ -792,7 +819,7 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
...
@@ -792,7 +819,7 @@ def streak_bunchspectrum(filename, bunch_number, dataset="incoherent",
cmap
=
mpl
.
cm
.
inferno
# sequential
cmap
=
mpl
.
cm
.
inferno
# sequential
c
=
ax
.
imshow
(
data
.
T
,
cmap
=
cmap
,
origin
=
'
lower
'
,
aspect
=
'
auto
'
,
c
=
ax
.
imshow
(
data
.
T
,
cmap
=
cmap
,
origin
=
'
lower
'
,
aspect
=
'
auto
'
,
extent
=
[
x_var
.
min
(),
x_var
.
max
(),
t
ime
.
min
()
,
t
ime
.
max
()
],
extent
=
[
x_var
.
min
(),
x_var
.
max
(),
tmin
,
tmax
],
norm
=
option
)
norm
=
option
)
cbar
=
fig
.
colorbar
(
c
,
ax
=
ax
)
cbar
=
fig
.
colorbar
(
c
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
"
FFT amplitude [a.u.]
"
,
rotation
=
270
)
cbar
.
ax
.
set_ylabel
(
"
FFT amplitude [a.u.]
"
,
rotation
=
270
)
...
...
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