28#include <lal/LALStdio.h>
29#include <lal/LALStdlib.h>
30#include <lal/LALConstants.h>
31#include <lal/SeqFactories.h>
33#include <lal/Random.h>
34#include <lal/VectorOps.h>
35#include <lal/SimulateCoherentGW.h>
36#include <lal/GeneratePPNInspiral.h>
37#include <lal/LALSimulation.h>
38#include <lal/StreamInput.h>
39#include <lal/TimeFreqFFT.h>
40#include <lal/TimeSeries.h>
42#define INSPAWGFILEC_ENORM 0
43#define INSPAWGFILEC_ESUB 1
44#define INSPAWGFILEC_EARG 2
45#define INSPAWGFILEC_EVAL 3
46#define INSPAWGFILEC_EFILE 4
47#define INSPAWGFILEC_EINPUT 5
48#define INSPAWGFILEC_EMEM 6
50#define INSPAWGFILEC_MSGENORM "Normal exit"
51#define INSPAWGFILEC_MSGESUB "Subroutine failed"
52#define INSPAWGFILEC_MSGEARG "Error parsing arguments"
53#define INSPAWGFILEC_MSGEVAL "Input argument out of valid range"
54#define INSPAWGFILEC_MSGEFILE "Could not open file"
55#define INSPAWGFILEC_MSGEINPUT "Error reading file"
56#define INSPAWGFILEC_MSGEMEM "Out of memory"
60#define DIST (0.00002*LAL_MRSUN_SI )
68#define DT (1.0/16384.0)
75#define DELTAT (0.00006103515625)
78#define USAGE "Usage: %s [-s sourcefile] [-r respfile] [-o outfile] [-e seed]\n" \
79" [-i infile | -n sec nsec npt dt sigma] [-fi lowf] [-fe highf] \n" \
80" [-d debuglevel] [-p]\n"
83#define ERROR( code, msg, statement ) \
85if ( lalDebugLevel & LALERROR ) \
87 LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
88 " %s %s\n", (code), *argv, __FILE__, \
89 __LINE__, "$Id$", statement ? statement : \
94#define INFO( statement ) \
96if ( lalDebugLevel & LALINFO ) \
98 LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
99 " %s\n", *argv, __FILE__, __LINE__, \
100 "$Id$", (statement) ); \
104#define WARNING( statement ) \
106if ( lalDebugLevel & LALWARNING ) \
108 LALPrintError( "Warning[0]: program %s, file %s, line %d, %s\n" \
109 " %s\n", *argv, __FILE__, __LINE__, \
110 "$Id$", (statement) ); \
114#define SUB( func, statusptr ) \
116if ( (func), (statusptr)->statusCode ) \
118 ERROR( INSPAWGFILEC_ESUB, INSPAWGFILEC_MSGESUB, \
119 "Function call \"" #func "\" failed:" ); \
120 return INSPAWGFILEC_ESUB; \
124#define CHECKVAL( val, lower, upper ) \
126if ( ( (val) <= (lower) ) || ( (val) > (upper) ) ) \
128 ERROR( INSPAWGFILEC_EVAL, INSPAWGFILEC_MSGEVAL, \
129 "Value of " #val " out of range:" ); \
130 LALPrintError( #val " = %f, range = (%f,%f]\n", (REAL8)(val), \
131 (REAL8)(lower), (REAL8)(upper) ); \
132 return INSPAWGFILEC_EVAL; \
147 CHAR *sourcefile = NULL;
148 CHAR *respfile = NULL;
151 CHAR *specfile = NULL;
186 while ( arg < argc ) {
188 if ( !strcmp( argv[arg],
"-s" ) ) {
189 if ( argc > arg + 1 ) {
191 sourcefile = argv[arg++];
199 else if ( !strcmp( argv[arg],
"-r" ) ) {
200 if ( argc > arg + 1 ) {
202 respfile = argv[arg++];
210 else if ( !strcmp( argv[arg],
"-i" ) ) {
211 if ( argc > arg + 1 ) {
213 infile = argv[arg++];
221 else if ( !strcmp( argv[arg],
"-n" ) ) {
222 if ( argc > arg + 5 ) {
224 sec = atoi( argv[arg++] );
225 nsec = atoi( argv[arg++] );
226 npt = atoi( argv[arg++] );
227 dt = atof( argv[arg++] );
228 sigma = atof( argv[arg++] );
236 else if ( !strcmp( argv[arg],
"-o" ) ) {
237 if ( argc > arg + 1 ) {
247 else if ( !strcmp( argv[arg],
"-d" ) ) {
248 if ( argc > arg + 1 ) {
257 else if ( !strcmp( argv[arg],
"-fi" ) ) {
258 if ( argc > arg + 1 ) {
260 fstart = atof( argv[arg++] );
268 else if ( !strcmp( argv[arg],
"-fe" ) ) {
269 if ( argc > arg + 1 ) {
271 fstop = atof( argv[arg++] );
279 else if ( !strcmp( argv[arg],
"-e" ) ) {
280 if ( argc > arg + 1 ) {
282 seed = atoi( argv[arg++] );
290 else if ( !strcmp( argv[arg],
"-p" ) ) {
291 if ( argc > arg + 1 ) {
293 specfile = argv[arg++];
301 else if ( argv[arg][0] ==
'-' ) {
342 if ( (
fp = fopen( respfile,
"r" ) ) == NULL ) {
353 ok &= (
fscanf(
fp,
"# deltaF = %lf\n",
354 &(
detector.transfer->deltaF ) ) == 1 );
375 for (
i = 0;
i < response->
length;
i++ ) {
376 unity->
data[
i] = 1.0;
390 detector.transfer->deltaF = 1.5*fstop;
393 detector.transfer->data->data[0] = 1.0;
394 detector.transfer->data->data[1] = 1.0;
401 if ( (
fp = fopen( infile,
"r" ) ) == NULL ) {
435 output.epoch.gpsSeconds = sec;
436 output.epoch.gpsNanoSeconds = nsec;
453 if ( (
fp = fopen( sourcefile,
"r" ) ) == NULL ) {
500 ppnParams.
ppn = NULL;
513 "\tWaveform terminared at %e Hz\n",
514 *argv, __FILE__, __LINE__,
515 "$Id$", ppnParams.
fStop );
517 if ( ppnParams.
dfdt > 2.0 ) {
519 "Waveform sampling interval is too large:\n"
520 "\tmaximum df*dt = %f", ppnParams.
dfdt );
526 if ( timeCode ==
'f' )
528 else if ( timeCode ==
'c' )
566 fprintf(stderr,
"error, unable to compute power spectrum.\n" );
567 fprintf(stderr,
"LALRealAverageSpectrum has been removed from LAL.\n" );
568 fprintf(stderr,
"Fix code to use new LALREAL4AverageSpectrum routine.\n" );
569 fprintf(stderr,
"Aborting.\n" );
573 RealDFTParams *dftparams = NULL;
574 LALWindowParams winParams;
579 winParams.length=length;
587 length/2 + 1), &
stat );
590 SUB( LALCreateRealDFTParams(&
stat , &dftparams, &winParams, 1),
598 SUB( LALDestroyRealDFTParams(&
stat, &dftparams), &
stat);
611 if ( (
fp = fopen(
outfile,
"w" ) ) == NULL ) {
616 for (
i = 0;
i <
output.data->length;
i++ )
639 INT8 s = input / 1000000000LL;
641 output->gpsNanoSeconds = (
INT4)( input - 1000000000LL*
s );
void LALCheckMemoryLeaks(void)
void LALSimulateCoherentGW(LALStatus *status, REAL4TimeSeries *output, CoherentGW *input, DetectorResponse *detector)
void LALSDestroyVectorSequence(LALStatus *status, REAL4VectorSequence **vectorSequence)
void LALGeneratePPNInspiral(LALStatus *, CoherentGW *output, PPNParamStruc *params)
int LALPrintError(const char *fmt,...)
int XLALSimAddInjectionREAL4TimeSeries(REAL4TimeSeries *target, REAL4TimeSeries *h, const COMPLEX8FrequencySeries *response)
void LALSPrintFrequencySeries(REAL4FrequencySeries *series, const CHAR *filename)
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
void LALNormalDeviates(LALStatus *status, REAL4Vector *deviates, RandomParams *params)
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
COORDINATESYSTEM_EQUATORIAL
REAL4TimeSeries * XLALCreateREAL4TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
void XLALDestroyREAL4TimeSeries(REAL4TimeSeries *series)
const LALUnit lalStrainUnit
const LALUnit lalADCCountUnit
LALUnit * XLALUnitDivide(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
void LALCCreateVector(LALStatus *, COMPLEX8Vector **, UINT4)
void LALDestroyVector(LALStatus *, REAL4Vector **)
void LALCDestroyVector(LALStatus *, COMPLEX8Vector **)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALCreateVector(LALStatus *, REAL4Vector **, UINT4)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
void LALCCVectorDivide(LALStatus *status, COMPLEX8Vector *out, const COMPLEX8Vector *in1, const COMPLEX8Vector *in2)
void XLALBacktraceErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
void I8ToLIGOTimeGPS(LIGOTimeGPS *output, INT8 input)
#define INSPAWGFILEC_MSGEINPUT
int main(int argc, char **argv)
#define SUB(func, statusptr)
#define INSPAWGFILEC_MSGEFILE
#define ERROR(code, msg, statement)
#define INSPAWGFILEC_MSGEARG
#define INSPAWGFILEC_EMEM
#define INSPAWGFILEC_ENORM
#define CHECKVAL(val, lower, upper)
#define INSPAWGFILEC_MSGENORM
#define INSPAWGFILEC_EFILE
#define INSPAWGFILEC_EINPUT
#define WARNING(statement)
#define INSPAWGFILEC_MSGEMEM
#define INSPAWGFILEC_EARG
const CHAR * termDescription
int output(const char *outfile, int outtype, REAL4TimeSeries *series)