150 #include <gsl/gsl_rng.h>
151 #include <lal/LALStdlib.h>
152 #include <lal/LALConstants.h>
153 #include <lal/LALgetopt.h>
154 #include <lal/Date.h>
155 #include <lal/TimeSeries.h>
156 #include <lal/LALSimBurst.h>
159 #define STR(x) XSTR(x)
160 #define INVALID_DOUBLE (nan(""))
161 #define IS_INVALID_DOUBLE(x) (isnan(x))
162 #define DEFAULT_ECCENTRICITY 0
163 #define DEFAULT_PHASE 0
164 #define DEFAULT_SRATE 16384
167 #define verbose_output(...) (verbose ? fprintf(stderr, __VA_ARGS__) : 0)
170 static double my_atof(
const char *
s);
186 #define INIT_NAME(a) [a] = #a
199 [
BLTWNB] =
"band-limited white-noise burst",
205 [
Impulse] =
"delta-function impulse"
209 [
BLTWNB] =
"duration, frequency, bandwidth, eccentricity, phase, fluence",
213 [
SineGaussian] =
"quality-factor, frequency, hrss, eccentricity, phase",
231 int save_errno = errno;
235 val = strtod(
s, &endptr);
236 if (errno != 0 || *endptr !=
'\0') {
238 fprintf(stderr,
"error: could not parse string `%s' into a double\n",
s);
259 int main(
int argc,
char **argv)
272 fprintf(stderr,
"error: must specify valid waveform\n");
278 rng = gsl_rng_alloc(gsl_rng_default);
282 fprintf(stderr,
"error: must specify valid sample rate\n");
290 switch (
p.waveform) {
308 fprintf(stderr,
"error: must specify valid eccentricity in domain [0,1] for waveform `%s'\n",
waveform_names[
p.waveform]);
322 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
324 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
326 fprintf(stderr,
"warning: amplitude parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
328 fprintf(stderr,
"warning: hrss parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
331 double int_hdot_squared_dt;
339 verbose_output(
"%-31s %g (s^-1)\n",
"integral (dh/dt)^2 dt:", int_hdot_squared_dt);
340 verbose_output(
"%-31s GSL_RNG_TYPE=%s\n",
"GSL random number generator:", gsl_rng_name(rng));
341 verbose_output(
"%-31s GSL_RNG_SEED=%lu\n",
"GSL random number seed:", gsl_rng_default_seed);
360 fprintf(stderr,
"warning: duration parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
362 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
364 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
366 fprintf(stderr,
"warning: eccentricity parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
368 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
370 fprintf(stderr,
"warning: hrss parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
372 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
395 fprintf(stderr,
"warning: duration parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
397 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
399 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
401 fprintf(stderr,
"warning: eccentricity parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
403 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
405 fprintf(stderr,
"warning: hrss parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
407 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
426 fprintf(stderr,
"warning: frequency parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
428 fprintf(stderr,
"warning: duration parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
430 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
432 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
434 fprintf(stderr,
"warning: eccentricity parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
436 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
438 fprintf(stderr,
"warning: hrss parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
440 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
452 fprintf(stderr,
"error: must specify valid quality factor for waveform `%s'\n",
waveform_names[
p.waveform]);
464 fprintf(stderr,
"error: must specify valid eccentricity in domain [0,1] for waveform `%s'\n",
waveform_names[
p.waveform]);
474 fprintf(stderr,
"warning: duration parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
476 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
478 fprintf(stderr,
"warning: amplitude parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
480 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
485 verbose_output(
"%-31s %g (Hz^-1/2)\n",
"root-sum-squared strain:",
p.hrss);
505 fprintf(stderr,
"warning: frequency parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
507 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
509 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
511 fprintf(stderr,
"warning: eccentricity parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
513 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
515 fprintf(stderr,
"warning: amplitude parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
517 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
520 verbose_output(
"%-31s %g (Hz^-1/2)\n",
"root-sum-squared strain:",
p.hrss);
536 fprintf(stderr,
"warning: duration parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
538 fprintf(stderr,
"warning: frequency parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
540 fprintf(stderr,
"warning: bandwidth parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
542 fprintf(stderr,
"warning: quality-factor parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
544 fprintf(stderr,
"warning: eccentricity parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
546 fprintf(stderr,
"warning: phase parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
548 fprintf(stderr,
"warning: hrss parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
550 fprintf(stderr,
"warning: fluence parameter is set but ignored for waveform `%s'\n",
waveform_names[
p.waveform]);
553 verbose_output(
"%-31s %g (dimensionless)\n",
"amplitude:",
p.amplitude);
559 fprintf(stderr,
"error: unrecognized waveform\n");
574 tpeak = hplus->
epoch;
581 verbose_output(
"%-31s (h+, hx) = (%g, %g)\n",
"peak strain amplitude:", creal(hpeak), cimag(hpeak));
582 verbose_output(
"%-31s abs(h+, hx) = %g\n",
"peak strain amplitude:", cabs(hpeak));
583 verbose_output(
"%-31s arg(h+, hx) = %g (rad)\n",
"peak strain amplitude:", carg(hpeak));
601 fprintf(stdout,
"# time (s)\tH_PLUS (strain)\tH_CROSS (strain)\n");
614 "[default values in brackets]\n"
615 " -h, --help print this message and exit\n"
616 " -v, --verbose verbose output\n"
617 " -w WAVEFM, --waveform=WAVEFM the waveform to generate\n"
618 " -t DT, --duration=DT duration (seconds)\n"
619 " -f FREQ, --frequency=FREQ frequency (Hz)\n"
620 " -b BW, --bandwidth=BW bandwidth (Hz)\n"
621 " -q Q, --quality-factor=Q quality factor (dimensionless)\n"
624 " -A AMP, --amplitude=AMP amplitude (dimensionless or s^-1/3)\n"
625 " -H HRSS, --hrss=HRSS root-sum-squared amplitude (Hz^-1/2)\n"
626 " -F FLUENCE, --fluence=FLUENCE isotropic energy fluence (Msun c^2 pc^-2)\n"
627 " -R SRATE, --sample-rate=SRATE sample rate (Hz) [" STR(
DEFAULT_SRATE)
"]\n";
631 fprintf(stderr,
"waveforms supported:\n");
670 char args[] =
"hvw:t:f:b:q:e:A:H:F:d:R:";
673 int option_index = 0;
682 if (long_options[option_index].
flag)
685 fprintf(stderr,
"error parsing option %s with argument %s\n", long_options[option_index].
name, LALoptarg);
710 p.eccentricity =
my_atof(LALoptarg);
731 fprintf(stderr,
"unknown error while parsing options\n");
735 if (LALoptind < argc) {
736 fprintf(stderr,
"extraneous command line arguments:\n");
737 while (LALoptind < argc)
738 fprintf(stderr,
"%s\n", argv[LALoptind++]);
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
static int waveform_value(const char *waveform)
static int output(REAL8TimeSeries *hplus, REAL8TimeSeries *hcross)
int main(int argc, char **argv)
static struct params parseargs(int argc, char **argv)
static const char * waveform_long_names[NumWaveforms]
static double my_atof(const char *s)
static const char * waveform_parameters[NumWaveforms]
static const char * waveform_names[NumWaveforms]
static int usage(const char *program)
#define DEFAULT_ECCENTRICITY
#define verbose_output(...)
#define IS_INVALID_DOUBLE(x)
char * XLALGPSToStr(char *s, const LIGOTimeGPS *t)
int XLALSimBurstSineGaussian(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 Q, REAL8 centre_frequency, REAL8 hrss, REAL8 eccentricity, REAL8 phase, REAL8 delta_t)
Generate sine- and cosine-Gaussian waveforms with various polarizations and phases.
int XLALGenerateStringKinkKink(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 amplitude, REAL8 delta_t)
Generates cosmic string kink waveforms.
REAL8 XLALMeasureHrss(const REAL8TimeSeries *hplus, const REAL8TimeSeries *hcross)
Computes "root-sum-square strain", or .
int XLALGenerateBandAndTimeLimitedWhiteNoiseBurst(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 duration, REAL8 frequency, REAL8 bandwidth, REAL8 eccentricity, REAL8 phase, REAL8 int_hdot_squared, REAL8 delta_t, gsl_rng *rng)
Generate a band- and time-limited white-noise burst waveform with Gaussian envelopes in the time and ...
int XLALSimBurstGaussian(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 duration, REAL8 hrss, REAL8 delta_t)
Generate Gaussian waveforms.
REAL8 XLALMeasureEoverRsquared(REAL8TimeSeries *hplus, REAL8TimeSeries *hcross)
Computes the areal energy density carried by a gravitational wave.
int XLALGenerateImpulseBurst(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 hpeak, REAL8 delta_t)
Genereates a single-sample impulse waveform.
int XLALGenerateStringKink(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 amplitude, REAL8 f_high, REAL8 delta_t)
Generates cosmic string kink waveforms.
COMPLEX16 XLALMeasureHPeak(const REAL8TimeSeries *hplus, const REAL8TimeSeries *hcross, unsigned *index)
Return the strain of the sample with the largest magnitude.
int XLALGenerateStringCusp(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8 amplitude, REAL8 f_high, REAL8 delta_t)
Generates cosmic string cusp waveforms.
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)