Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gstlal-calibration
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
LIGO Calibration
gstlal-calibration
Commits
ce17292f
Commit
ce17292f
authored
7 years ago
by
Aaron Viets
Browse files
Options
Downloads
Patches
Plain Diff
lal_transferfunction: debugged fir filter generation and file writing capability
parent
7e09c4d1
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
gst/lal/gstlal_transferfunction.c
+26
-15
26 additions, 15 deletions
gst/lal/gstlal_transferfunction.c
with
26 additions
and
15 deletions
gst/lal/gstlal_transferfunction.c
+
26
−
15
View file @
ce17292f
...
...
@@ -167,15 +167,15 @@ static void write_transfer_functions(complex double *tfs, char *element_name, gi
gint64
i
;
int
j
,
j_stop
;
if
(
write_to_screen
)
{
g_print
(
"
\n\n
========= Transfer functions computed by %s =========
\n
"
,
element_name
);
g_print
(
"
\n\n
=========
===========
Transfer functions computed by %s =========
===========
\n\t
"
,
element_name
);
for
(
j
=
1
;
j
<
columns
;
j
++
)
g_print
(
"ch%d -> ch0
\t
"
,
j
);
g_print
(
"ch%d -> ch0
\t
\t\t\t
"
,
j
);
g_print
(
"ch%d -> ch0
\n\n
"
,
columns
);
j_stop
=
columns
-
1
;
for
(
i
=
0
;
i
<
rows
;
i
++
)
{
for
(
j
=
0
;
j
<
j_stop
;
j
++
)
g_print
(
"%10e + %10e i
\t
"
,
creal
(
tfs
[
i
+
j
*
rows
]),
cimag
(
tfs
[
i
+
j
*
rows
]));
g_print
(
"%10e + %10e i
\t
\t
"
,
creal
(
tfs
[
i
+
j
*
rows
]),
cimag
(
tfs
[
i
+
j
*
rows
]));
g_print
(
"%10e + %10e i
\n
"
,
creal
(
tfs
[
i
+
j_stop
*
rows
]),
cimag
(
tfs
[
i
+
j_stop
*
rows
]));
}
g_print
(
"
\n\n
"
);
...
...
@@ -183,18 +183,19 @@ static void write_transfer_functions(complex double *tfs, char *element_name, gi
if
(
filename
)
{
FILE
*
fp
;
fp
=
fopen
(
filename
,
"
w
"
);
g_fprintf
(
fp
,
"========= Transfer functions computed by %s =========
\n
"
,
element_name
);
fp
=
fopen
(
filename
,
"
a
"
);
g_fprintf
(
fp
,
"=========
===========
Transfer functions computed by %s =========
===========
\n\t
"
,
element_name
);
for
(
j
=
1
;
j
<
columns
;
j
++
)
g_fprintf
(
fp
,
"ch%d -> ch0
\t
"
,
j
);
g_fprintf
(
fp
,
"ch%d -> ch0
\t
\t\t\t
"
,
j
);
g_fprintf
(
fp
,
"ch%d -> ch0
\n\n
"
,
columns
);
j_stop
=
columns
-
1
;
for
(
i
=
0
;
i
<
rows
;
i
++
)
{
for
(
j
=
0
;
j
<
j_stop
;
j
++
)
g_fprintf
(
fp
,
"%10e + %10e i
\t
"
,
creal
(
tfs
[
i
+
j
*
rows
]),
cimag
(
tfs
[
i
+
j
*
rows
]));
g_fprintf
(
fp
,
"%10e + %10e i
\t
\t
"
,
creal
(
tfs
[
i
+
j
*
rows
]),
cimag
(
tfs
[
i
+
j
*
rows
]));
g_fprintf
(
fp
,
"%10e + %10e i
\n
"
,
creal
(
tfs
[
i
+
j_stop
*
rows
]),
cimag
(
tfs
[
i
+
j_stop
*
rows
]));
}
g_fprintf
(
fp
,
"
\n\n
"
);
fclose
(
fp
);
}
g_free
(
element_name
);
...
...
@@ -205,7 +206,7 @@ static void write_fir_filters(double *filters, char *element_name, gint64 rows,
gint64
i
;
int
j
,
j_stop
;
if
(
write_to_screen
)
{
g_print
(
"============ FIR filters computed by %s ============
\n
"
,
element_name
);
g_print
(
"============
======
FIR filters computed by %s
======
============
\n
"
,
element_name
);
for
(
j
=
1
;
j
<
columns
;
j
++
)
g_print
(
"ch%d -> ch0
\t
"
,
j
);
g_print
(
"ch%d -> ch0
\n\n
"
,
columns
);
...
...
@@ -221,8 +222,8 @@ static void write_fir_filters(double *filters, char *element_name, gint64 rows,
if
(
filename
)
{
FILE
*
fp
;
fp
=
fopen
(
filename
,
"
w
"
);
g_fprintf
(
fp
,
"
\n\n
============ FIR filters computed by %s ============
\n
"
,
element_name
);
fp
=
fopen
(
filename
,
"
a
"
);
g_fprintf
(
fp
,
"
======
============ FIR filters computed by %s
======
============
\n
"
,
element_name
);
for
(
j
=
1
;
j
<
columns
;
j
++
)
g_fprintf
(
fp
,
"ch%d -> ch0
\t
"
,
j
);
g_fprintf
(
fp
,
"ch%d -> ch0
\n\n
"
,
columns
);
...
...
@@ -233,6 +234,7 @@ static void write_fir_filters(double *filters, char *element_name, gint64 rows,
g_fprintf
(
fp
,
"%10e
\t
"
,
filters
[
i
+
j
*
rows
]);
g_fprintf
(
fp
,
"%10e
\n
"
,
filters
[
i
+
j_stop
*
rows
]);
}
g_fprintf
(
fp
,
"
\n\n
"
);
fclose
(
fp
);
}
g_free
(
element_name
);
...
...
@@ -284,11 +286,12 @@ static void update_fir_filters_ ## DTYPE(complex double *transfer_functions, int
\
int i; \
gint64 j, zero_index, fir_length; \
DTYPE df, delay, exp_arg; \
DTYPE df, delay; \
complex DTYPE exp_arg; \
fir_length = 2 * (length_tfs - 1); \
df = sample_rate / 2.0 / (length_tfs - 1);
/* frequency spacing is Nyquist frequency / number of frequency increments */
\
delay = (length_tfs - 1.0) / sample_rate;
/* number of samples of delay is length of transfer functions - 1 */
\
exp_arg = -2.0 * M_PI * I * df * delay; \
exp_arg =
(complex DTYPE) (
-2.0 * M_PI * I * df * delay
)
; \
for(i = 0; i < num_tfs; i++) { \
/*
* First, copy samples from transfer_functions to fir_filter for fftw(f) to take an inverse fft.
...
...
@@ -296,7 +299,7 @@ static void update_fir_filters_ ## DTYPE(complex double *transfer_functions, int
* A delay is also added in order to center the filter in time.
*/
\
for(j = 0; j < length_tfs; j++) \
fir_filter[j] = fd_window[j] * cexp ## F_OR_BLANK(exp_arg * j) * transfer_functions[i * length_tfs + j]; \
fir_filter[j] = fd_window[j] * cexp ## F_OR_BLANK(exp_arg * j) *
(DTYPE)
transfer_functions[i * length_tfs + j]; \
\
/* Now make fir_filter conjugate symmetric by filling the remaining memory with complex conjugates */
\
zero_index = length_tfs - 1; \
...
...
@@ -532,6 +535,10 @@ static gboolean start(GstBaseSink *sink) {
/* At start of stream, we want the element to compute a transfer function as soon as possible */
element
->
sample_count
=
element
->
update_samples
;
/* If we are writing output to file, and a file already exists with the same name, remove it */
if
(
element
->
filename
)
remove
(
element
->
filename
);
return
TRUE
;
}
...
...
@@ -736,6 +743,8 @@ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps) {
fir_length
=
2
*
(
element
->
fft_length
-
1
);
edge_to_corner
=
(
gint64
)
(
0
.
45
*
fir_length
);
element
->
workspace
.
wspf
.
tukey
=
g_malloc
(
fir_length
*
sizeof
(
*
element
->
workspace
.
wspf
.
tukey
));
/* first curve of window */
for
(
i
=
0
;
i
<
edge_to_corner
;
i
++
)
element
->
workspace
.
wspf
.
tukey
[
i
]
=
pow
(
sin
((
M_PI
/
2
.
0
)
*
i
/
edge_to_corner
),
2
.
0
);
...
...
@@ -773,7 +782,7 @@ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps) {
element
->
workspace
.
wspf
.
fft
=
(
complex
float
*
)
fftwf_malloc
(
element
->
fft_length
*
sizeof
(
*
element
->
workspace
.
wspf
.
fft
));
element
->
workspace
.
wspf
.
plan
=
fftwf_plan_dft_r2c_1d
(
element
->
fft_length
,
(
float
*
)
element
->
workspace
.
wspf
.
fft
,
element
->
workspace
.
wspf
.
fft
,
FFTW_MEASURE
);
if
(
element
->
make_fir_filters
&&
!
element
->
fir_filter
s
)
{
if
(
element
->
make_fir_filters
&&
!
element
->
workspace
.
wspf
.
fir_filter
)
{
/* data that will be inverse Fourier transformed back into the time domain */
element
->
workspace
.
wspf
.
fir_filter
=
(
complex
float
*
)
fftwf_malloc
(
2
*
(
element
->
fft_length
-
1
)
*
sizeof
(
*
element
->
workspace
.
wspf
.
fir_filter
));
...
...
@@ -846,6 +855,8 @@ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps) {
fir_length
=
2
*
(
element
->
fft_length
-
1
);
edge_to_corner
=
(
gint64
)
(
0
.
45
*
fir_length
);
element
->
workspace
.
wdpf
.
tukey
=
g_malloc
(
fir_length
*
sizeof
(
*
element
->
workspace
.
wdpf
.
tukey
));
/* first curve of window */
for
(
i
=
0
;
i
<
edge_to_corner
;
i
++
)
element
->
workspace
.
wdpf
.
tukey
[
i
]
=
pow
(
sin
((
M_PI
/
2
.
0
)
*
i
/
edge_to_corner
),
2
.
0
);
...
...
@@ -883,7 +894,7 @@ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps) {
element
->
workspace
.
wdpf
.
fft
=
(
complex
double
*
)
fftw_malloc
(
element
->
fft_length
*
sizeof
(
*
element
->
workspace
.
wdpf
.
fft
));
element
->
workspace
.
wdpf
.
plan
=
fftw_plan_dft_r2c_1d
(
element
->
fft_length
,
(
double
*
)
element
->
workspace
.
wdpf
.
fft
,
element
->
workspace
.
wdpf
.
fft
,
FFTW_MEASURE
);
if
(
element
->
make_fir_filters
&&
!
element
->
fir_filter
s
)
{
if
(
element
->
make_fir_filters
&&
!
element
->
workspace
.
wdpf
.
fir_filter
)
{
/* data that will be inverse Fourier transformed back into the time domain */
element
->
workspace
.
wdpf
.
fir_filter
=
(
complex
double
*
)
fftw_malloc
(
2
*
(
element
->
fft_length
-
1
)
*
sizeof
(
*
element
->
workspace
.
wdpf
.
fir_filter
));
...
...
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