144#define SIMULATETAYLORCWTESTC_ENORM 0
145#define SIMULATETAYLORCWTESTC_ESUB 1
146#define SIMULATETAYLORCWTESTC_EARG 2
147#define SIMULATETAYLORCWTESTC_EVAL 3
148#define SIMULATETAYLORCWTESTC_EFILE 4
149#define SIMULATETAYLORCWTESTC_EINPUT 5
150#define SIMULATETAYLORCWTESTC_EMEM 6
151#define SIMULATETAYLORCWTESTC_EPRINT 7
155#define SIMULATETAYLORCWTESTC_MSGENORM "Normal exit"
156#define SIMULATETAYLORCWTESTC_MSGESUB "Subroutine failed"
157#define SIMULATETAYLORCWTESTC_MSGEARG "Error parsing arguments"
158#define SIMULATETAYLORCWTESTC_MSGEVAL "Input argument out of valid range"
159#define SIMULATETAYLORCWTESTC_MSGEFILE "Could not open file"
160#define SIMULATETAYLORCWTESTC_MSGEINPUT "Error reading file"
161#define SIMULATETAYLORCWTESTC_MSGEMEM "Out of memory"
162#define SIMULATETAYLORCWTESTC_MSGEPRINT "Wrote past end of message string"
167#include <lal/LALStdio.h>
168#include <lal/LALStdlib.h>
169#include <lal/LALConstants.h>
170#include <lal/StreamInput.h>
171#include <lal/AVFactories.h>
172#include <lal/SeqFactories.h>
173#include <lal/VectorOps.h>
174#include <lal/DetectorSite.h>
175#include <lal/Units.h>
176#include <lal/PulsarSimulateCoherentGW.h>
177#include <lal/GenerateTaylorCW.h>
178#include <lal/LALBarycenter.h>
179#include <lal/LALInitBarycenter.h>
183#define APLUS (1000.0)
184#define ACROSS (1000.0)
195#define DT (0.0009765625)
199#define USAGE "Usage: %s [-s sourcefile] [-o outfile] [-r respfile]\n" \
200"\t[-l site earthfile sunfile] [-o outfile] [-t sec nsec npt dt]\n" \
201"\t[-t hsec hnsec fh] [-d debuglevel]\n"
207#define FSTOP (16384.0)
210#define ERROR( code, msg, statement ) \
212if ( lalDebugLevel & LALERROR ) \
214 XLALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
215 " %s %s\n", (code), *argv, __FILE__, \
217 statement ? statement : "", (msg) ); \
221#define INFO( statement ) \
223if ( lalDebugLevel & LALINFO ) \
225 XLALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
226 " %s\n", *argv, __FILE__, __LINE__, \
227 "$Id$", (statement) ); \
231#define WARNING( statement ) \
233if ( lalDebugLevel & LALWARNING ) \
235 XLALPrintError( "Warning[0]: program %s, file %s, line %d, %s\n" \
236 " %s\n", *argv, __FILE__, __LINE__, \
237 "$Id$", (statement) ); \
241#define SUB( func, statusptr ) \
243if ( (func), (statusptr)->statusCode ) \
245 ERROR( SIMULATETAYLORCWTESTC_ESUB, SIMULATETAYLORCWTESTC_MSGESUB, \
246 "Function call \"" #func "\" failed:" ); \
247 return SIMULATETAYLORCWTESTC_ESUB; \
251#define CHECKVAL( val, lower, upper ) \
253if ( ( (val) < (lower) ) || ( (val) > (upper) ) ) \
255 ERROR( SIMULATETAYLORCWTESTC_EVAL, SIMULATETAYLORCWTESTC_MSGEVAL, \
256 "Value of " #val " out of range:" ); \
257 if ( lalDebugLevel & LALERROR ) \
258 XLALPrintError( #val " = %f, range = [%f,%f]\n", (REAL8)(val), \
259 (REAL8)(lower), (REAL8)(upper) ); \
260 return SIMULATETAYLORCWTESTC_EVAL; \
274main(
int argc,
char **argv )
279 CHAR *sourcefile = NULL;
280 CHAR *respfile = NULL;
282 CHAR *earthfile = NULL;
283 CHAR *sunfile = NULL;
286 INT4 sec = SEC, nsec = NSEC;
287 INT4 hsec = HSEC, hnsec = HNSEC;
308 while ( arg < argc ) {
310 if ( !strcmp( argv[arg],
"-s" ) ) {
311 if ( argc > arg + 1 ) {
313 sourcefile = argv[arg++];
316 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
322 else if ( !strcmp( argv[arg],
"-r" ) ) {
323 if ( argc > arg + 1 ) {
325 respfile = argv[arg++];
328 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
334 else if ( !strcmp( argv[arg],
"-o" ) ) {
335 if ( argc > arg + 1 ) {
340 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
346 else if ( !strcmp( argv[arg],
"-l" ) ) {
347 if ( argc > arg + 3 ) {
350 earthfile = argv[arg++];
351 sunfile = argv[arg++];
354 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
360 else if ( !strcmp( argv[arg],
"-t" ) ) {
361 if ( argc > arg + 4 ) {
363 sec = atoi( argv[arg++] );
364 nsec = atoi( argv[arg++] );
365 npt = atoi( argv[arg++] );
366 dt = atof( argv[arg++] );
369 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
375 else if ( !strcmp( argv[arg],
"-h" ) ) {
376 if ( argc > arg + 4 ) {
378 hsec = atoi( argv[arg++] );
379 hnsec = atoi( argv[arg++] );
380 fh = atof( argv[arg++] );
383 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
389 else if ( !strcmp( argv[arg],
"-d" ) ) {
390 if ( argc > arg + 1 ) {
394 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
400 else if ( argv[arg][0] ==
'-' ) {
402 SIMULATETAYLORCWTESTC_MSGEARG, 0 );
409 CHECKVAL(
dt, LAL_REAL8_MIN, LAL_REAL8_MAX );
410 CHECKVAL( npt, 0, 2147483647 );
419 INT8 epochOut = nsec;
420 epochOut += 1000000000LL * sec;
421 tStart = epochOut - 1000000000LL;
423 I8ToLIGOTimeGPS( &(
output.epoch ), epochOut );
427 memset(
output.data->data, 0, npt *
sizeof(
REAL4 ) );
428 tStop = epochOut + 1000000000LL * (
INT8 )(
dt * npt + 1.0 );
443 if ( !( transfer ) ) {
445 SIMULATETAYLORCWTESTC_MSGEMEM, 0 );
448 detector.heterodyneEpoch.gpsSeconds = hsec;
449 detector.heterodyneEpoch.gpsNanoSeconds = hnsec;
456 if ( (
fp = fopen( respfile,
"r" ) ) == NULL ) {
458 SIMULATETAYLORCWTESTC_MSGEFILE, respfile );
463 ok &= (
fscanf(
fp,
"# epoch = %" LAL_INT8_FORMAT
"\n", &epoch ) == 1 );
464 I8ToLIGOTimeGPS( &( transfer->
epoch ), epoch );
465 ok &= (
fscanf(
fp,
"# f0 = %lf\n", &( transfer->
f0 ) )
467 ok &= (
fscanf(
fp,
"# deltaF = %lf\n",
468 &( transfer->
deltaF ) ) == 1 );
471 SIMULATETAYLORCWTESTC_MSGEINPUT, respfile );
480 SIMULATETAYLORCWTESTC_MSGEINPUT, respfile );
489 for (
i = 0;
i < response->
length;
i++ ) {
490 unity->
data[
i] = 1.0;
501 I8ToLIGOTimeGPS( &( transfer->
epoch ), EPOCH );
513 if ( !strcmp( site,
"LHO" ) ) {
515 }
else if ( !strcmp( site,
"LLO" ) ) {
517 }
else if ( !strcmp( site,
"VIRGO" ) ) {
519 }
else if ( !strcmp( site,
"GEO600" ) ) {
521 }
else if ( !strcmp( site,
"TAMA300" ) ) {
523 }
else if ( !strcmp( site,
"CIT40" ) ) {
527 SIMULATETAYLORCWTESTC_MSGEVAL,
"Unrecognized site:" );
536 SIMULATETAYLORCWTESTC_MSGEMEM, 0 );
563 if ( (
fp = fopen( sourcefile,
"r" ) ) == NULL ) {
565 SIMULATETAYLORCWTESTC_MSGEFILE, sourcefile );
580 signalvec.
data = NULL;
588 ok &= (
fscanf(
fp,
"%" LAL_INT8_FORMAT, &epoch ) == 1 );
591 ok &= ( input->
length > 6 );
601 if ( input->
length > 7 ) {
604 for (
i = 0;
i < input->
length - 7;
i++ ) {
631 for (
i = 0;
i < length;
i++ ) {
633 fFac += fData[
i] * ( tN *=
t );
634 tFac += fData[
i] * tN / (
i + 2.0 );
635 for ( j =
i + 1;
j < length;
j++ ) {
636 fData[
i] +=
choose( j + 1,
i + 1 ) * fData[
j] * ( tM *=
t );
641 for (
i = 0;
i < length;
i++ ) {
647 REAL4 *sigData, *outData;
648 REAL4 t = ( 1.0e-9 ) * (
REAL4 )( tStop - tStart );
654 for (
i = 0;
i <
params.f->length;
i++ ) {
655 dtInv += sqrt( (
i + 1 ) * fabs(
params.f->data[
i] ) * tN );
658 dtInv *= 10.0 * sqrt( fabs(
params.f0 ) );
660 if ( dtInv < 1.0 /
t ) {
664 params.deltaT = 1.0 / dtInv;
668 if (
params.dfdt > 2.0 ) {
675 "Waveform sampling interval is too large:\n"
676 "\tmaximum df*dt = %f",
params.dfdt );
679 SIMULATETAYLORCWTESTC_MSGEPRINT, 0 );
693 outData =
output.data->data;
694 for (
i = 0;
i < (
UINT4 )( npt );
i++ ) {
695 outData[
i] += sigData[
i];
729 if ( (
fp = fopen(
outfile,
"w" ) ) == NULL ) {
731 SIMULATETAYLORCWTESTC_MSGEFILE,
outfile );
736 fprintf(
fp,
"# epoch = %" LAL_INT8_FORMAT
"\n", epoch );
738 for (
i = 0;
i <
output.data->length;
i++ ) {
756 INFO( SIMULATETAYLORCWTESTC_MSGENORM );
765 INT8 s = input / 1000000000LL;
767 output->gpsNanoSeconds = (
INT4 )( input - 1000000000LL *
s );
778 UINT4 lal_index = b + 1;
779 while ( --lal_index ) {
780 numer *=
a - b + lal_index;
783 return numer /
denom;
LALDetectorIndexGEO600DIFF
LALDetectorIndexTAMA300DIFF
LALDetectorIndexVIRGODIFF
LALDetectorIndexCIT40DIFF
#define SUB(func, statusptr)
#define ERROR(code, msg, statement)
static UINT4 choose(UINT4 a, UINT4 b)
void LALCheckMemoryLeaks(void)
const WeaveSearchTimingDenominator denom
#define SIMULATETAYLORCWTESTC_EINPUT
Error reading file.
#define SIMULATETAYLORCWTESTC_EARG
Error parsing arguments.
#define SIMULATETAYLORCWTESTC_ENORM
Normal exit.
#define SIMULATETAYLORCWTESTC_EFILE
Could not open file.
#define SIMULATETAYLORCWTESTC_EVAL
Input argument out of valid range.
#define SIMULATETAYLORCWTESTC_EMEM
Out of memory.
#define SIMULATETAYLORCWTESTC_EPRINT
Wrote past end of message string.
int main(int argc, char **argv)
void LALSDestroyVectorSequence(LALStatus *status, REAL4VectorSequence **vectorSequence)
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
void LALGenerateTaylorCW(LALStatus *stat, PulsarCoherentGW *output, TaylorCWParamStruc *params)
Computes a Taylor-parametrized continuous waveform.
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
void LALPulsarSimulateCoherentGW(LALStatus *stat, REAL4TimeSeries *output, PulsarCoherentGW *CWsignal, PulsarDetectorResponse *detector)
Computes the response of a detector to a coherent gravitational wave.
COORDINATESYSTEM_EQUATORIAL
const LALUnit lalStrainUnit
const LALUnit lalADCCountUnit
LALUnit * XLALUnitDivide(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
void LALCCreateVector(LALStatus *, COMPLEX8Vector **, UINT4)
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALCDestroyVector(LALStatus *, COMPLEX8Vector **)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
void LALCCVectorDivide(LALStatus *status, COMPLEX8Vector *out, const COMPLEX8Vector *in1, const COMPLEX8Vector *in2)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
This structure stores a representation of a plane gravitational wave propagating from a particular po...
This structure contains information required to determine the response of a detector to a gravitation...
This structure stores the parameters for constructing a gravitational waveform with a Taylor-polynomi...