Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
chrip_demodulator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Benedikt
chrip_demodulator
Commits
0068d53e
Commit
0068d53e
authored
1 year ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
added first version
parent
d84753f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitmodules
+3
-0
3 additions, 0 deletions
.gitmodules
main.py
+64
-9
64 additions, 9 deletions
main.py
with
67 additions
and
9 deletions
.gitmodules
0 → 100644
+
3
−
0
View file @
0068d53e
[submodule "sinetools"]
path = sinetools
url = https://gitlab1.ptb.de/TBruns/sinetools.git
This diff is collapsed.
Click to expand it.
main.py
+
64
−
9
View file @
0068d53e
# This is a sample Python script.
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import
numpy
as
np
import
scipy
as
sp
import
matplotlib.pyplot
as
plt
import
sinetools.SineTools
as
st
# This is a sample Python script.
def
plot_spectrogram
(
title
,
w
,
fs
):
ff
,
tt
,
Sxx
=
sp
.
signal
.
spectrogram
(
w
,
fs
=
fs
,
nperseg
=
64
,
nfft
=
128
)
fig
,
ax
=
plt
.
subplots
()
ax
.
pcolormesh
(
tt
,
ff
[:
145
],
Sxx
[:
145
],
cmap
=
'
gray_r
'
,
shading
=
'
gouraud
'
)
ax
.
set_title
(
title
)
fig
.
show
()
def
chripphaseFromZero
(
ts
,
f0
,
fstop
):
#berechnet die thoretirsche phase aktuell gibts noch nen liniearen offset zum sine fit ....
f0
=
f0
sweepSeed
=
(
fstop
-
f0
)
/
ts
[
-
1
]
phase
=
2
*
np
.
pi
*
(
f0
*
ts
+
((
sweepSeed
*
ts
*
ts
)
/
2
))
return
-
1
*
phase
def
chripLocalSineFitter
(
t
,
y
,
f0
,
f1
,
blockSize
=
8
):
#fiittet mit der block size sequenziell 3 param sin approxxes und gibt amplitude und phase zurück
ft
=
np
.
linspace
(
f0
,
f1
,
t
.
size
)
abcs
=
np
.
zeros
((
t
.
size
-
blockSize
,
3
))
fMeanLoacl
=
np
.
zeros
((
t
.
size
-
blockSize
))
for
i
in
range
(
t
.
size
-
blockSize
):
fMeanLoacl
[
i
]
=
np
.
mean
(
ft
[
i
:
i
+
blockSize
])
ts
=
t
[
i
:
i
+
blockSize
]
ys
=
y
[
i
:
i
+
blockSize
]
abcs
[
i
,:]
=
st
.
threeparsinefit
(
ys
,
ts
,
fMeanLoacl
[
i
])
complexes
=
abcs
[:,
0
]
*
1j
+
abcs
[:,
1
]
#komplexe fit ergebnisse ggf. auch nützlich
amp
=
np
.
abs
(
complexes
)
phase
=
np
.
angle
(
complexes
)
fig
,
ax
=
plt
.
subplots
()
ax
.
plot
(
fMeanLoacl
,
amp
,
label
=
"
amp
"
)
ax
.
plot
(
fMeanLoacl
,
np
.
unwrap
(
phase
),
label
=
'
phase
'
)
theoreticalChirpPhase
=
chripphaseFromZero
(
t
,
f0
,
f1
)
theoreticalChirpPhase
=
theoreticalChirpPhase
[:
-
blockSize
]
ax
.
plot
(
fMeanLoacl
,
theoreticalChirpPhase
,
label
=
"
theorie phase
"
)
ax
.
plot
(
fMeanLoacl
,
np
.
unwrap
(
phase
)
-
theoreticalChirpPhase
,
label
=
"
phase-theorie
"
)
ax
.
legend
()
fig
.
show
()
print
(
"
Done
"
)
return
fMeanLoacl
,
amp
,
np
.
unwrap
(
phase
)
def
print_hi
(
name
):
# Use a breakpoint in the code line below to debug your script.
print
(
f
'
Hi,
{
name
}
'
)
# Press Strg+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if
__name__
==
'
__main__
'
:
print_hi
(
'
PyCharm
'
)
startTime
=
0
stopTime
=
0.160
points
=
4096
f0
=
10
f1
=
2500
timePoints
=
np
.
linspace
(
startTime
,
stopTime
,
num
=
points
)
fs
=
points
/
(
stopTime
-
startTime
)
chirptimeSignal
=
sp
.
signal
.
chirp
(
timePoints
,
f0
=
f0
,
f1
=
f1
,
t1
=
timePoints
[
-
1
])
"""
fig1,ax1=plt.subplots()
plt.title(
"
Linear Chirp time
"
)
plt.xlabel(
'
t (sec)
'
)
plt.plot(timePoints,chirptimeSignal)
plt.show()
"""
chripLocalSineFitter
(
timePoints
,
chirptimeSignal
,
f0
,
f1
,
blockSize
=
16
)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
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