94 #include <lal/LALgetopt.h>
95 #include <lal/LALStdlib.h>
96 #include <lal/LALString.h>
97 #include <lal/TimeSeries.h>
98 #include <lal/LALFrStream.h>
99 #include <lal/Units.h>
112 int usage(
const char *program);
135 int main(
int argc,
char *argv[])
205 fprintf(stderr,
"unsupported channel type\n");
224 char args[] =
"hc:f:g:s:t:";
226 int option_index = 0;
235 if (long_options[option_index].
flag)
238 fprintf(stderr,
"error parsing option %s with argument %s\n",
262 fprintf(stderr,
"unknown error while parsing options\n");
268 fprintf(stderr,
"extraneous command line arguments:\n");
277 fprintf(stderr,
"must specify a channel\n");
282 fprintf(stderr,
"must specify a frame cache or frame files\n");
294 fprintf(stderr,
"\t-h, --help \tprint this message and exit\n");
295 fprintf(stderr,
"\t-c, CHAN --channel=CHAN \tchannel name CHAN\n");
296 fprintf(stderr,
"\t-f CACHE, --frame-cache=CACHE\tframe cache file CACHE\n");
297 fprintf(stderr,
"\t-g GLOB, --frame-glob=GLOB \tframe file glob string GLOB\n");
298 fprintf(stderr,
"\t-s T0, --start-time=T0 \tGPS start time T0 (s)\n");
299 fprintf(stderr,
"\t-t DT, --duration=DT \tduration DT (s)\n");
303 #define DEFINE_OUTPUT_FUNCTION(laltype, format, ...) \
304 void output_ ## laltype (LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end) \
307 laltype ## TimeSeries *series; \
309 series = XLALCreate ## laltype ## TimeSeries(channame, start, 0.0, 0.0, &lalDimensionlessUnit, 0); \
310 XLALFrStreamGet ## laltype ## TimeSeriesMetadata(series, stream); \
311 while ((remaining = XLALGPSDiff(end, start)) > series->deltaT) { \
314 remaining = (remaining > MAXDUR ? MAXDUR : remaining); \
315 length = (size_t)floor(remaining / series->deltaT); \
316 length = (length > MAXLEN ? MAXLEN : length); \
317 if (series->data->length != length) \
318 XLALResize ## laltype ## TimeSeries(series, 0, length); \
319 XLALFrStreamGet ## laltype ## TimeSeries(series, stream); \
320 for (i = 0; i < series->data->length; ++i) { \
322 laltype value = series->data->data[i]; \
323 LIGOTimeGPS t = series->epoch; \
324 XLALGPSAdd(&t, i * series->deltaT); \
325 fprintf(stdout, "%s", XLALGPSToStr(tstr, &t)); \
327 fprintf(stdout, format, __VA_ARGS__); \
330 XLALGPSAdd(start, series->data->length * series->deltaT); \
332 XLALDestroy ## laltype ## TimeSeries(series); \
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
#define required_argument
LALCache * XLALCacheImport(const char *fname)
LALCache * XLALCacheGlob(const char *dirstr, const char *fnptrn)
int XLALFrStreamSeek(LALFrStream *stream, const LIGOTimeGPS *epoch)
Seeks a LALFrStream stream to data at a given time.
int XLALFrStreamSeekO(LALFrStream *stream, double dt, int whence)
Seeks a LALFrStream stream by a time offset.
int XLALFrStreamTell(LIGOTimeGPS *epoch, LALFrStream *stream)
Tells the current time of the current position of a LALFrStream stream.
int XLALFrStreamClose(LALFrStream *stream)
Closes a LALFrStream.
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
Opens a LALFrStream associated with a LALCache.
int XLALFrStreamGetMode(LALFrStream *stream)
Returns the current operating mode of a LALFrStream.
int XLALFrStreamSetMode(LALFrStream *stream, int mode)
Change the operating mode of a LALFrStream.
@ LAL_FR_STREAM_TIMEWARN_MODE
display warning for invalid time requests
@ LAL_FR_STREAM_IGNORETIME_MODE
ignore invalid times requested
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...
char char * XLALStringDuplicate(const char *s)
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
void output_INT2(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
int main(int argc, char *argv[])
int usage(const char *program)
#define DEFINE_OUTPUT_FUNCTION(laltype, format,...)
int parseargs(int argc, char **argv)
void output_UINT2(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_UINT8(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_REAL8(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_COMPLEX16(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_COMPLEX8(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_REAL4(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_UINT4(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_INT4(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
void output_INT8(LALFrStream *stream, const char *channame, LIGOTimeGPS *start, LIGOTimeGPS *end)
This structure details the state of the frame stream.