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 #include <stdio.h>
00026 #include <unistd.h>
00027 #include <FrameL.h>
00028 #include <math.h>
00029 #include <lal/LALStdlib.h>
00030 #include <lal/AVFactories.h>
00031 #include <lal/PrintFTSeries.h>
00032 #include <lal/FrameStream.h>
00033 #include <lal/LALMoment.h>
00034 #include <lal/Units.h>
00035 #include <lal/BandPassTimeSeries.h>
00036
00037 #define TRUE 1
00038 #define FALSE 0
00039
00040 #define FRAMEHEARSEEC_ENORM 0
00041 #define FRAMEHEARSEEC_EARG 2
00042
00043 #define FRAMEHEARSEEC_MSGENORM "Normal exit"
00044 #define FRAMEHEARSEEC_MSGEARG "Error parsing arguments"
00045
00046
00047 #define USAGE "Usage: %s [options] | xmgr -pipe\n"\
00048 " --help Print this help message\n" \
00049 " --channel name Name of frame channel\n" \
00050 " [--duration secs] How many seconds to look at\n"\
00051 " [--epoch sec nsec] The starting epoch\n"\
00052 " [--framedir dirname] Directory containing frame files\n"\
00053 " [--highpass freq attenuation] High-pass filter parameters \n"\
00054 " [--numpts npoints] Points per graph displayed\n"
00055
00056 INT4 lalDebugLevel = LALMSGLVL3;
00057
00058 #include <config.h>
00059 #ifndef HAVE_LIBLALFRAME
00060 int main( void )
00061 {
00062 fputs( "Disabled: LALApps compiled with non-frame-enabled LAL\n", stderr );
00063 return 77;
00064 }
00065 #else
00066
00067
00068 void graphout(float x1,float x2,int thistime, int last) {
00069 static int count=0;
00070 printf("&\n");
00071
00072 if (count==0) {
00073 printf("@doublebuffer true\n");
00074 printf("@s0 color 3\n");
00075 printf("@view 0.1, 0.1, 0.9, 0.45\n");
00076 printf("@with g1\n");
00077 printf("@view 0.1, 0.6, 0.9, 0.95\n");
00078 printf("@with g0\n");
00079 printf("@world xmin %f\n",x1);
00080 printf("@world xmax %f\n",x2);
00081 printf("@autoscale\n");
00082 printf("@focus off\n");
00083 printf("@xaxis label \"t (sec)\"\n");
00084 printf("@fft(s0, 1)\n");
00085 printf("@s1 color 2\n");
00086 printf("@move g0.s1 to g1.s0\n");
00087 printf("@with g1\n");
00088 printf("@g1 type logy\n");
00089 printf("@autoscale\n");
00090 printf("@subtitle \"Spectrum\"\n");
00091 printf("@xaxis label \"f (Hz)\"\n");
00092 printf("@with g0\n");
00093 printf("@subtitle \"IFO output %d\"\n",thistime);
00094 count++;
00095 if (!last) printf("@kill s0\n");
00096 }
00097 else {
00098
00099 printf("@s0 color 3\n");
00100 printf("@fft(s0, 1)\n");
00101 printf("@s1 color 2\n");
00102 printf("@move g0.s1 to g1.s0\n");
00103 printf("@subtitle \"IFO output %d\"\n",thistime);
00104 count++;
00105 printf("@world xmin %f\n",x1);
00106 printf("@world xmax %f\n",x2);
00107 printf("@autoscale yaxes\n");
00108 printf("@clear stack\n");
00109 if (!last) printf("@kill s0\n");
00110 printf("@with g1\n");
00111 printf("@g1 type logy\n");
00112 printf("@clear stack\n");
00113 if (!last) printf("@kill s0\n");
00114 printf("@with g0\n");
00115 }
00116 return;
00117 }
00118
00119
00120
00121 int main( int argc, char *argv[] )
00122 {
00123 static LALStatus status;
00124 FrStream *stream = NULL;
00125 FrChanIn channelIn;
00126 REAL4 time, numSeconds;
00127 INT4 i, numPoints=4096, inarg = 1;
00128 CHAR *dirname;
00129 REAL4TimeSeries series;
00130 LIGOTimeGPS epoch;
00131 BOOLEAN epochSet = FALSE;
00132 BOOLEAN highpass = FALSE;
00133 PassBandParamStruc highpassParam;
00134
00135
00136 if ( FRAMELIB_VERSION < 4 )
00137 return 77;
00138
00139
00140 dirname = getenv( "LAL_FRAME_PATH" );
00141
00142
00143 highpassParam.nMax = 4;
00144 highpassParam.f1 = -1.0;
00145 highpassParam.a1 = -1.0;
00146
00147
00148
00149
00150
00151 if (argc <= 1){
00152 LALPrintError( USAGE, *argv );
00153 return 0;
00154 }
00155
00156 while ( inarg < argc ) {
00157
00158 if ( !strcmp( argv[inarg], "--help" ) ) {
00159 if ( argc > inarg + 1 ) {
00160 inarg++;
00161 fprintf(stderr,"Should be a usage message\n");
00162 exit(0);
00163 }else{
00164 LALPrintError( USAGE , *argv );
00165 return FRAMEHEARSEEC_EARG;
00166 }
00167 }
00168 else if ( !strcmp( argv[inarg], "--epoch" ) ) {
00169 if ( argc > inarg + 1 ) {
00170 inarg++;
00171 epoch.gpsSeconds = atoi( argv[inarg++] );
00172 epoch.gpsNanoSeconds = atoi( argv[inarg++] );
00173 epochSet = TRUE;
00174 }else{
00175 LALPrintError( USAGE, *argv );
00176 return FRAMEHEARSEEC_EARG;
00177 }
00178 }
00179 else if ( !strcmp( argv[inarg], "--numpts" ) ) {
00180 if ( argc > inarg + 1 ) {
00181 inarg++;
00182 numPoints = atoi( argv[inarg++] );
00183 }else{
00184 LALPrintError( USAGE, *argv );
00185 return FRAMEHEARSEEC_EARG;
00186 }
00187 }
00188 else if ( !strcmp( argv[inarg], "--highpass" ) ) {
00189 if ( argc > inarg + 1 ) {
00190 inarg++;
00191 highpass = TRUE;
00192 highpassParam.f2 = atof( argv[inarg++] );
00193 highpassParam.a2 = atof( argv[inarg++] );
00194 }else{
00195 LALPrintError( USAGE, *argv );
00196 return FRAMEHEARSEEC_EARG;
00197 }
00198 }
00199 else if ( !strcmp( argv[inarg], "--duration" ) ) {
00200 if ( argc > inarg + 1 ) {
00201 inarg++;
00202 numSeconds = atof( argv[inarg++] );
00203 }else{
00204 LALPrintError( USAGE, *argv );
00205 return FRAMEHEARSEEC_EARG;
00206 }
00207 }
00208 else if ( !strcmp( argv[inarg], "--channel" ) ) {
00209 if ( argc > inarg + 1 ) {
00210 inarg++;
00211 channelIn.name = argv[inarg++];
00212 channelIn.type = ADCDataChannel;
00213 }else{
00214 LALPrintError( USAGE, *argv );
00215 return FRAMEHEARSEEC_EARG;
00216 }
00217 }
00218 else if ( !strcmp( argv[inarg], "--framedir" ) ) {
00219 if ( argc > inarg + 1 ) {
00220 inarg++;
00221 dirname = argv[inarg++];
00222 }else{
00223 LALPrintError( USAGE, *argv );
00224 return FRAMEHEARSEEC_EARG;
00225 }
00226 }
00227
00228 else if ( argv[inarg][0] == '-' ) {
00229 LALPrintError( USAGE, *argv );
00230 return FRAMEHEARSEEC_EARG;
00231 }
00232 }
00233
00234
00235 LALFrOpen( &status, &stream, dirname, "*.gwf" );
00236
00237
00238 series.data = NULL;
00239 LALFrGetREAL4TimeSeries( &status, &series, &channelIn, stream);
00240 if (epochSet ){
00241 series.epoch.gpsSeconds = epoch.gpsSeconds;
00242 series.epoch.gpsNanoSeconds = epoch.gpsNanoSeconds;
00243 }
00244 LALFrSeek(&status, &(series.epoch), stream);
00245
00246
00247 LALCreateVector( &status, &series.data, numPoints);
00248
00249
00250 LALFrGetREAL4TimeSeries( &status, &series, &channelIn, stream);
00251
00252 while ( !(status.statusCode) &&
00253 (series.epoch.gpsSeconds < epoch.gpsSeconds + (INT4)(numSeconds))){
00254
00255
00256 if (highpass){
00257 LALButterworthREAL4TimeSeries(&status, &series, &highpassParam);
00258 }
00259
00260
00261 for (i=0 ; i<32 ; i++ ){
00262 time= i * series.deltaT;
00263 printf("%e\t%e\n", time,0.0);
00264 }
00265 for (i=32 ; i<numPoints ; i++) {
00266 time= i * series.deltaT;
00267 printf("%e\t%e\n", time, series.data->data[i]);
00268 }
00269
00270
00271 graphout(0, 0+numPoints * series.deltaT, series.epoch.gpsSeconds,
00272 (status.statusCode == FRAMESTREAMH_EDONE ||
00273 (series.epoch.gpsSeconds + (INT4)(numPoints*series.deltaT)
00274 >= epoch.gpsSeconds + (INT4)(numSeconds)) ));
00275
00276
00277 LALFrGetREAL4TimeSeries( &status, &series, &channelIn, stream);
00278 }
00279
00280
00281 LALFrClose( &status, &stream );
00282
00283
00284
00285
00286
00287
00288
00289
00290 LALSDestroyVector( &status, &(series.data) );
00291 LALCheckMemoryLeaks();
00292 return 0;
00293 }
00294
00295 #endif