Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SFTbin.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Badri Krishnan, Reinhard Prix, Alicia Sintes Olives
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*-----------------------------------------------------------------------
21 *
22 * File Name: SFTbin.c
23 *
24 * Authors: Sintes, A.M., Krishnan, B. & inspired from Siemens, X.
25 *
26 *
27 * History: Created by Sintes May 21, 2003
28 * Modified by Krishnan on Feb 22, 2004
29 *
30 *-----------------------------------------------------------------------
31 */
32
33/** OBSOLETE -- Use LAL functions from SFTfileIO.c instead */
34
35/**
36 * \author Sintes, A.M., Krishnan, B.
37 *
38 * ### SFTbin.c ###
39 *
40 * Routines for reading SFT binary files
41 *
42 * ### Prototypes ###
43 *
44 * <tt>ReadSFTbinHeader1()</tt>
45 * <tt>ReadCOMPLEX8SFTbinData1()</tt>
46 * <tt>ReadCOMPLEX16SFTbinData1()</tt>
47 * <tt>COMPLEX8SFT2Periodogram1()</tt>
48 * <tt>COMPLEX16SFT2Periodogram1()</tt>
49 *
50 * ### Description ###
51 *
52 * the output of the periodogram should be properly normalized !!!
53 *
54 * ### Uses ###
55 *
56 * \code
57 * LALHO()
58 * \endcode
59 */
60
61#include "SFTbin.h"
62
63/*
64 * The functions that make up the guts of this module
65 */
66
67/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
68
71 COMPLEX8SFTData1 *sft )
72{
73
74 INT4 length;
75
76 /* --------------------------------------------- */
79
80 /* Make sure the arguments are not NULL: */
83
84 peri->epoch.gpsSeconds = sft->epoch.gpsSeconds;
86 peri->timeBase = sft->timeBase;
87 peri->fminBinIndex = sft->fminBinIndex;
88
89 length = sft->length;
90 ASSERT( length == peri->length, status, SFTBINH_EVAL, SFTBINH_MSGEVAL );
91
92 if ( length > 0 ) {
93 REAL8 *out;
94 COMPLEX8 *in1;
95 REAL8 re, im, factor;
96 INT4 n;
97
100 out = peri->data;
101 in1 = sft->data;
102 n = length;
103
104 /* if data was properly normalized */
105 factor = 1. / peri->timeBase;
106
107 /* if data is not normalized... this factor needs to be clarified */
108 /* note inconsistency with the previous function and quantity *factor* there */
109
110 /* if bin zero is included should be treated properly because of factor 2 */
111
112 while ( n-- > 0 ) {
113 re = crealf( *in1 );
114 im = cimagf( *in1 );
115 *out = ( re * re + im * im ) * factor; /* factor 2 still missing if one-sided*/
116 ++out;
117 ++in1;
118 }
119 }
120
121
122
124 /* normal exit */
125 RETURN( status );
126}
127
128
129
130
131/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
132
134 REAL8Periodogram1 *peri,
135 SFTtype *sft )
136{
137
138 INT4 length;
139 REAL8 f0, deltaF;
140 /* --------------------------------------------- */
143
144 /* Make sure the arguments are not NULL: */
147
148 f0 = sft->f0;
149 deltaF = sft->deltaF;
150 length = sft->data->length;
151
152 peri->epoch.gpsSeconds = sft->epoch.gpsSeconds;
154 peri->timeBase = 1.0 / deltaF;
155 peri->fminBinIndex = floor( f0 / deltaF + 0.5 );
156
157 ASSERT( length == peri->length, status, SFTBINH_EVAL, SFTBINH_MSGEVAL );
158
159 if ( length > 0 ) {
160 REAL8 *out;
161 COMPLEX8 *in1;
162 REAL8 re, im, factor;
163 INT4 n;
164
167 out = peri->data;
168 in1 = sft->data->data;
169 n = length;
170
171 /* if data was properly normalized */
172 factor = 1. / peri->timeBase;
173
174 /* if data is not normalized... this factor needs to be clarified */
175 /* note inconsistency with the previous function and quantity *factor* there */
176
177 /* if bin zero is included should be treated properly because of factor 2 */
178
179 while ( n-- > 0 ) {
180 re = crealf( *in1 );
181 im = cimagf( *in1 );
182 *out = ( re * re + im * im ) * factor; /* factor 2 still missing if one-sided*/
183 ++out;
184 ++in1;
185 }
186 }
187
188
189
191 /* normal exit */
192 RETURN( status );
193}
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
void SFT2Periodogram(LALStatus *status, REAL8Periodogram1 *peri, SFTtype *sft)
Definition: SFTbin.c:133
void COMPLEX8SFT2Periodogram1(LALStatus *status, REAL8Periodogram1 *peri, COMPLEX8SFTData1 *sft)
OBSOLETE – Use LAL functions from SFTfileIO.c instead.
Definition: SFTbin.c:69
#define SFTBINH_ENULL
Definition: SFTbin.h:99
#define SFTBINH_MSGEVAL
Definition: SFTbin.h:112
#define SFTBINH_EVAL
Definition: SFTbin.h:103
#define SFTBINH_MSGENULL
Definition: SFTbin.h:108
double REAL8
float complex COMPLEX8
int32_t INT4
n
out
int deltaF
COMPLEX8Sequence * data
LIGOTimeGPS epoch
Definition: SFTbin.h:138
REAL8 timeBase
Definition: SFTbin.h:139
COMPLEX8 * data
Definition: SFTbin.h:142
INT4 fminBinIndex
Definition: SFTbin.h:140
COMPLEX8 * data
INT4 gpsNanoSeconds
REAL8 timeBase
Definition: SFTbin.h:160
LIGOTimeGPS epoch
Definition: SFTbin.h:159
INT4 fminBinIndex
Definition: SFTbin.h:161
REAL8 * data
Definition: SFTbin.h:163