00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <math.h>
00045 #include <stdio.h>
00046 #include <unistd.h>
00047 #include <lal/LALStdlib.h>
00048 #include <lal/AVFactories.h>
00049 #include <lal/PrintFTSeries.h>
00050 #include <lal/FrameStream.h>
00051
00052 #include <lal/LALRCSID.h>
00053 NRCSID (READGEODATAC,"$Id: ReadGEOData.c,v 1.6 2007/06/08 14:41:46 bema Exp $");
00054
00055 #ifndef CHANNEL
00056 #define CHANNEL "LSC_MID_EP-P"
00057 #endif
00058
00059 #define TESTSTATUS( pstat ) \
00060 if ( (pstat)->statusCode ) { REPORTSTATUS(pstat); return 1; } else ((void)0)
00061
00062 INT4 lalDebugLevel = LALMSGLVL3;
00063
00064 int main( void )
00065 {
00066 static LALStatus status;
00067 const float duration = 60.0;
00068 REAL4TimeSeries tser;
00069 INT2TimeSeries chan;
00070 FrChanIn chanin = { CHANNEL, ADCDataChannel };
00071 FrStream *stream = NULL;
00072 FrOutPar outpar = { "G:" CHANNEL, "TEST", ADCDataChannel, 6, 0, 0 };
00073 char *dirname = getenv( "LAL_FRAME_PATH" );
00074
00075
00076 LALFrOpen( &status, &stream, dirname, "GEO_*.fr" );
00077 TESTSTATUS( &status );
00078
00079
00080 chan.data = NULL;
00081 LALFrGetINT2TimeSeries( &status, &chan, &chanin, stream );
00082 TESTSTATUS( &status );
00083
00084
00085 LALI2CreateVector( &status, &chan.data, duration / chan.deltaT );
00086 TESTSTATUS( &status );
00087
00088
00089 memcpy( &tser, &chan, sizeof( tser ) );
00090 tser.data = NULL;
00091 LALSCreateVector( &status, &tser.data, duration / tser.deltaT );
00092 TESTSTATUS( &status );
00093
00094
00095 while ( 1 )
00096 {
00097 INT8 tacc = 0.1 * 1e9 / 16384;
00098 INT8 texp;
00099 INT8 tact;
00100 UINT4 i;
00101
00102 texp = (INT8)1000000000 * (INT8)chan.epoch.gpsSeconds;
00103 texp += (INT8)chan.epoch.gpsNanoSeconds;
00104 texp += (INT8)( 1e9 * chan.data->length * chan.deltaT );
00105
00106 LALFrGetINT2TimeSeries( &status, &chan, &chanin, stream );
00107 if ( status.statusCode == FRAMESTREAMH_EDONE )
00108 {
00109 break;
00110 }
00111 TESTSTATUS( &status );
00112
00113 tact = (INT8)1000000000 * (INT8)chan.epoch.gpsSeconds;
00114 tact += (INT8)chan.epoch.gpsNanoSeconds;
00115
00116 if ( abs( texp - tact ) > tacc )
00117 puts( "Gap in frame data!" );
00118
00119 tser.epoch = chan.epoch;
00120 printf( "%s-%s-%d-%d.gwf\n", outpar.source, outpar.description,
00121 tser.epoch.gpsSeconds,
00122 (int)ceil( 1e-9 * tser.epoch.gpsNanoSeconds
00123 + tser.data->length * tser.deltaT ) );
00124 for ( i = 0; i < tser.data->length; ++i )
00125 {
00126 tser.data->data[i] = chan.data->data[i];
00127 }
00128 LALFrWriteREAL4TimeSeries( &status, &tser, &outpar );
00129 TESTSTATUS( &status );
00130 }
00131
00132 LALFrClose( &status, &stream );
00133 TESTSTATUS( &status );
00134
00135 LALI2DestroyVector( &status, &chan.data );
00136 TESTSTATUS( &status );
00137
00138 LALSDestroyVector( &status, &tser.data );
00139 TESTSTATUS( &status );
00140
00141 LALCheckMemoryLeaks();
00142 return 0;
00143 }