Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GstLAL
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
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
lscsoft
GstLAL
Commits
e1ee1ad5
Commit
e1ee1ad5
authored
4 years ago
by
Patrick Godwin
Committed by
Madeline Wade
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
reference_psd.measure_psd(): convert to stream API
parent
a2ac86a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gstlal/python/psd.py
+33
-30
33 additions, 30 deletions
gstlal/python/psd.py
with
33 additions
and
30 deletions
gstlal/python/psd.py
+
33
−
30
View file @
e1ee1ad5
...
...
@@ -55,6 +55,7 @@ from gstlal import datasource
from
gstlal
import
pipeparts
from
gstlal
import
pipeio
from
gstlal
import
simplehandler
from
gstlal.stream
import
MessageType
,
Stream
__doc__
=
"""
...
...
@@ -95,6 +96,15 @@ class PSDHandler(simplehandler.Handler):
return
False
class
PSDTracker
:
def
__init__
(
self
):
self
.
psd
=
None
def
on_spectrum_message
(
self
,
message
):
self
.
psd
=
pipeio
.
parse_spectrum_message
(
message
)
return
True
#
# measure_psd()
#
...
...
@@ -138,53 +148,46 @@ def measure_psd(gw_data_source_info, instrument, rate, psd_fft_length = 8, verbo
raise
ValueError
(
"
segment %s too short
"
%
str
(
gw_data_source_info
.
seg
))
#
#
build pipeline
#
calculate number of samples to average over
#
if
verbose
:
print
(
"
measuring PSD in segment %s
"
%
str
(
gw_data_source_info
.
seg
),
file
=
sys
.
stderr
)
print
(
"
building pipeline ...
"
,
file
=
sys
.
stderr
)
mainloop
=
GObject
.
MainLoop
()
pipeline
=
Gst
.
Pipeline
(
name
=
"
psd
"
)
handler
=
PSDHandler
(
mainloop
,
pipeline
)
head
,
_
,
_
=
datasource
.
mkbasicsrc
(
pipeline
,
gw_data_source_info
,
instrument
,
verbose
=
verbose
)
head
=
pipeparts
.
mkcapsfilter
(
pipeline
,
head
,
"
audio/x-raw, rate=[%d,MAX]
"
%
rate
)
# disallow upsampling
head
=
pipeparts
.
mkresample
(
pipeline
,
head
,
quality
=
9
)
head
=
pipeparts
.
mkcapsfilter
(
pipeline
,
head
,
"
audio/x-raw, rate=%d
"
%
rate
)
head
=
pipeparts
.
mkqueue
(
pipeline
,
head
,
max_size_buffers
=
8
)
if
gw_data_source_info
.
seg
is
not
None
:
average_samples
=
int
(
round
(
float
(
abs
(
gw_data_source_info
.
seg
))
/
(
psd_fft_length
/
2.
)
-
1.
))
else
:
#FIXME maybe let the user specify this
average_samples
=
64
head
=
pipeparts
.
mkwhiten
(
pipeline
,
head
,
psd_mode
=
0
,
zero_pad
=
0
,
fft_length
=
psd_fft_length
,
average_samples
=
average_samples
,
median_samples
=
7
)
pipeparts
.
mkfakesink
(
pipeline
,
head
)
#
#
setup signal handler to shutdown pipe
li
n
e
for live data
#
initia
li
z
e
PSD tracker
#
if
gw_data_source_info
.
data_source
in
(
"
lvshm
"
,
"
framexmit
"
):
# FIXME what about nds online?
simplehandler
.
OneTimeSignalHandler
(
pipeline
)
tracker
=
PSDTracker
()
#
#
process segment
#
build pipeline
#
if
verbose
:
print
(
"
putting pipeline into READY state ...
"
,
file
=
sys
.
stderr
)
if
pipeline
.
set_state
(
Gst
.
State
.
READY
)
==
Gst
.
StateChangeReturn
.
FAILURE
:
raise
RuntimeError
(
"
pipeline failed to enter READY state
"
)
if
gw_data_source_info
.
data_source
not
in
(
"
lvshm
"
,
"
framexmit
"
):
# FIXME what about nds online?
datasource
.
pipeline_seek_for_gps
(
pipeline
,
*
gw_data_source_info
.
seg
)
if
verbose
:
print
(
"
putting pipeline into PLAYING state ...
"
,
file
=
sys
.
stderr
)
if
pipeline
.
set_state
(
Gst
.
State
.
PLAYING
)
==
Gst
.
StateChangeReturn
.
FAILURE
:
raise
RuntimeError
(
"
pipeline failed to enter PLAYING state
"
)
print
(
"
measuring PSD in segment %s
"
%
str
(
gw_data_source_info
.
seg
),
file
=
sys
.
stderr
)
print
(
"
building pipeline ...
"
,
file
=
sys
.
stderr
)
stream
=
Stream
.
from_datasource
(
gw_data_source_info
,
instrument
,
verbose
=
verbose
)
stream
.
add_callback
(
MessageType
.
ELEMENT
,
"
spectrum
"
,
tracker
.
on_spectrum_message
)
stream
=
stream
.
capsfilter
(
f
"
audio/x-raw, rate=[
{
rate
:
d
}
,MAX]
"
)
# disallow upsampling
stream
.
resample
(
quality
=
9
)
\
.
capsfilter
(
f
"
audio/x-raw, rate=
{
rate
:
d
}
"
)
\
.
queue
(
max_size_buffers
=
8
)
\
.
whiten
(
psd_mode
=
0
,
zero_pad
=
0
,
fft_length
=
psd_fft_length
,
average_samples
=
average_samples
,
median_samples
=
7
)
\
.
fakesink
()
#
# process segment
#
if
verbose
:
print
(
"
running pipeline ...
"
,
file
=
sys
.
stderr
)
mainloop
.
run
()
stream
.
start
()
#
# done
...
...
@@ -192,7 +195,7 @@ def measure_psd(gw_data_source_info, instrument, rate, psd_fft_length = 8, verbo
if
verbose
:
print
(
"
PSD measurement complete
"
,
file
=
sys
.
stderr
)
return
handl
er
.
psd
return
track
er
.
psd
def
read_psd
(
filename
:
str
,
verbose
:
Optional
[
bool
]
=
False
)
->
Dict
[
str
,
lal
.
REAL8FrequencySeries
]:
...
...
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