LALApps 10.1.0.1-eeff03c
segment.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton
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#include "config.h"
21
22#include <math.h>
23#include <string.h>
24
25#include <lal/LALStdlib.h>
26#include <lal/LALStdio.h>
27#include <lal/AVFactories.h>
28#include <lal/VectorOps.h>
29#include <lal/TimeFreqFFT.h>
30#include <lal/Units.h>
31
32#include <LALAppsVCSInfo.h>
33#include "segment.h"
34#include "errutil.h"
35#include "gpstime.h"
36
37/* routine to compute a single overwhitened data segment */
40 UINT4 segmentNumber,
42 REAL4FrequencySeries *invspec,
44 REAL8 segmentDuration,
45 REAL8 strideDuration,
46 REAL4FFTPlan *fwdPlan
47 )
48{
50 REAL4Vector vec;
51 INT8 ns;
52 UINT4 segmentLength;
53 UINT4 segmentStride;
54
55 segmentLength = floor( segmentDuration/series->deltaT + 0.5 );
56 segmentStride = floor( strideDuration/series->deltaT + 0.5 );
57
58 verbose( "computing overwhitened data segment %u\n", segmentNumber );
59
60 /* name of this segment */
61
62 /* allocate memory for the data */
63 segment->data = XLALCreateCOMPLEX8Vector( segmentLength/2 + 1 );
64
65 /* create a time series that contains only the relevant data */
66 seg = *series;
67 vec.length = segmentLength;
68 vec.data = seg.data->data + segmentNumber * segmentStride;
69 seg.data = &vec;
70 ns = epoch_to_ns( &seg.epoch );
71 ns += sec_to_ns( segmentNumber * strideDuration );
72 ns_to_epoch( &seg.epoch, ns );
73
74 /* fft the data */
75 XLALREAL4TimeFreqFFT( segment, &seg, fwdPlan );
76
77 /* multiply by the response function */
78 if ( response )
79 {
80 XLALCCVectorMultiply( segment->data, segment->data, response->data );
81 XLALUnitMultiply( &segment->sampleUnits, &segment->sampleUnits,
82 &response->sampleUnits );
83 }
84
85 /* multiply by the inverse spectrum */
86 XLALSCVectorMultiply( segment->data, invspec->data, segment->data );
87 XLALUnitMultiply( &segment->sampleUnits, &segment->sampleUnits,
88 &invspec->sampleUnits );
89
90 return 0;
91}
int verbose
Definition: chirplen.c:77
INT8 sec_to_ns(REAL8 sec)
Definition: gpstime.c:57
LIGOTimeGPS * ns_to_epoch(LIGOTimeGPS *epoch, INT8 ns)
Definition: gpstime.c:48
INT8 epoch_to_ns(LIGOTimeGPS *epoch)
Definition: gpstime.c:38
double REAL8
int64_t INT8
uint32_t UINT4
int XLALREAL4TimeFreqFFT(COMPLEX8FrequencySeries *freq, const REAL4TimeSeries *tser, const REAL4FFTPlan *plan)
LALUnit * XLALUnitMultiply(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
COMPLEX8Vector * XLALSCVectorMultiply(COMPLEX8Vector *out, const REAL4Vector *in1, const COMPLEX8Vector *in2)
COMPLEX8Vector * XLALCCVectorMultiply(COMPLEX8Vector *out, const COMPLEX8Vector *in1, const COMPLEX8Vector *in2)
ns
int compute_data_segment(COMPLEX8FrequencySeries *segment, UINT4 segmentNumber, REAL4TimeSeries *series, REAL4FrequencySeries *invspec, COMPLEX8FrequencySeries *response, REAL8 segmentDuration, REAL8 strideDuration, REAL4FFTPlan *fwdPlan)
Definition: segment.c:38
COMPLEX8Sequence * data
REAL4Sequence * data
REAL4Sequence * data
LIGOTimeGPS epoch
REAL4 * data
Definition: series.h:36