Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
pyBOAT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gregor Moenke
pyBOAT
Commits
57eb8afa
Commit
57eb8afa
authored
Jun 09, 2020
by
Gregor Moenke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed Fourier, plotting styles
parent
d88b7099
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
31 deletions
+65
-31
doc/logo_circ64x64.png
doc/logo_circ64x64.png
+0
-0
pyboat/__init__.py
pyboat/__init__.py
+1
-1
pyboat/core.py
pyboat/core.py
+2
-2
pyboat/plotting.py
pyboat/plotting.py
+43
-17
pyboat/ui/analysis.py
pyboat/ui/analysis.py
+2
-1
pyboat/ui/data_viewer.py
pyboat/ui/data_viewer.py
+1
-1
pyboat/ui/synth_gen.py
pyboat/ui/synth_gen.py
+2
-2
scripting_template.py
scripting_template.py
+8
-5
scripting_templateOOP.py
scripting_templateOOP.py
+6
-2
No files found.
doc/logo_circ64x64.png
0 → 100644
View file @
57eb8afa
13.8 KB
pyboat/__init__.py
View file @
57eb8afa
...
...
@@ -3,7 +3,7 @@
import
sys
,
os
import
argparse
__version__
=
'0.8.1.
3
'
__version__
=
'0.8.1.
5
'
# the object oriented API
from
.api
import
WAnalyzer
...
...
pyboat/core.py
View file @
57eb8afa
...
...
@@ -440,7 +440,7 @@ def smooth(x, window_len=11, window="flat", data=None):
if
window_len
<
3
:
raise
ValueError
(
"window must not be shorter than 3"
)
if
window_len
%
2
is
0
:
if
window_len
%
2
==
0
:
raise
ValueError
(
"window_len should be odd"
)
if
not
window
in
[
"flat"
,
"extern"
]:
...
...
@@ -596,7 +596,7 @@ def normalize_with_envelope(dsignal, window_size, dt):
----------
dsignal : ndarray, the (detrended) signal
window_size : int, the window size in time units
window_size : int, the window size in
sampling
time units
dt : float, the sampling interval
"""
...
...
pyboat/plotting.py
View file @
57eb8afa
...
...
@@ -14,29 +14,33 @@ TREND_COLOR = rgb_2mpl(165, 105, 189) # orchidy
ENVELOPE_COLOR
=
'orange'
DETREND_COLOR
=
'black'
FOURIER_COLOR
=
'
slategray
'
FOURIER_COLOR
=
'
cadetblue
'
RIDGE_COLOR
=
"crimson"
COI_COLOR
=
'0.6'
# light gray
# average power histogram
HIST_COLOR
=
'
lightslategray
'
HIST_COLOR
=
'
cadetblue
'
# the readouts
PERIOD_COLOR
=
'cornflowerblue'
PHASE_COLOR
=
'crimson'
AMPLITUDE_COLOR
=
'k'
POWER_COLOR
=
'
gray
'
POWERKDE_COLOR
=
rgba_2mpl
(
10
,
10
,
10
,
1
8
0
)
POWER_COLOR
=
'
cadetblue
'
POWERKDE_COLOR
=
rgba_2mpl
(
10
,
10
,
10
,
1
6
0
)
# the colormap for the wavelet spectra
CMAP
=
"YlGnBu_r"
# CMAP = 'cividis'
# CMAP = 'magma'
# --- max size of signal to plot also the sample points
Nmax
=
250
# --- define line widths ---
TREND_LW
=
1.5
SIGNAL_LW
=
1.5
MARKER_SIZE
=
4
# --- standard sizes ---
label_size
=
18
...
...
@@ -47,6 +51,19 @@ tick_label_size = 16
# match dimensions of spectrum and signal plots
x_size
=
6.5
# signal plot style, markers only for short signals
def
get_marker_lw
(
signal
):
if
len
(
signal
)
<=
Nmax
:
m
=
'o'
lw
=
1.2
else
:
m
=
''
lw
=
SIGNAL_LW
return
m
,
lw
# --- Signal and Trend -----------------------------------------------
...
...
@@ -69,14 +86,17 @@ def mk_signal_ax(time_unit="a.u.", fig=None):
return
ax
def
draw_signal
(
ax
,
time_vector
,
signal
):
ax
.
plot
(
time_vector
,
signal
,
lw
=
SIGNAL_LW
,
color
=
SIG_COLOR
,
alpha
=
0.8
,
label
=
"signal"
)
def
draw_signal
(
ax
,
time_vector
,
signal
,
label
=
"signal"
):
m
,
lw
=
get_marker_lw
(
signal
)
ax
.
plot
(
time_vector
,
signal
,
lw
=
lw
,
marker
=
m
,
ms
=
MARKER_SIZE
,
color
=
SIG_COLOR
,
alpha
=
0.8
,
label
=
label
)
def
draw_trend
(
ax
,
time_vector
,
trend
):
ax
.
plot
(
time_vector
,
trend
,
color
=
TREND_COLOR
,
alpha
=
0.8
,
lw
=
TREND_LW
,
label
=
"trend"
)
def
draw_trend
(
ax
,
time_vector
,
trend
,
label
=
'trend'
):
ax
.
plot
(
time_vector
,
trend
,
color
=
TREND_COLOR
,
alpha
=
0.8
,
lw
=
TREND_LW
,
label
=
label
)
def
draw_envelope
(
ax
,
time_vector
,
envelope
):
ax
.
plot
(
time_vector
,
envelope
,
color
=
ENVELOPE_COLOR
,
...
...
@@ -85,9 +105,11 @@ def draw_envelope(ax, time_vector, envelope):
def
draw_detrended
(
ax
,
time_vector
,
detrended
):
m
,
lw
=
get_marker_lw
(
detrended
)
ax2
=
ax
.
twinx
()
ax2
.
plot
(
time_vector
,
detrended
,
"-"
,
color
=
DETREND_COLOR
,
lw
=
1.5
,
alpha
=
0.6
,
label
=
'detrended'
)
ax2
.
plot
(
time_vector
,
detrended
,
"-"
,
marker
=
m
,
ms
=
MARKER_SIZE
,
color
=
DETREND_COLOR
,
lw
=
lw
,
alpha
=
0.6
,
label
=
'detrended'
)
ax2
.
set_ylabel
(
"detrended"
,
fontsize
=
label_size
)
ax2
.
ticklabel_format
(
style
=
"sci"
,
axis
=
"y"
,
scilimits
=
(
0
,
0
))
...
...
@@ -223,7 +245,11 @@ def plot_signal_modulus(axs, time_vector, signal, modulus, periods, p_max=None):
# Plot Signal above spectrum
sig_ax
.
plot
(
time_vector
,
signal
,
color
=
"black"
,
lw
=
1.5
,
alpha
=
0.7
)
m
,
lw
=
get_marker_lw
(
signal
)
sig_ax
.
plot
(
time_vector
,
signal
,
color
=
"black"
,
lw
=
lw
,
alpha
=
0.65
,
marker
=
m
,
ms
=
MARKER_SIZE
)
# sig_ax.plot(time_vector, signal, ".", color="black", ms=2.0, alpha=0.5)
sig_ax
.
ticklabel_format
(
style
=
"sci"
,
axis
=
"y"
,
scilimits
=
(
0
,
0
))
sig_ax
.
tick_params
(
axis
=
"both"
,
labelsize
=
tick_label_size
)
...
...
@@ -380,12 +406,13 @@ def plot_readout(ridge_data, time_unit="a.u.", draw_coi = False, fig=None):
ax3
.
tick_params
(
axis
=
"both"
,
labelsize
=
tick_label_size
)
# powers
ax4
.
plot
(
ridge_t
.
loc
[
i_left
:
i_right
],
powers
.
loc
[
i_left
:
i_right
],
"k-"
,
lw
=
2.5
,
alpha
=
0.5
,
ax4
.
plot
(
ridge_t
.
loc
[
i_left
:
i_right
],
powers
.
loc
[
i_left
:
i_right
],
lw
=
2.5
,
alpha
=
0.8
,
color
=
POWER_COLOR
,
ls
=
lstyle
,
marker
=
mstyle
,
ms
=
1.5
)
# inside COI
ax4
.
plot
(
ridge_t
.
loc
[:
i_left
],
powers
.
loc
[:
i_left
],
'--'
,
color
=
'gray'
,
alpha
=
0.6
,
ms
=
2.5
)
ax4
.
plot
(
ridge_t
.
loc
[
i_right
:],
powers
.
loc
[
i_right
:],
'--'
,
color
=
'gray'
,
alpha
=
0.6
,
ms
=
2.5
)
ax4
.
plot
(
ridge_t
.
loc
[:
i_left
],
powers
.
loc
[:
i_left
],
'--'
,
color
=
POWER_COLOR
,
alpha
=
0.6
,
ms
=
2.5
)
ax4
.
plot
(
ridge_t
.
loc
[
i_right
:],
powers
.
loc
[
i_right
:],
'--'
,
color
=
POWER_COLOR
,
alpha
=
0.6
,
ms
=
2.5
)
ax4
.
set_ylim
((
0
,
1.1
*
powers
.
max
()))
ax4
.
set_ylabel
(
"Power (wnp)"
,
fontsize
=
label_size
)
...
...
@@ -478,7 +505,6 @@ def plot_power_distribution(powers, kde = True, fig = None):
dens
(
support
),
color
=
POWERKDE_COLOR
,
lw
=
2.
,
alpha
=
0.8
,
label
=
'KDE'
)
...
...
pyboat/ui/analysis.py
View file @
57eb8afa
...
...
@@ -64,7 +64,8 @@ class FourierAnalyzer(QWidget):
# plot it
ax
=
pl
.
mk_Fourier_ax
(
self
.
fCanvas
.
fig
,
self
.
time_unit
,
self
.
show_T
)
pl
.
Fourier_spec
(
ax
,
self
.
fft_freqs
,
self
.
fpower
,
self
.
show_T
)
self
.
fCanvas
.
fig
.
subplots_adjust
(
left
=
0.15
)
# self.fCanvas.fig.tight_layout()
main_layout
=
QGridLayout
()
main_layout
.
addWidget
(
self
.
fCanvas
,
0
,
0
,
9
,
1
)
...
...
pyboat/ui/data_viewer.py
View file @
57eb8afa
...
...
@@ -960,7 +960,7 @@ class DataViewer(QWidget):
if
self
.
cb_use_envelope2
.
isChecked
():
L
=
self
.
get_L
(
self
.
L_edit
)
signal
=
pyboat
.
normalize_with_envelope
(
signal
,
self
.
L
,
self
.
dt
)
signal
=
pyboat
.
normalize_with_envelope
(
signal
,
L
,
self
.
dt
)
# periods or frequencies?
if
self
.
cb_FourierT
.
isChecked
():
...
...
pyboat/ui/synth_gen.py
View file @
57eb8afa
...
...
@@ -608,7 +608,7 @@ class SynthSignalGen(QWidget):
print
(
"L ValueError"
,
text
)
pass
#
transform to sampling interval
s
#
still in sampling interval unit
s
self
.
L
=
int
(
L
)
if
self
.
debug
:
...
...
@@ -1076,7 +1076,7 @@ class SynthSignalGen(QWidget):
return
elif
self
.
cb_use_envelope2
.
isChecked
():
signal
=
pyboat
.
normalize_with_envelope
(
signal
,
self
.
L
)
signal
=
pyboat
.
normalize_with_envelope
(
signal
,
self
.
L
,
self
.
dt
)
# periods or frequencies?
if
self
.
cb_FourierT
.
isChecked
():
...
...
scripting_template.py
View file @
57eb8afa
...
...
@@ -19,7 +19,7 @@ time_unit = 's'
eps
=
0.5
# noise intensity
alpha
=
0.4
# AR1 parameter
Nt
=
5
00
# number of samples
Nt
=
4
00
# number of samples
signal1
=
ssg
.
create_noisy_chirp
(
T1
=
30
/
dt
,
T2
=
50
/
dt
,
Nt
=
Nt
,
eps
=
eps
,
alpha
=
alpha
)
...
...
@@ -37,7 +37,7 @@ detr_signal = signal - trend
# plot the signal/trend
tvec
=
np
.
arange
(
len
(
signal
))
*
dt
ax
=
pl
.
mk_signal_ax
(
time_unit
=
's'
)
pl
.
draw_signal
(
ax
,
tvec
,
signal
)
pl
.
draw_signal
(
ax
,
tvec
,
signal
,
label
=
'2 chirps'
)
# pl.draw_detrended(ax, tvec, signal)
pl
.
draw_trend
(
ax
,
tvec
,
trend
)
ppl
.
legend
(
ncol
=
2
)
...
...
@@ -49,7 +49,7 @@ modulus, wlet = pyboat.compute_spectrum(signal, dt, periods)
# plot spectrum and ridge
ax_sig
,
ax_spec
=
pl
.
mk_signal_modulus_ax
(
time_unit
)
pl
.
plot_signal_modulus
((
ax_sig
,
ax_spec
),
tvec
,
signal
,
modulus
,
periods
)
ppl
.
tight_layout
()
# --- compute spectrum on the detrended signal ---
modulus
,
wlet
=
pyboat
.
compute_spectrum
(
detr_signal
,
dt
,
periods
)
...
...
@@ -57,16 +57,19 @@ modulus, wlet = pyboat.compute_spectrum(detr_signal, dt, periods)
# get maximum ridge
ridge_ys
=
pyboat
.
get_maxRidge_ys
(
modulus
)
# evaluate along the ridge
# evaluate along the ridge
, ridge_results is a pandas DataFrame
ridge_results
=
pyboat
.
eval_ridge
(
ridge_ys
,
wlet
,
signal
,
periods
,
tvec
)
# plot spectrum and ridge
ax_sig2
,
ax_spec2
=
pl
.
mk_signal_modulus_ax
(
time_unit
)
pl
.
plot_signal_modulus
((
ax_sig2
,
ax_spec2
),
tvec
,
signal
,
modulus
,
periods
)
pl
.
plot_signal_modulus
((
ax_sig2
,
ax_spec2
),
tvec
,
detr_
signal
,
modulus
,
periods
)
pl
.
draw_Wavelet_ridge
(
ax_spec2
,
ridge_results
)
ppl
.
tight_layout
()
ppl
.
savefig
(
'detr_signal_spec.png'
)
# plot readout
pl
.
plot_readout
(
ridge_results
)
ppl
.
savefig
(
'detr_signal_readout.png'
)
scripting_templateOOP.py
View file @
57eb8afa
...
...
@@ -16,7 +16,7 @@ time_unit = 's'
eps
=
0.5
# noise intensity
alpha
=
0.4
# AR1 parameter
Nt
=
5
00
# number of samples
Nt
=
4
00
# number of samples
signal1
=
ssg
.
create_noisy_chirp
(
T1
=
30
/
dt
,
T2
=
50
/
dt
,
Nt
=
Nt
,
eps
=
eps
,
alpha
=
alpha
)
...
...
@@ -43,6 +43,10 @@ wAn.compute_spectrum(signal)
wAn
.
get_maxRidge
(
power_thresh
=
5
)
wAn
.
draw_Ridge
()
ppl
.
savefig
(
'detr_signal_spec.png'
)
wAn
.
plot_readout
(
draw_coi
=
True
)
rd
=
wAn
.
ridge_data
ppl
.
savefig
(
'detr_signal_readout.png'
)
rd
=
wAn
.
ridge_data
# this is a pandas DataFrame holding the ridge results
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment