LALFrame 3.0.7.1-eeff03c
MakeFrames.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, 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/**
21 * \author Jolien D. E. Creighton
22 * \file
23 *
24 * ### Program MakeFrames.c ###
25 *
26 * Make some frames with random Gaussian noise.
27 *
28 * ### Usage ###
29 *
30 * \code
31 * MakeFrames
32 * \endcode
33 *
34 * ### Description ###
35 *
36 * This program makes some frames with one ADC channel containing random
37 * Gaussian noise.
38 *
39 */
40
41#include <stdio.h>
42#include <lal/LALStdlib.h>
43#include <lal/AVFactories.h>
44#include <lal/Random.h>
45#include <lal/Units.h>
46#include <lal/LALFrStream.h>
47
48#define TESTSTATUS( pstat ) \
49 if ( (pstat)->statusCode ) { REPORTSTATUS(pstat); return 1; } else ((void)0)
50
51#ifndef CHANNEL
52#define CHANNEL "H1:LSC-AS_Q"
53#endif
54
55
56int main( void )
57{
58 static LALStatus status;
59 static INT4TimeSeries series;
60 const UINT4 duration = 60; /* duration of frame file */
61 const INT4 seed = 10; /* random number seed */
62 const REAL4 rate = 16384; /* sample rate (Hz) */
63 const UINT4 npts = duration * rate; /* number of points */
64 FrOutPar opar = { "F", "TEST", ADCDataChannel, 6, 0, 0 };
65 RandomParams *rpar = NULL;
66 UINT4 count = 0;
67 UINT4 i;
68
69 /* initialize */
70
71 LALCreateRandomParams( &status, &rpar, seed );
73
74 strncpy( series.name, CHANNEL, sizeof( series.name ) );
75 series.epoch.gpsSeconds = 600000000;
77 series.deltaT = 1 / rate;
78 LALI4CreateVector( &status, &series.data, npts );
80
81 /* generate first frame file worth of data and write it */
82
83 /*
84 LALNormalDeviates( &status, series.data, rpar );
85 TESTSTATUS( &status );
86 */
87 for ( i = 0; i < series.data->length; ++i )
88 {
89 series.data->data[i] = count++;
90 }
91
92 LALFrWriteINT4TimeSeries( &status, &series, &opar );
94
95 /* generate second frame file worth of data and write it */
96
97 series.epoch.gpsSeconds += duration;
98 /*
99 LALNormalDeviates( &status, series.data, rpar );
100 TESTSTATUS( &status );
101 */
102 for ( i = 0; i < series.data->length; ++i )
103 {
104 series.data->data[i] = count++;
105 }
106
107 LALFrWriteINT4TimeSeries( &status, &series, &opar );
108 TESTSTATUS( &status );
109
110 /* generate third frame file worth of data and write it */
111
112 series.epoch.gpsSeconds += duration;
113 /*
114 LALNormalDeviates( &status, series.data, rpar );
115 TESTSTATUS( &status );
116 */
117 for ( i = 0; i < series.data->length; ++i )
118 {
119 series.data->data[i] = count++;
120 }
121
122 LALFrWriteINT4TimeSeries( &status, &series, &opar );
123 TESTSTATUS( &status );
124
125 //if ( XLALFrWriteINT4TimeSeries( &series, 7 ) < 0 )
126 //return 1;
127
128 /* cleanup */
129
130 LALI4DestroyVector( &status, &series.data );
131 TESTSTATUS( &status );
132
134 TESTSTATUS( &status );
135
137 return 0;
138}
void LALFrWriteINT4TimeSeries(LALStatus *status, INT4TimeSeries *series, FrOutPar *params)
#define ADCDataChannel
Definition: LALFrStream.h:293
void LALCheckMemoryLeaks(void)
#define TESTSTATUS(pstat)
Definition: MakeFrames.c:48
int main(void)
Definition: MakeFrames.c:56
#define CHANNEL
Definition: MakeFrames.c:52
uint32_t UINT4
int32_t INT4
float REAL4
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
const LALUnit lalADCCountUnit
void LALI4CreateVector(LALStatus *, INT4Vector **, UINT4)
void LALI4DestroyVector(LALStatus *, INT4Vector **)
string status
LALUnit sampleUnits
INT4Sequence * data
LIGOTimeGPS epoch
CHAR name[LALNameLength]
INT4 * data
UINT4 length