LALFrame 3.0.7.1-eeff03c
LALFrSeriesTest.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 FrameStreamTest.c ###
25 *
26 * Tests the low-level frame stream routines.
27 *
28 * ### Usage ###
29 *
30 * \code
31 * FrameStreamTest
32 * \endcode
33 *
34 * ### Description ###
35 *
36 * This program reads the channels <tt>H1:LSC-AS_Q</tt> from all the fake frames
37 * <tt>F-TEST-*.gwf</tt> in the directory TEST_DATA_DIR, and prints them to files.
38 *
39 */
40
41#include <stdio.h>
42#include <lal/LALStdlib.h>
43#include <lal/AVFactories.h>
44#include <lal/PrintFTSeries.h>
45#include <lal/LALFrStream.h>
46#include <lal/TimeSeries.h>
47#include <lal/Units.h>
48
49#ifndef CHANNEL
50#define CHANNEL "H1:LSC-AS_Q"
51#endif
52
53
54int main( void )
55{
56 const UINT4 npts = 200001; /* read data in weirdly sized blocks */
57 LALFrStream *stream;
58 LALFrStreamPos frpos;
59 INT4TimeSeries *chan;
61 INT4 file;
62
64
65 stream = XLALFrStreamOpen( TEST_DATA_DIR, "F-TEST-*.gwf" );
66 if ( !stream )
67 return 1;
68
70 return 1;
71
72 /* seek to some initial time */
73 epoch.gpsSeconds = 600000071;
74 epoch.gpsNanoSeconds = 123456789;
75 if ( XLALFrStreamSeek( stream, &epoch ) )
76 return 1;
77
78 /* save this position */
79 if ( XLALFrStreamGetpos( &frpos, stream ) )
80 return 1;
81
82 /* only channel name and npts are used. other metadata will be filled in
83 * later */
84 chan = XLALCreateINT4TimeSeries( CHANNEL, &epoch, 0.0, 0.0, &lalDimensionlessUnit, npts );
85 if ( !chan )
86 return 1;
87
88 for ( file = 0; file < 8; file++ )
89 {
90 CHAR fname[256];
92 if ( typecode != LAL_I4_TYPE_CODE )
93 {
94 if ( (int)typecode < 0 )
95 fprintf( stderr, "failure\n" );
96 else
97 fprintf( stderr, "Wrong data type!\n" );
98 return 1;
99 }
100 if ( XLALFrStreamGetINT4TimeSeries( chan, stream ) )
101 return 1;
102 sprintf( fname, CHANNEL ".%03d", file );
103 LALI4PrintTimeSeries( chan, fname );
104 }
105
106 /* go back to saved time */
107 if ( XLALFrStreamSetpos( stream, &frpos ) )
108 return 1;
109
110 if ( XLALFrStreamGetINT4TimeSeries( chan, stream ) )
111 return 1;
112
113 LALI4PrintTimeSeries( chan, CHANNEL ".999" );
114
115 XLALFrStreamClose( stream );
116
118
119 return 0;
120}
int main(void)
#define CHANNEL
#define fprintf
LALTYPECODE
char CHAR
uint32_t UINT4
int32_t INT4
LAL_I4_TYPE_CODE
int XLALFrStreamSeek(LALFrStream *stream, const LIGOTimeGPS *epoch)
Seeks a LALFrStream stream to data at a given time.
Definition: LALFrStream.c:542
int XLALFrStreamClose(LALFrStream *stream)
Closes a LALFrStream.
Definition: LALFrStream.c:170
int XLALFrStreamGetpos(LALFrStreamPos *position, LALFrStream *stream)
Gets the current position of a LALFrStream stream.
Definition: LALFrStream.c:736
LALFrStream * XLALFrStreamOpen(const char *dirname, const char *pattern)
Opens a LALFrStream for specified frame files.
Definition: LALFrStream.c:253
int XLALFrStreamSetMode(LALFrStream *stream, int mode)
Change the operating mode of a LALFrStream.
Definition: LALFrStream.c:327
int XLALFrStreamSetpos(LALFrStream *stream, const LALFrStreamPos *position)
Sets the current position of a LALFrStream stream.
Definition: LALFrStream.c:756
@ LAL_FR_STREAM_CHECKSUM_MODE
ensure that file checksums are OK
Definition: LALFrStream.h:88
@ LAL_FR_STREAM_VERBOSE_MODE
display warnings and info
Definition: LALFrStream.h:84
LALTYPECODE XLALFrStreamGetTimeSeriesType(const char *chname, LALFrStream *stream)
Returns the type code for the data type of channel chname in the current frame in frame stream stream...
int XLALFrStreamGetINT4TimeSeries(INT4TimeSeries *series, LALFrStream *stream)
void LALI4PrintTimeSeries(INT4TimeSeries *series, const CHAR *filename)
void XLALDestroyINT4TimeSeries(INT4TimeSeries *series)
INT4TimeSeries * XLALCreateINT4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalDimensionlessUnit
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
This structure details the state of the frame stream.
Definition: LALFrStream.h:95
This structure contains a record of the state of a frame stream; this record can be used to restore t...
Definition: LALFrStream.h:110
enum @1 epoch