262#include <sys/types.h>
272#include <lal/LALConfig.h>
273#include <lal/LALgetopt.h>
274#include <lal/LALStdio.h>
275#include <lal/LALStdlib.h>
276#include <lal/LALError.h>
277#include <lal/LALDatatypes.h>
278#include <lal/AVFactories.h>
279#include <lal/LALConstants.h>
280#include <lal/LALFrStream.h>
281#include <lal/Calibration.h>
282#include <lal/LALFrameIO.h>
283#include <lal/FindChirp.h>
284#include <lal/LIGOLwXML.h>
285#include <lal/LIGOLwXMLRead.h>
286#include <lal/LIGOMetadataTables.h>
287#include <lal/LIGOMetadataUtils.h>
288#include <lal/LIGOMetadataInspiralUtils.h>
290#include <lal/Units.h>
291#include <lal/TimeSeries.h>
295#define CVS_ID_STRING "$Id$"
296#define CVS_NAME_STRING "$Name$"
297#define CVS_REVISION "$Revision$"
298#define CVS_SOURCE "$Source$"
299#define CVS_DATE "$Date$"
300#define PROGRAM_NAME "inspiral"
352int main(
int argc,
char *argv[] )
378 const LALUnit strainPerCount = {0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}};
417 for ( this_proc_param = procparams; this_proc_param->
next;
418 this_proc_param = this_proc_param->
next );
483 if (
vrbflg )
fprintf( stdout,
"input channel %s has sample interval "
484 "(deltaT) = %e\nreading %d points from frame stream\n",
fqChanName,
502 if (
vrbflg )
fprintf( stdout,
"read channel %s from frame stream\n"
503 "got %d points with deltaT %e\nstarting at GPS time %d sec %d ns\n",
539 (inj.
deltaT * 1.0e9) + 0.5 );
543 if (
vrbflg )
fprintf( stdout,
"input inj Channel %s has sample interval"
544 " (deltaT) = %e\nreading %d points from frame stream\n",
fqChanName,
553 if (
vrbflg )
fprintf( stdout,
"read inj Channel %s from frame stream\n"
554 "got %d points with deltaT %e\nstarting at GPS time %d sec %d ns\n",
609 fprintf( stderr,
"error: cannot read injection file" );
642 if (
vrbflg )
fprintf( stdout,
"setting response to unity... " );
669 if (
vrbflg )
fprintf( stdout,
"injected signals from %s into %s\n",
685 struct FrFile *frOutFile = NULL;
686 struct FrameH *outFrame = NULL;
696 output.data->length = length;
759 "Casting data to real 8 before writing frame\n" );
761 for (
j = 0 ;
j <
output.data->length ; ++
j )
772 for (
j = 0 ;
j <
output.data->length ; ++
j )
781 "ct",
"PLUS_INSP_INJ" );
809 frOutFile = FrFileONew(
fname, 3 );
810 FrameWrite( outFrame, frOutFile );
811 FrFileOEnd( frOutFile );
817 if( real8Output.
data )
876 if (
vrbflg )
fprintf( stdout,
" process_params table...\n" );
881 if (
vrbflg )
fprintf( stdout,
" search_summary table...\n" );
907 if (
vrbflg )
fprintf( stdout,
"checking memory leaks and exiting\n" );
914#define ADD_PROCESS_PARAM( pptype, format, ppvalue ) \
915 this_proc_param = this_proc_param->next = (ProcessParamsTable *) \
916calloc( 1, sizeof(ProcessParamsTable) ); \
917snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", \
919snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "--%s", \
920 long_options[option_index].name ); \
921snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "%s", pptype ); \
922snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, format, ppvalue );
932 "Usage: %s [options] [LIGOLW XML input files]\n" \
933 "The following options are recognized. Options not surrounded in [] are\n" \
935 " [--help] display this message\n"\
936 " [--verbose] print progress information\n"\
937 " [--version] print version information and exit\n"\
938 " [--user-tag] usertag set the process_params usertag to usertag\n"\
939 " [--comment] string set the process table comment to string\n"\
941 " --gps-start-time start_time GPS second of data start time\n"\
942 " [--gps-start-time-ns] start_ns GPS nanosecond of data start time\n"\
943 " --gps-end-time end_time GPS second of data end time\n"\
944 " [--gps-end-time-ns] end_ns GPS nanosecond of data end time\n"\
946 " [--frame-cache] cache frame cache with locations of data\n"\
947 " [--calibration-file] cal_file frame file containing calibration data\n"\
948 " [--calibration-cache] cal_cache file with location of calibration data\n"\
949 " [--calibrated-data] type calibrated data of type (real_4 | real_8)\n"\
950 " [--num-resp-points] N num points to determine response function (4194304)\n"\
951 " [--channel-name] chan channel from which to read data\n"\
953 " [--injection-channel] inj_chan channel from which to read inj data\n"\
954 " [--injection-cache] inj_cache cache with location of injection data\n"\
955 " [--injection-file] inj_file xml file with injection details\n"\
956 " [--inject-overhead] inject signals from overhead detector\n"\
957 " [--inject-safety] safety inject signals ending up to safety\n"
958 " seconds after end_time\n"\
959 " [--injection-start-freq] flow inject signals starting at flow (40Hz)\n"\
961 " [--write-raw-data] write out raw-data channel\n"\
962 " [--write-inj-only] write out inj-only channel\n"\
963 " [--write-raw-plus-inj] write out raw plus inj channel\n"\
964 " [--write-real8-frame] write out real 8 frames\n"\
966 " [--output-frame-length] len length of output frames\n"\
967 " [--output-file-name] out set file names to out-gpstime-length.gwf\n"\
968 " if not set, default to ifo-inspfrinj-gpstime-length.gwf\n"\
969 " [--write-compress] write compressed xml files\n"\
971 " [--ifo] ifo specify the ifo (if not reading frames)\n"\
972 " [--sample-rate] rate data sample rate (if not reading frames)\n"\
1031 int option_index = 0;
1032 size_t LALoptarg_len;
1035 "A:B:C:I:L:N:S:V:Z:"
1036 "a:b:c:d:f:hi:l:p:q:r:s:u:w:y:",
1037 long_options, &option_index );
1049 if ( long_options[option_index].
flag != 0 )
1055 fprintf( stderr,
"error parsing option %s with argument %s\n",
1065 if ( gstartt < 441417609 )
1067 fprintf( stderr,
"invalid argument to --%s:\n"
1068 "GPS start time is prior to "
1069 "Jan 01, 1994 00:00:00 UTC:\n"
1070 "(%ld specified)\n",
1071 long_options[option_index].
name, gstartt );
1083 if ( gstarttns < 0 )
1085 fprintf( stderr,
"invalid argument to --%s:\n"
1086 "GPS start time nanoseconds is negative\n",
1087 long_options[option_index].
name );
1090 if ( gstarttns > 999999999 )
1092 fprintf( stderr,
"invalid argument to --%s:\n"
1093 "GPS start time nanoseconds is greater than unity:\n"
1094 "Must be <= 999999999 (%ld specified)\n",
1095 long_options[option_index].
name, gstarttns );
1107 if ( gendt < 441417609 )
1109 fprintf( stderr,
"invalid argument to --%s:\n"
1110 "GPS end time is prior to "
1111 "Jan 01, 1994 00:00:00 UTC:\n"
1112 "(%ld specified)\n",
1113 long_options[option_index].
name, gendt );
1127 fprintf( stderr,
"invalid argument to --%s:\n"
1128 "GPS end time nanoseconds is negative\n",
1129 long_options[option_index].
name );
1132 else if ( gendtns > 999999999 )
1134 fprintf( stderr,
"invalid argument to --%s:\n"
1135 "GPS end time nanoseconds is greater than unity:\n"
1136 "Must be <= 999999999:\n"
1137 "(%ld specified)\n",
1138 long_options[option_index].
name, gendtns );
1149 char *channamptr = NULL;
1150 LALoptarg_len = strlen(
LALoptarg ) + 1;
1156 if ( ! (channamptr = strstr(
fqChanName,
":" ) ) )
1158 fprintf( stderr,
"invalid argument to --%s:\n"
1159 "channel name must be a full LIGO channel name "
1160 "e.g. L1:LSC-AS_Q\n(%s specified)\n",
1166 memset(
ifo, 0,
sizeof(
ifo) );
1176 fprintf( stderr,
"invalid argument to --%s:\n"
1177 "length of frame must be a positive integer: "
1178 "(%d specified) \n",
1189 fprintf( stderr,
"invalid argument to --%s\n"
1190 "outfile name %s too long: string truncated\n",
1205 LALoptarg_len = strlen(
LALoptarg ) + 1;
1213 LALoptarg_len = strlen(
LALoptarg ) + 1;
1225 fprintf( stderr,
"invalid argument to --%s:\n"
1226 "number of points must be an even positive integer,\n"
1227 "(%d specified) \n",
1241 else if ( ! strcmp(
"real_8",
LALoptarg ) )
1244 fprintf( stderr,
"Sorry, code not currently set up to\n"
1245 "run on real_8 data\n" );
1250 fprintf( stderr,
"invalid argument to --%s:\n"
1251 "unknown data type specified;\n"
1252 "%s (must be one of: real_4, real_8)\n",
1265 fprintf( stderr,
"invalid argument to --%s:\n"
1266 "sample rate must be a positive integer: "
1267 "(%d specified) \n",
1279 fprintf( stderr,
"invalide argument to --%s:\n"
1280 "injections must start at a positive frequency."
1281 "(%f specified) \n",
1291 memset(
ifo, 0,
sizeof(
ifo) );
1301 fprintf( stderr,
"invalid argument to --%s:\n"
1302 "comment must be less than %d characters\n",
1316 fprintf( stderr,
"invalid argument to --%s:\n"
1317 "injection safety must be a positive integer: "
1318 "(%d specified) \n",
1328 LALoptarg_len = strlen(
LALoptarg ) + 1;
1337 LALoptarg_len = strlen(
LALoptarg ) + 1;
1345 LALoptarg_len = strlen(
LALoptarg ) + 1;
1353 LALoptarg_len = strlen(
LALoptarg ) + 1;
1361 LALoptarg_len = strlen(
LALoptarg ) + 1;
1377 fprintf( stdout,
"LIGO/LSC Inspiral Injection Program\n"
1378 "Steve Fairhurst <sfairhur@gravity.phys.uwm.edu>\n");
1389 fprintf( stderr,
"unknown error while parsing options\n" );
1397 fprintf( stderr,
"extraneous command line arguments:\n" );
1414 "--write-raw-data" );
1426 "--write-inj-only" );
1437 "--write-raw-plus-inj" );
1449 "--write-real8-frame" );
1462 "--inject-overhead" );
1479 fprintf( stderr,
"--gps-start-time must be specified\n" );
1487 fprintf( stderr,
"--gps-end-time must be specified\n" );
1495 fprintf( stderr,
"invalid gps time range: "
1496 "start time: %d, end time %d\n",
1505 "either --injection-file or --injection-channel must be specified\n");
1511 "Only one of --injection-file and --injection-channel may be given\n");
1519 "If --injection-channel specified, also require --frame-cache\n");
1529 fprintf( stderr,
"--output-frame-length must be specified\n" );
1535 fprintf(stderr,
"data length %d must be a multiple of frame length %d",
1551 fprintf( stderr,
"--channel-name must be specified\n" );
1560 fprintf( stderr,
"If --frame-cache not specified,\n"
1561 "--sample-rate must be specified\n" );
1567 fprintf( stderr,
"Neither --write-raw-data nor --write-raw-plus-inj\n"
1568 "can be specified when --frame-cache not given\n");
1576 fprintf( stderr,
"Either --calibration-cache must be specified,\n"
1577 "or must run on --calibrated-data.\n");
1583 "Only one of --calibration-cache and --calibration and --calibrated-data\n"
1584 "should be specified\n.");
1592 fprintf( stderr,
"--channel-name must be specified\n" );
1599 if (
vrbflg )
fprintf( stdout,
"--num-resp-points not specified\n"
1600 "This gives the number of points used to obtain response,\n"
1601 "Response has numRespPoints/2 + 1 points,\n"
1602 "Frequency resolution of 1/(numRespPoints * delta T).\n"
1603 "Setting it to a default value of 256 * 16384 = 4194304\n");
1611#undef ADD_PROCESS_PARAM
void LALFindChirpInjectSignals(LALStatus *status, REAL4TimeSeries *chan, SimInspiralTable *events, COMPLEX8FrequencySeries *resp)
const LALVCSInfoList lalAppsVCSInfoList
NULL-terminated list of VCS and build information for LALApps and its dependencies
const LALVCSInfo lalAppsVCSIdentInfo
Identable VCS and build information for LALApps.
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_CALL(function, statusptr)
void LALFrSeek(LALStatus *status, const LIGOTimeGPS *epoch, LALFrStream *stream)
void LALFrCacheOpen(LALStatus *status, LALFrStream **output, LALCache *cache)
void LALFrGetREAL4TimeSeries(LALStatus *status, REAL4TimeSeries *series, FrChanIn *chanin, LALFrStream *stream)
void LALFrClose(LALStatus *status, LALFrStream **stream)
void LALCheckMemoryLeaks(void)
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
#define required_argument
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLProcessTable(LIGOLwXMLStream *, const ProcessTable *)
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *, const ProcessParamsTable *)
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *, const SimInspiralTable *)
int XLALWriteLIGOLwXMLSearchSummaryTable(LIGOLwXMLStream *, const SearchSummaryTable *)
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
static LALUnit strainPerCount
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
void XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheImport(const char *fname)
#define XLAL_INIT_DECL(var,...)
LAL_FR_STREAM_VERBOSE_MODE
int XLALOutputVCSInfo(FILE *fp, const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
REAL4TimeSeries * XLALAddREAL4TimeSeries(REAL4TimeSeries *arg1, const REAL4TimeSeries *arg2)
const LALUnit lalADCCountUnit
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 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)
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
int main(int argc, char *argv[])
CHAR outfileName[FILENAME_MAX]
SimInspiralTable * thisInj
#define ADD_PROCESS_PARAM(pptype, format, ppvalue)
int vrbflg
defined in lal/lib/std/LALError.c
CHAR comment[LIGOMETA_COMMENT_MAX]
static void print_usage(char *program)
SimInspiralTable * injections
int arg_parse_check(int argc, char *argv[], ProcessParamsTable *procparams)
char name[LIGOMETA_SOURCE_MAX]
FrameH * fr_add_proc_REAL8TimeSeries(FrameH *frame, REAL8TimeSeries *chan, const char *unit, const char *suffix)
FrameH * fr_add_proc_REAL4TimeSeries(FrameH *frame, REAL4TimeSeries *chan, const char *unit, const char *suffix)
const char *const vcsDate
const char *const vcsStatus
CHAR type[LIGOMETA_TYPE_MAX]
CHAR param[LIGOMETA_PARAM_MAX]
CHAR value[LIGOMETA_VALUE_MAX]
struct tagProcessParamsTable * next
CHAR program[LIGOMETA_PROGRAM_MAX]
CHAR ifos[LIGOMETA_IFOS_MAX]
CHAR comment[LIGOMETA_COMMENT_MAX]
struct tagSimInspiralTable * next
int output(const char *outfile, int outtype, REAL4TimeSeries *series)