28#include <lal/LALFrameIO.h>
29#include <lal/LALgetopt.h>
30#include <lal/LALCache.h>
31#include <lal/LALFrStream.h>
32#include <lal/BandPassTimeSeries.h>
34#include <lal/TimeSeries.h>
35#include <lal/FrequencySeries.h>
36#include <lal/ResampleTimeSeries.h>
38#include <lal/Window.h>
39#include <lal/RealFFT.h>
40#include <lal/TimeFreqFFT.h>
42#include <lal/LIGOMetadataTables.h>
43#include <lal/LIGOMetadataUtils.h>
44#include <lal/SnglBurstUtils.h>
45#include <lal/LIGOLwXML.h>
46#include <lal/LIGOLwXMLRead.h>
47#include <lal/FindChirp.h>
48#include <lal/GenerateBurst.h>
79int verbose(
const char *fmt, ... );
80int usage(
const char *program );
98int main(
int argc,
char *argv[] )
145 ndiscard = 0.5 * discard /
series->deltaT;
188 char args[] =
"01P:t:T:d:m:M:c:C:f:F:o:O:s:I:B:";
191 int option_index = 0;
198 if ( long_options[option_index].
flag )
200 fprintf( stderr,
"error parsing option %s with argument %s\n", long_options[option_index].
name,
LALoptarg );
258 fprintf( stderr,
"error: unrecognized output type\n" );
273 fprintf( stderr,
"unknown error while parsing options\n" );
279 fprintf( stderr,
"extraneous command line arguments:\n" );
295 verbose(
"generating %g seconds of %s data starting at time %d.%09d\n",
315 verbose(
"reading %g seconds of %s data starting at time %d.%09d\n",
319 if ( cachefileflg ) {
323 char pathcpy[FILENAME_MAX];
325 char *dirname = NULL;
326 strncpy( pathcpy,
path,
sizeof(pathcpy) - 1 );
389 fprintf( stderr,
"warning: cannot perform injections without calibration\n" );
396 fprintf( stderr,
"error: could not read file %s\n", inspinjfile );
399 verbose(
"injecting inspirals listed in file %s\n", inspinjfile );
408 fprintf( stderr,
"error: signal injection failed\n" );
432 if ( ! burstinjfile )
435 fprintf( stderr,
"warning: cannot perform injections without calibration\n" );
441 if ( !sim_burst || !time_slide ) {
442 fprintf( stderr,
"error: could not read file %s\n", burstinjfile );
446 verbose(
"injecting bursts listed in file %s\n", burstinjfile );
481 const INT4 filtorder = 8;
482 const REAL8 amplitude = 0.9;
500 REAL4FFTPlan *pfwd, *prev;
507 verbose(
"calibrating data\n" );
520 if (
f_min < 30.0 ) {
521 fprintf( stderr,
"warning: setting minimum frequency to 30 Hz for calibration\n" );
551 verbose(
"computing power spectrum\n" );
559 verbose(
"setting spectrum to be unity\n" );
576 spectrum->
data->
data[
k] *= re*re + im*im;
590 verbose(
"output psd of %s data beginning at GPS time %d.%09d to file %s\n",
609 verbose(
"output %s data beginning at GPS time %d.%09d to file %s\n",
629 fprintf( stderr,
"error: invalid output type\n" );
646 fprintf( stderr,
"OPTIONS\n" );
649 fprintf( stderr,
"\t-c CHANNEL\n\t--channel-name=CHANNEL\n" );
650 fprintf( stderr,
"\t\tread channel CHANNEL\n" );
653 fprintf( stderr,
"\t-C CALFILE\n\t--calibration-file=CALFILE\n" );
654 fprintf( stderr,
"\t\tuse calibration file CALFILE\n" );
655 fprintf( stderr,
"\t\tthis means that data will be calibrated\n" );
656 fprintf( stderr,
"\t\tunless the --no-calibration option is used\n" );
659 fprintf( stderr,
"\t-d DURATION\n\t--duration=DURATION\n" );
660 fprintf( stderr,
"\t\tread DURATION seconds of data\n" );
663 fprintf( stderr,
"\t-f FILES\n\t--frame-files=FILES\n" );
664 fprintf( stderr,
"\t\tread data from frame files FILES\n" );
667 fprintf( stderr,
"\t-F CACHE\n\t--cache-file=CACHE\n" );
668 fprintf( stderr,
"\t\tread data from files in frame cache file CACHE\n" );
671 fprintf( stderr,
"\t-h\n\t--help\n\t\tprint this message\n\n" );
674 fprintf( stderr,
"\t-m MINFREQ\n\t--min-frequency=MINFREQ\n" );
675 fprintf( stderr,
"\t\thighpass data at MINFREQ hertz\n" );
678 fprintf( stderr,
"\t-M MAXFREQ\n\t--max-frequency=MAXNFREQ\n" );
679 fprintf( stderr,
"\t\tlowpass data at MAXFREQ hertz\n" );
682 fprintf( stderr,
"\t-o OUTFILE\n\t--output-file=OUTFILE\n" );
683 fprintf( stderr,
"\t\toutput to file OUTFILE\n" );
686 fprintf( stderr,
"\t-O OTYPE\n\t--output-type=OTYPE\n" );
687 fprintf( stderr,
"\t\toutput data type OTYPE [ \"ASCII\" | \"AU\" | \"WAVE\" ]\n" );
690 fprintf( stderr,
"\t-P NUMAVG\n\t--power-spectrum=NUMAVE\n" );
691 fprintf( stderr,
"\t\tcompute power spectrum with NUMAVE averages\n" );
694 fprintf( stderr,
"\t-s SRATE\n\t--sample-rate=SRATE\n" );
695 fprintf( stderr,
"\t\tresample to sample rate SRATE hertz\n" );
698 fprintf( stderr,
"\t-t GPSTIME\n\t--gps-start-time=GPSTIME\n" );
699 fprintf( stderr,
"\t\tstart reading data at time GPSTIME\n" );
700 fprintf( stderr,
"\t\tnote: output results for data a little later\n" );
703 fprintf( stderr,
"\t-T GPSTIME\n\t--exact-gps-start-time=GPSTIME\n" );
704 fprintf( stderr,
"\t\tdata output for EXACTLY time GPSTIME\n" );
705 fprintf( stderr,
"\t\tnote: data must exist before this time\n" );
708 fprintf( stderr,
"\t--no-calibration\n" );
709 fprintf( stderr,
"\t\tdo not apply response function to data\n" );
710 fprintf( stderr,
"\t\t(it may still be required for injections)\n" );
713 fprintf( stderr,
"\t--verbose\n" );
714 fprintf( stderr,
"\t\tprint messages describing actions that are taken\n" );
717 fprintf( stderr,
"\t--debug\n" );
718 fprintf( stderr,
"\t\tdump intermediate products to data files\n" );
721 fprintf( stderr,
"EXAMPLES\n" );
724 fprintf( stderr,
"\tRead some data, condition it, and write it as an audio file\n" );
725 fprintf( stderr,
"\n\t\t%s --verbose --channel L1:LSC-DARM_ERR --frame-files=L-RDS_R_L3-795259680-256.gwf --min-frequency=80 --max-frequency=500 --sample-rate=1024 --output-file=data.au --output-type=au --gps-start-time=795259680\n",
program );
728 fprintf( stderr,
"\tImpulse response of the response function\n" );
729 fprintf( stderr,
"\n\t\t%s --verbose --channel L1:LSC-DARM_ERR --calibration-file=L-L1_CAL_S4_V4-793128493-2801040.gwf --min-frequency=30 --max-frequency=500 --unit-impulse --output-file=resp.dat --gps-start-time=795259680",
program );
732 fprintf( stderr,
"\tPower spectrum of the response function\n" );
733 fprintf( stderr,
"\n\t\t%s --verbose --channel L1:LSC-DARM_ERR --calibration-file=L-L1_CAL_S4_V4-793128493-2801040.gwf --unit-impulse --output-file=rpsd.dat --gps-start-time=795259680 --power-spectrum=1",
program );
736 fprintf( stderr,
"\tMake a strain sensitivity curve with 32 averages\n" );
737 fprintf( stderr,
"\n\t\t%s --channel=L1:LSC-DARM_ERR --calibration-file=L-L1_CAL_S4_V4-793128493-2801040.gwf --duration=16 --frame-file=\"L-RDS_R_L3-*.gwf\" --output-file=spec.dat --gps-start-time=795259680 --power-spectrum=32\n",
program );
738 fprintf( stderr,
"\n\t(note quotes around wildcard in --frame-file option)\n" );
740 fprintf( stderr,
"\tMake an audio file of a chirp injected into strain data\n"
741 "\tresampled to 1024 Hz and high-pass filtered at 70 Hz\n" );
742 fprintf( stderr,
"\n\t\t%s -c L1:LSC-DARM_ERR -C L-L1_CAL_S4_V4-793128493-2801040.gwf -d 16 -f L-RDS_R_L3-795259680-256.gwf -m 70 -o chirph.au -s 1024 -t 795259680 -I inj.xml -O au\n",
program );
744 fprintf( stderr,
"\tAs above but in terms of ADC counts rather than strain\n" );
745 fprintf( stderr,
"\n\t\t%s -c L1:LSC-DARM_ERR -C L-L1_CAL_S4_V4-793128493-2801040.gwf -d 16 -f L-RDS_R_L3-795259680-256.gwf -m 70 -o chirpv.au -s 1024 -t 795259680 -I inj.xml -O au --no-cal\n",
program );
747 fprintf( stderr,
"\tAs above but just with the injection (no data!)\n" );
748 fprintf( stderr,
"\n\t\t%s -c L1:LSC-DARM_ERR -C L-L1_CAL_S4_V4-793128493-2801040.gwf -d 16 -m 70 -o chirph.au -s 1024 -t 795259680 -I inj.xml -O au --no-cal -0\n",
program );
799 fprintf( stderr,
"verbose: " );
800 vfprintf( stderr,
fmt, ap );
int XLALHighPassREAL4TimeSeries(REAL4TimeSeries *series, REAL8 frequency, REAL8 amplitude, INT4 filtorder)
int XLALLowPassREAL4TimeSeries(REAL4TimeSeries *series, REAL8 frequency, REAL8 amplitude, INT4 filtorder)
int XLALHighPassREAL8TimeSeries(REAL8TimeSeries *series, REAL8 frequency, REAL8 amplitude, INT4 filtorder)
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
void LALFindChirpInjectSignals(LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *events, COMPLEX8FrequencySeries *resp)
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
#define required_argument
TimeSlide * XLALTimeSlideTableFromLIGOLw(const char *filename)
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
int XLALAudioWAVRecordREAL4TimeSeries(FILE *fp, REAL4TimeSeries *series)
int XLALAudioAURecordREAL4TimeSeries(FILE *fp, REAL4TimeSeries *series)
void XLALDestroyCOMPLEX8FrequencySeries(COMPLEX8FrequencySeries *series)
REAL4FrequencySeries * XLALCreateREAL4FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
COMPLEX8FrequencySeries * XLALCreateCOMPLEX8FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheGlob(const char *dirstr, const char *fnptrn)
LALCache * XLALCacheImport(const char *fname)
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
int XLALFrStreamSetMode(LALFrStream *stream, int mode)
LAL_FR_STREAM_VERBOSE_MODE
LALTYPECODE XLALFrStreamGetTimeSeriesType(const char *chname, LALFrStream *stream)
REAL8TimeSeries * XLALFrStreamReadREAL8TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
REAL4TimeSeries * XLALFrStreamReadREAL4TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
REAL4FFTPlan * XLALCreateReverseREAL4FFTPlan(UINT4 size, int measurelvl)
REAL4FFTPlan * XLALCreateForwardREAL4FFTPlan(UINT4 size, int measurelvl)
void XLALDestroyREAL4FFTPlan(REAL4FFTPlan *plan)
int XLALResampleREAL4TimeSeries(REAL4TimeSeries *series, REAL8 dt)
int XLALREAL4AverageSpectrumWelch(REAL4FrequencySeries *spectrum, const REAL4TimeSeries *tseries, UINT4 seglen, UINT4 stride, const REAL4Window *window, const REAL4FFTPlan *plan)
int XLALREAL4FreqTimeFFT(REAL4TimeSeries *tser, const COMPLEX8FrequencySeries *freq, const REAL4FFTPlan *plan)
int XLALREAL4TimeFreqFFT(COMPLEX8FrequencySeries *freq, const REAL4TimeSeries *tser, const REAL4FFTPlan *plan)
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
REAL4TimeSeries * XLALResizeREAL4TimeSeries(REAL4TimeSeries *series, int first, size_t length)
const LALUnit lalADCCountUnit
const LALUnit lalDimensionlessUnit
void XLALDestroyREAL4Window(REAL4Window *window)
REAL4Window * XLALCreateHannREAL4Window(UINT4 length)
#define XLAL_ERROR_NULL(...)
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
SimInspiralTable * injections
char name[LIGOMETA_SOURCE_MAX]
struct tagSimInspiralTable * next
int inspinj(REAL4TimeSeries *series, const char *inspinjfile, const char *calfile)
int main(int argc, char *argv[])
const char * inspinjfile_
int verbose(const char *fmt,...)
REAL4TimeSeries * setdata(int intype, const char *channel, LIGOTimeGPS *start, REAL8 duration, REAL8 samplerate)
int parseopts(int argc, char **argv)
int usage(const char *program)
int dbg_fsdump(COMPLEX8FrequencySeries *series, const char *fname)
const char * burstinjfile_
REAL4FrequencySeries * powerspec(REAL4TimeSeries *series, REAL8 segdur, LIGOTimeGPS *epoch, const char *calibfile, int intype)
int burstinj(REAL4TimeSeries *series, const char *burstinjfile, const char *calfile)
REAL4TimeSeries * getdata(const char *path, int cachefileflg, const char *channel, LIGOTimeGPS *start, REAL8 duration)
int dbg_specdump(REAL4FrequencySeries *series, const char *fname)
int calibrate(REAL4TimeSeries *tseries, const char *calfile, REAL8 f_min)
int dbg_tsdump(REAL4TimeSeries *series, const char *fname)
int resample(REAL4TimeSeries *series, REAL8 srate)
int filter(REAL4TimeSeries *series, REAL8 minfreq, REAL8 maxfreq)
int output_psd(const char *outfile, REAL4FrequencySeries *series)
int output(const char *outfile, int outtype, REAL4TimeSeries *series)