Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IENT
GDET3-Demos
Commits
2ef56d07
Commit
2ef56d07
authored
Apr 16, 2019
by
Hafiz Emin Kosar
Browse files
GUI improvements and bug fixes
parent
1d03f2b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
GDET3 Laplace-Transformation.ipynb
View file @
2ef56d07
...
...
@@ -69,9 +69,7 @@
"source": [
"# Achse wandert hoch - ient_axis?\n",
"# update_signal todos beachten\n",
"# dirac spitzer!\n",
"# f statt omega\n",
"# Skript S. 18 2.2 P/N-Diagramm, 2 Cells versch. KBs, pn und t plotten"
"# dirac spitzer!"
]
},
{
...
...
%% Cell type:code id: tags:
```
python
from
ipywidgets
import
interact
,
interactive
,
fixed
,
HBox
,
VBox
import
ipywidgets
as
widgets
from
IPython.display
import
clear_output
,
display
,
HTML
from
IPython.display
import
Markdown
as
md
from
ient_nb.ient_plots
import
*
from
src.laplace.laplace_plot
import
pzPoint
,
pzPlot
from
src.laplace.inline_plot
import
inline_plot
%
matplotlib
inline
import
matplotlib.pyplot
as
plt
import
matplotlib.gridspec
as
gridspec
import
numpy
as
np
```
%% Cell type:code id: tags:
```
python
inline_plot
(
'right'
)
```
%% Cell type:code id: tags:
```
python
inline_plot
(
'left'
)
```
%% Cell type:code id: tags:
```
python
%
matplotlib
notebook
%
matplotlib
notebook
pzp
=
pzPlot
()
filter_type
=
interactive
(
pzp
.
update_filter
,
filtr
=
widgets
.
Dropdown
(
options
=
list
(
pzp
.
filter_types
.
keys
()),
value
=
"Sprungfunktion"
,
description
=
'Filter'
))
action_type
=
interactive
(
pzp
.
update_action
,
action
=
widgets
.
Dropdown
(
options
=
list
(
pzp
.
action_types
.
keys
()),
value
=
"Hinzufügen"
,
description
=
'Modus'
))
point_type
=
interactive
(
pzp
.
update_mode
,
mode
=
widgets
.
Dropdown
(
options
=
list
(
pzp
.
mode_types
.
keys
()),
value
=
"Polstelle"
,
description
=
'Typ'
))
amp_type
=
interactive
(
pzp
.
update_amp
,
H0
=
widgets
.
IntSlider
(
min
=
1
,
max
=
10
,
step
=
1
,
value
=
1
),
description
=
"H0"
)
left_box
=
VBox
([
filter_type
,
amp_type
])
right_box
=
VBox
([
action_type
,
point_type
])
HBox
([
left_box
,
right_box
])
```
%% Cell type:code id: tags:
```
python
# Achse wandert hoch - ient_axis?
# update_signal todos beachten
# dirac spitzer!
# f statt omega
# Skript S. 18 2.2 P/N-Diagramm, 2 Cells versch. KBs, pn und t plotten
```
%% Cell type:code id: tags:
```
python
``
`
%%
Cell
type
:
code
id
:
tags
:
```
python
```
...
...
src/funcs.py
View file @
2ef56d07
...
...
@@ -191,7 +191,11 @@ def calc_laplace(t=np.linspace(-6, 6, num=1024), f = np.linspace(-6, 6, num=1024
tmp
=
np
.
append
(
tmp
,
np
.
array
(
Polstellen
[
i
]
*
np
.
ones
(
GradPolstellen
[
i
])))
p
=
np
.
poly
(
tmp
)
A
[
-
len
(
p
):,
col
]
=
p
try
:
A
[
-
len
(
p
):,
col
]
=
p
except
TypeError
:
A
[
-
int
(
p
):,
col
]
=
p
for
i
in
range
(
0
,
len
(
Polstellen
)):
for
j
in
range
(
1
,
GradPolstellen
[
i
]
+
1
):
...
...
@@ -255,12 +259,13 @@ def calc_laplace(t=np.linspace(-6, 6, num=1024), f = np.linspace(-6, 6, num=1024
if
a
[
0
]
>
0
:
h
=
np
.
array
(
np
.
real
(
h
),
dtype
=
float
)
h
=
mod
.
addDirac
(
h
,
a
[
0
]
*
mod
.
dirac_fcn
(
t
))
type
=
'dirac'
else
:
print
(
"
Zaehlergrad größer als Nennergrad. Keine Partialbruchzerlegung möglich
!"
)
#
Zaehlergrad größer als Nennergrad. Keine Partialbruchzerlegung möglich
h
=
np
.
array
([
np
.
NaN
for
x
in
t
])
return
h
,
H
return
h
,
H
,
type
def
calc_dft
(
t
,
s
,
length
,
k_max
):
s_shifted
=
np
.
concatenate
((
s
[
int
(
length
/
2
):],
s
[:
int
(
length
/
2
)]))
...
...
src/laplace/laplace_plot.py
View file @
2ef56d07
...
...
@@ -108,11 +108,18 @@ class pzPlot():
self
.
handles
[
'axh'
]
=
plt
.
subplot
(
gs
[
1
,
0
])
self
.
handles
[
'axh'
].
set_title
(
'Impulsantwort'
,
fontsize
=
'16'
,
fontweight
=
'bold'
)
self
.
handles
[
'axh'
].
set_xlabel
(
r
'$\rightarrow \mathrm{t}$'
)
self
.
handles
[
'axh'
].
set_ylabel
(
r
'$\uparrow \mathrm{s(t)}$'
)
self
.
pbzErrortxt
=
self
.
handles
[
'axh'
].
text
(
-
4.5
,
0.55
,
# hässlich
'Zählergrad größer als Nennergrad.
\n
Keine Partialbruchzerlegung möglich!'
,
fontsize
=
12
,
visible
=
False
)
self
.
handles
[
'lineh'
],
=
self
.
handles
[
'axh'
].
plot
(
self
.
t
,
self
.
t
)
ient_axis
(
self
.
handles
[
'axh'
])
self
.
handles
[
'axH'
]
=
plt
.
subplot
(
gs
[
1
,
1
])
self
.
handles
[
'axH'
].
set_title
(
'Übertragungsfunktion'
,
fontsize
=
'16'
,
fontweight
=
'bold'
)
self
.
handles
[
'lineH'
],
=
self
.
handles
[
'axH'
].
plot
(
self
.
f
,
self
.
f
)
self
.
handles
[
'axH'
].
set_xlabel
(
r
'$\rightarrow f$'
)
self
.
handles
[
'axH'
].
set_ylabel
(
r
'$\uparrow \mathrm{|S(f)|}$'
)
ient_axis
(
self
.
handles
[
'axH'
])
# TODO ient_axis für H ändern
#self.handles['axH'].spines['bottom'].set_position('center')
...
...
@@ -378,17 +385,28 @@ class pzPlot():
H0
=
self
.
H0
roc
=
self
.
roc
[
'sigma'
]
s_t
,
S_f
=
func
.
calc_laplace
(
self
.
t
,
self
.
f
,
H0
,
poles
,
zeroes
,
poles_order
,
zeroes_order
,
roc
)
# calculate extreme values, for ylims
s_t_extr
=
[
np
.
amin
(
np
.
real
(
s_t
)),
np
.
amax
(
np
.
real
(
s_t
))]
S_f_extr
=
[
np
.
amin
(
np
.
real
(
S_f
)),
np
.
amax
(
np
.
real
(
S_f
))]
s_t
,
S_f
,
signal_type
=
func
.
calc_laplace
(
self
.
t
,
self
.
f
,
H0
,
poles
,
zeroes
,
poles_order
,
zeroes_order
,
roc
)
# set ylims
self
.
handles
[
'axh'
].
set_ylim
(
s_t_extr
[
0
]
+
s_t_extr
[
0
]
/
10
,
s_t_extr
[
1
]
+
s_t_extr
[
1
]
/
10
)
# process signals
if
not
np
.
isnan
(
s_t
[
0
]):
# if pbz was not successful
self
.
pbzErrortxt
.
set_visible
(
False
)
if
signal_type
==
''
:
# if signal does not contain any diracs -> set y-lims according to min, max in array
s_t_extr
=
[
np
.
amin
(
np
.
real
(
s_t
)),
np
.
amax
(
np
.
real
(
s_t
))]
self
.
handles
[
'axh'
].
set_ylim
(
s_t_extr
[
0
]
+
s_t_extr
[
0
]
/
10
,
s_t_extr
[
1
]
+
s_t_extr
[
1
]
/
10
)
elif
signal_type
==
'dirac'
:
# if signal contains diracs -> plot dirac and set y-data
# TODO - plot dirac
_
,
value
=
func
.
findDirac
(
s_t
)
self
.
handles
[
'axh'
].
set_ylim
(
0
,
np
.
amax
(
value
)
+
0.2
)
else
:
self
.
handles
[
'axh'
].
set_ylim
(
-
1
,
1
)
self
.
pbzErrortxt
.
set_visible
(
True
)
# TODO - schlecht, da rechenintensiv (workaround wegen inf in S_f -> nehme Maximalwert, der nicht unendlich ist)
S_f_extr
=
[
np
.
amin
(
np
.
real
(
S_f
)),
np
.
nanmax
(
np
.
isfinite
(
np
.
real
(
S_f
))
*
np
.
real
(
S_f
))]
self
.
handles
[
'axH'
].
set_ylim
(
S_f_extr
[
0
]
+
S_f_extr
[
0
]
/
10
,
S_f_extr
[
1
]
+
S_f_extr
[
1
]
/
10
)
ient_axis
(
self
.
handles
[
'axh'
])
# TODO - Eigene Funktion plottet s(t) nicht, was läuft hier schief?
#plot(self.t, s_t, self.handles['axh'])
...
...
Write
Preview
Supports
Markdown
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