40#include <gsl/gsl_rng.h>
41#include <gsl/gsl_randist.h>
45#include <lal/LALgetopt.h>
46#include <lal/GenerateBurst.h>
47#include <lal/LALConstants.h>
48#include <lal/LALSimBurst.h>
49#include <lal/LALStdio.h>
50#include <lal/LALStdlib.h>
51#include <lal/LIGOLwXML.h>
52#include <lal/LIGOLwXMLRead.h>
53#include <lal/LIGOMetadataTables.h>
54#include <lal/LIGOMetadataUtils.h>
55#include <lal/TimeDelay.h>
56#include <lal/TimeSeries.h>
57#include <lal/XLALError.h>
61#define CVS_REVISION "$Revision$"
62#define CVS_SOURCE "$Source$"
63#define CVS_DATE "$Date$"
64#define PROGRAM_NAME "lalapps_binj"
148"lalapps_binj [options]\n" \
152"--gps-end-time seconds\n" \
153"--gps-start-time seconds\n" \
154" Bounds of interval in which to synthesize injections.\n" \
157" display this message\n" \
159"--max-amplitude value\n" \
160"--min-amplitude value\n" \
161" Set the bounds of the injection ampltiudes. These only affect\n" \
162" string cusp injections.\n" \
164"--max-bandwidth hertz\n" \
165"--min-bandwidth hertz\n" \
166" Set the bounds of the injection bandwidthds. These only affect\n" \
167" btlwnb waveforms.\n" \
170"--max-duration seconds\n" \
171"--min-duration seconds\n" \
172" Set the bounds of the injection durations. These only affect\n" \
173" btlwnb waveforms.\n" \
175"--max-e-over-r2 value\n" \
176"--min-e-over-r2 value\n" \
177" Set the bounds of the range of equivalent isotropic radiated\n" \
178" energies of btlwnb waveforms. The units are M_{sun} / pc^{2} (solar\n" \
179" masses per parsec^{2}).\n" \
182"--max-frequency hertz\n" \
183"--min-frequency hertz\n" \
184" Set the bounds of the injection frequencies. These are the centre\n" \
185" frequencies of sine-Gaussians and btlwnb waveforms, and the\n" \
186" high-frequency cut-offs of string cusp waveforms.\n" \
188"--max-hrss value\n" \
189"--min-hrss value\n" \
191" Set the bounds of the injection h_{rss} values. These only affect\n" \
192" sine-Gaussian injections. (Actually, these set the bounds of the\n" \
193" product of the waveform's hrss and its duration, which makes the\n" \
194" injections lie along the 50 efficiency curve better. To convert to\n" \
195" real hrss multiply by sqrt(2) pi f/Q.) \n" \
198"--output filename\n" \
199" Select output name (default is too hard to explain).\n" \
201"--population name\n" \
202" Select the injection population to synthesize. Allowed values are\n" \
203" \"targeted\", \"string_cusp\", and \"all_sky_sinegaussian\",\n" \
204" \"all_sky_btlwnb\".\n" \
207" Set the Q for sine-Gaussian injections.\n" \
210" Set the right-ascension and declination of the sky location from which\n" \
211" injections should originate when generating a targeted population.\n" \
212" Co-ordinates are in radians.\n" \
216" Set the random number generator's seed (0 = off, default = 0).\n" \
218"--time-step value\n" \
219" Set the time betwen injections in seconds (default = 210 / pi).\n" \
222" Give the injection time a random offset within a centered window with a\n" \
223" length specified by this parameter. Value is in seconds, default is 0.\n" \
225"--time-slide-file filename\n" \
226" Set the name of the LIGO Light-Weight XML file from which to load\n" \
227" the time slide table. The document must contain exactly 1 time\n" \
228" slide vector, and only the contents of the process, process_params,\n" \
229" search_summary (optional), sim_burst (optional), and time_slide tables\n" \
232"--user-tag string\n" \
233" Set the user tag in the process and search summary tables to this.\n"
241 snprintf((*proc_param)->program,
sizeof((*proc_param)->program),
"%s",
PROGRAM_NAME);
242 snprintf((*proc_param)->type,
sizeof((*proc_param)->type),
"%s",
type);
243 snprintf((*proc_param)->param,
sizeof((*proc_param)->param),
"--%s", param);
244 snprintf((*proc_param)->value,
sizeof((*proc_param)->value),
"%s", value);
246 return &(*proc_param)->next;
250#define ADD_PROCESS_PARAM(process, type) \
251 do { paramaddpoint = add_process_param(paramaddpoint, process, type, long_options[option_index].name, LALoptarg); } while(0)
287 do switch(
c =
LALgetopt_long(*argc, *argv,
"", long_options, &option_index)) {
373 else if(!strcmp(
LALoptarg,
"string_cusp"))
375 else if(!strcmp(
LALoptarg,
"all_sky_sinegaussian"))
377 else if(!strcmp(
LALoptarg,
"all_sky_btlwnb"))
472 fprintf(stderr,
"error: --max-amplitude < --min-amplitude\n");
476 fprintf(stderr,
"error: --max-bandwidth < --min-bandwidth\n");
480 fprintf(stderr,
"error: --max-duration < --min-duration\n");
484 fprintf(stderr,
"error: --max-frequency < --min-frequency\n");
488 fprintf(stderr,
"error: --max-hrss < --min-hrss\n");
493 fprintf(stderr,
"--gps-start-time and --gps-end-time are both required\n");
497 fprintf(stderr,
"error: --gps-end-time < --gps-start-time\n");
501 fprintf(stderr,
"--time-slide-file is required\n");
513 fprintf(stderr,
"error: --population is required\n");
518 int max_length = 100;
539#define DEFINELIGOLWTABLEAPPEND(funcroot, rowtype) \
540static rowtype *XLAL ## funcroot ## Append(rowtype *head, rowtype *row) \
545 for(tail = head; tail->next; tail = tail->next); \
563 TimeSlide *tisl_time_slide_table_head, *time_slide_row;
565 SimBurst *tisl_sim_burst_table_head, *sim_burst_row;
571 if(!tisl_process_table_head)
574 if(!tisl_process_params_table_head)
577 if(!tisl_time_slide_table_head)
581 if(!tisl_search_summary_table_head)
584 tisl_search_summary_table_head = NULL;
587 if(!tisl_sim_burst_table_head)
590 tisl_sim_burst_table_head = NULL;
594 for(time_slide_row = tisl_time_slide_table_head->
next; time_slide_row; time_slide_row = time_slide_row->
next)
596 fprintf(stderr,
"error: time slide file \"%s\" contains more than 1 offset vector",
filename);
604 for(process_row = *process_table_head; process_row; process_row = process_row->
next)
606 for(process_params_row = *process_params_table_head; process_params_row; process_params_row = process_params_row->
next)
608 for(search_summary_row = *search_summary_table_head; search_summary_row; search_summary_row = search_summary_row->
next)
610 for(sim_burst_row = *sim_burst_table_head; sim_burst_row; sim_burst_row = sim_burst_row->
next)
615 *process_table_head = XLALProcessTableAppend(tisl_process_table_head, *process_table_head);
616 *process_params_table_head = XLALProcessParamsTableAppend(tisl_process_params_table_head, *process_params_table_head);
617 *time_slide_table_head = XLALTimeSlideTableAppend(tisl_time_slide_table_head, *time_slide_table_head);
618 *search_summary_table_head = XLALSearchSummaryTableAppend(tisl_search_summary_table_head, *search_summary_table_head);
619 *sim_burst_table_head = XLALSimBurstTableAppend(tisl_sim_burst_table_head, *sim_burst_table_head);
629 return strcmp(*
a, *b);
636 char **time_slide_instruments;
637 int n_instruments,
n;
641 for(n_instruments = 0, time_slide = time_slide_table_head; time_slide; n_instruments++, time_slide = time_slide->
next);
645 time_slide_instruments = malloc(n_instruments *
sizeof(*time_slide_instruments));
646 if(!time_slide_instruments)
648 for(
n = 0, time_slide = time_slide_table_head; time_slide;
n++, time_slide = time_slide->
next)
649 time_slide_instruments[
n] = time_slide->
instrument;
650 qsort(time_slide_instruments, n_instruments,
sizeof(*time_slide_instruments), (
int (*)(
const void *,
const void *))
qsort_strcmp);
653 for(
n = 0;
n < n_instruments;
n++) {
655 copied = snprintf(
ifos,
sizeof(
process->ifos) - (
ifos -
process->ifos),
"%s%s", time_slide_instruments[
n],
n < n_instruments - 1 ?
"," :
"");
656 if(copied < 2 + (
n < n_instruments - 1 ? 1 : 0)) {
657 fprintf(stderr,
"error: too many instruments for process table's ifos column\n");
658 free(time_slide_instruments);
663 free(time_slide_instruments);
683static double sequence_arithmetic_next(
double low,
double high,
double delta)
688 if(high < low || high - low < delta)
708 static unsigned i = 0;
709 double x = low * pow(ratio,
i++);
711 if(high < low || high / low < ratio)
729static double sequence_preset_next(gsl_rng *rng)
731 static const double presets[] = {
741 return presets[gsl_rng_uniform_int(rng,
XLAL_NUM_ELEM(presets))];
763 return exp(gsl_ran_flat(rng,
log(
a),
log(b)));
779 static double factor = 0.0;
811 const double thetasqmin = pow(fhigh, -2.0 / 3.0);
812 const double thetasqmax = pow(
flow, -2.0 / 3.0);
813 const double thetasq = gsl_ran_flat(rng, thetasqmin, thetasqmax);
815 return pow(thetasq, -3.0 / 2.0);
827 *
dec = asin(gsl_ran_flat(rng, -1, +1));
844 strcpy(sim_burst->
waveform,
"StringCusp");
880static SimBurst *
random_directed_btlwnb(
double ra,
double dec,
double psi,
double minf,
double maxf,
double minband,
double maxband,
double mindur,
double maxdur,
double minEoverr2,
double maxEoverr2, gsl_rng *rng)
888 strcpy(sim_burst->
waveform,
"BTLWNB");
936 if(!hplus || !hcross) {
952static SimBurst *
random_all_sky_btlwnb(
double minf,
double maxf,
double minband,
double maxband,
double mindur,
double maxdur,
double minEoverr2,
double maxEoverr2, gsl_rng *rng)
958 return random_directed_btlwnb(
ra,
dec,
psi, minf, maxf, minband, maxband, mindur, maxdur, minEoverr2, maxEoverr2, rng);
979 return Q / (sqrt(2.0) *
LAL_PI *
f);
995 strcpy(sim_burst->
waveform,
"SineGaussian");
1094 TimeSlide *time_slide_table_head = NULL;
1095 SimBurst *sim_burst_table_head = NULL;
1096 SimBurst **sim_burst = &sim_burst_table_head;
1135 snprintf(search_summary->comment,
sizeof(search_summary->comment),
"%s",
options.
user_tag);
1136 search_summary->nnodes = 1;
1146 rng = gsl_rng_alloc(gsl_rng_mt19937);
1171 *sim_burst =
random_directed_btlwnb(
options.
ra,
options.
dec, gsl_ran_flat(rng, 0,
LAL_TWOPI),
options.
minf,
options.
maxf,
options.
minbandwidth,
options.
maxbandwidth,
options.
minduration,
options.
maxduration,
options.
minEoverr2,
options.
maxEoverr2, rng);
1221 sim_burst = &(*sim_burst)->
next;
1234 snprintf(search_summary->ifos,
sizeof(search_summary->ifos),
"%s",
process->ifos);
1240 write_xml(
options.
output, process_table_head, process_params_table_head, search_summary_table_head, time_slide_table_head, sim_burst_table_head);
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
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)
static double double delta
int LALgetopt_long(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 XLALWriteLIGOLwXMLSimBurstTable(LIGOLwXMLStream *, const SimBurst *)
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *, const ProcessParamsTable *)
int XLALWriteLIGOLwXMLSearchSummaryTable(LIGOLwXMLStream *, const SearchSummaryTable *)
int XLALWriteLIGOLwXMLTimeSlideTable(LIGOLwXMLStream *, const TimeSlide *)
int XLALLIGOLwHasTable(const char *filename, const char *table_name)
ProcessParamsTable * XLALProcessParamsTableFromLIGOLw(const char *filename)
ProcessTable * XLALProcessTableFromLIGOLw(const char *filename)
TimeSlide * XLALTimeSlideTableFromLIGOLw(const char *filename)
SearchSummaryTable * XLALSearchSummaryTableFromLIGOLw(const char *fileName)
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
static double ran_flat_log(gsl_rng *rng, double a, double b)
int main(int argc, char *argv[])
static void print_usage(void)
static int load_tisl_file_and_merge(const char *filename, ProcessTable **process_table_head, ProcessParamsTable **process_params_table_head, TimeSlide **time_slide_table_head, SearchSummaryTable **search_summary_table_head, SimBurst **sim_burst_table_head)
static double sequence_geometric_next(double low, double high, double ratio)
static SimBurst * random_all_sky_sineGaussian(double minf, double maxf, double q, double minhrsst, double maxhrsst, gsl_rng *rng)
static struct options parse_command_line(int *argc, char **argv[], const ProcessTable *process, ProcessParamsTable **paramaddpoint)
#define ADD_PROCESS_PARAM(process, type)
static int set_instruments(ProcessTable *process, TimeSlide *time_slide_table_head)
static ProcessParamsTable ** add_process_param(ProcessParamsTable **proc_param, const ProcessTable *process, const char *type, const char *param, const char *value)
static void random_location_and_polarization(double *ra, double *dec, double *psi, gsl_rng *rng)
static double random_string_cusp_fhigh(double flow, double fhigh, gsl_rng *rng)
static SimBurst * random_string_cusp(double flow, double fhigh, double Alow, double Ahigh, gsl_rng *rng)
static SimBurst * random_directed_btlwnb(double ra, double dec, double psi, double minf, double maxf, double minband, double maxband, double mindur, double maxdur, double minEoverr2, double maxEoverr2, gsl_rng *rng)
static SimBurst * random_all_sky_btlwnb(double minf, double maxf, double minband, double maxband, double mindur, double maxdur, double minEoverr2, double maxEoverr2, gsl_rng *rng)
static void write_xml(const char *filename, const ProcessTable *process_table_head, const ProcessParamsTable *process_params_table_head, const SearchSummaryTable *search_summary_table_head, const TimeSlide *time_slide_table_head, const SimBurst *sim_burst)
static double ran_flat_log_discrete(gsl_rng *rng, double a, double b, double ratio)
static struct options options_defaults(void)
static double duration_from_q_and_f(double Q, double f)
@ POPULATION_ALL_SKY_SINEGAUSSIAN
@ POPULATION_ALL_SKY_BTLWNB
static int qsort_strcmp(char **a, char **b)
#define DEFINELIGOLWTABLEAPPEND(funcroot, rowtype)
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
REAL8 XLALMeasureHrss(const REAL8TimeSeries *, const REAL8TimeSeries *)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_REAL8_FAIL_NAN
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALPrintProgressBar(double)
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
int XLALGenerateSimBurst(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, const SimBurst *sim_burst, double delta_t)
char name[LIGOMETA_SOURCE_MAX]
const char *const vcsDate
const char *const vcsStatus
struct tagProcessParamsTable * next
struct tagProcessTable * next
struct tagSearchSummaryTable * next
char waveform[LIGOMETA_WAVEFORM_MAX]
struct tagSimBurst * next
unsigned long waveform_number
CHAR instrument[LIGOMETA_STRING_MAX]
struct tagTimeSlide * next
enum population population