Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar
7.1.1.1-b246709
LALSuite
LAL
LALFrame
LALMetaIO
LALSimulation
LALBurst
LALInspiral
LALInference
LALPulsar
LALApps
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
SFTWindowFuncs.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007 Gregory Mendell
3
* Copyright (C) 2010, 2011, 2016 Bernd Machenschalk
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with with program; see the file COPYING. If not, write to the
17
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
* MA 02110-1301 USA
19
*/
20
21
#include "config.h"
22
23
#include <math.h>
24
25
#include <lal/LALStdlib.h>
26
#include <lal/LALConstants.h>
27
28
/* GLOBAL VARIABLES */
29
REAL8
winFncRMS
= 1.0;
/* 10/05/12 gam; global variable with the RMS of the window function; default value is 1.0 */
30
REAL8TimeSeries
dataDouble
;
31
32
/* FUNCTION PROTOTYPES */
33
int
WindowData
(
REAL8
r
);
34
int
WindowDataTukey2
(
void
);
35
int
WindowDataHann
(
void
);
36
37
int
WindowData
(
const
REAL8
r
)
38
{
39
INT4
k
,
N
, kl, kh;
40
/* 10/05/12 gam */
41
REAL8
win
;
42
/* This implementation of a Tukey window is describes
43
in the Matlab tukey window documentation */
44
45
/* initialize the RMS of the window function */
46
winFncRMS
= 0.0;
47
48
N
=
dataDouble
.
data
->
length
;
49
kl =
r
/ 2 * (
N
- 1 ) + 1;
50
kh =
N
-
r
/ 2 * (
N
- 1 ) + 1;
51
for
(
k
= 1;
k
< kl;
k
++ ) {
52
/* dataDouble.data->data[k-1]=dataDouble.data->data[k-1]*0.5*( 1.0 + cos(LAL_TWOPI/r*(k-1)/(N-1) - LAL_PI) ); */
53
win
= 0.5 * ( 1.0 + cos(
LAL_TWOPI
/
r
* (
k
- 1 ) / (
N
- 1 ) -
LAL_PI
) );
54
dataDouble
.
data
->
data
[
k
- 1] *=
win
;
55
winFncRMS
+=
win
*
win
;
56
}
57
for
(
k
= kh;
k
<=
N
;
k
++ ) {
58
/* dataDouble.data->data[k-1]=dataDouble.data->data[k-1]*0.5*( 1.0 + cos(LAL_TWOPI/r - LAL_TWOPI/r*(k-1)/(N-1) - LAL_PI) ); */
59
win
= 0.5 * ( 1.0 + cos(
LAL_TWOPI
/
r
-
LAL_TWOPI
/
r
* (
k
- 1 ) / (
N
- 1 ) -
LAL_PI
) );
60
dataDouble
.
data
->
data
[
k
- 1] *=
win
;
61
winFncRMS
+=
win
*
win
;
62
}
63
64
/* Add to sum of squares of the window function the parts of window which are equal to 1, and then find RMS value*/
65
winFncRMS
+= (
REAL8
)( kh - kl );
66
winFncRMS
= sqrt( (
winFncRMS
/ ( (
REAL8
)
N
) ) );
67
68
return
0;
69
}
70
71
/* Same as window function given in lalapps/src/pulsar/make_sfts.c */
72
int
WindowDataTukey2
(
void
)
73
{
74
/* Define the parameters to make the window */
75
INT4
WINSTART = 4096;
76
INT4
WINEND = 8192;
77
INT4
WINLEN = ( WINEND - WINSTART );
78
/* INT4 i; */
79
INT4
i
,
N
;
80
REAL8
win
;
81
82
83
/* initialize the RMS of the window function */
84
winFncRMS
= 0.0;
85
86
N
=
dataDouble
.
data
->
length
;
87
/* window data. Off portion */
88
for
(
i
= 0;
i
< WINSTART;
i
++ ) {
89
dataDouble
.
data
->
data
[
i
] = 0.0;
90
dataDouble
.
data
->
data
[
dataDouble
.
data
->
length
- 1 -
i
] = 0.0;
91
}
92
/* window data, smooth turn-on portion */
93
for
(
i
= WINSTART;
i
< WINEND;
i
++ ) {
94
win
= ( ( sin( (
i
- WINSTART ) *
LAL_PI
/ ( WINLEN ) -
LAL_PI_2
) + 1.0 ) / 2.0 );
95
dataDouble
.
data
->
data
[
i
] *=
win
;
96
dataDouble
.
data
->
data
[
dataDouble
.
data
->
length
- 1 -
i
] *=
win
;
97
winFncRMS
+= 2.0 *
win
*
win
;
98
}
99
100
/* Add to sum of squares of the window function the parts of window which are equal to 1, and then find RMS value*/
101
winFncRMS
+= (
REAL8
)(
N
- 2 * WINEND );
102
winFncRMS
= sqrt( (
winFncRMS
/ ( (
REAL8
)
N
) ) );
103
104
return
0;
105
}
106
107
/* Hann window based on Matlab, but with C indexing: w[k] = 0.5*( 1 - cos(2*pi*k/(N-1)) ) k = 0, 1, 2,...N-1 */
108
int
WindowDataHann
(
void
)
109
{
110
INT4
k
;
111
REAL8
win
,
N
, Nm1;
112
REAL8
real8TwoPi = 2.0 * ( (
REAL8
)(
LAL_PI
) );
113
114
/* initialize the RMS of the window function */
115
winFncRMS
= 0.0;
116
117
N
= ( (
REAL8
)
dataDouble
.
data
->
length
);
118
Nm1 =
N
- 1;
119
for
(
k
= 0;
k
<
N
;
k
++ ) {
120
win
= 0.5 * ( 1.0 - cos( real8TwoPi * ( (
REAL8
)(
k
) ) / Nm1 ) );
121
dataDouble
.
data
->
data
[
k
] *=
win
;
122
winFncRMS
+=
win
*
win
;
123
}
124
125
/* Find RMS value; note that N is REAL8 in this function */
126
winFncRMS
= sqrt( (
winFncRMS
/
N
) );
127
128
return
0;
129
}
k
int k
winFncRMS
REAL8 winFncRMS
Definition:
SFTWindowFuncs.c:29
WindowDataTukey2
int WindowDataTukey2(void)
Definition:
SFTWindowFuncs.c:72
WindowData
int WindowData(REAL8 r)
Definition:
SFTWindowFuncs.c:37
dataDouble
REAL8TimeSeries dataDouble
Definition:
SFTWindowFuncs.c:30
WindowDataHann
int WindowDataHann(void)
Definition:
SFTWindowFuncs.c:108
LAL_PI_2
#define LAL_PI_2
LAL_PI
#define LAL_PI
LAL_TWOPI
#define LAL_TWOPI
REAL8
double REAL8
INT4
int32_t INT4
r
static const INT4 r
make_frame_cache.i
int i
Definition:
make_frame_cache.py:77
N
int N
testSFTWindows.win
win
Definition:
testSFTWindows.py:36
REAL8TimeSeries
REAL8TimeSeries::data
REAL8Sequence * data
REAL8Vector::data
REAL8 * data
REAL8Vector::length
UINT4 length
bin
MakeData
SFTWindowFuncs.c
Generated on Fri Jul 11 2025 05:18:03 for LALPulsar by
1.9.4