int main(int argc, char *argv[]) { char tstr[32]; // string to hold GPS time -- 31 characters is enough const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); printf("# time (s)"); for (i = 0; i < numDetectors; ++i) { char name[LALNameLength]; snprintf(name, sizeof(name), "%s:STRAIN", detectors[i].frDetector.prefix); seg[i] = XLALCreateREAL8TimeSeries(name, &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); printf("\t%s (strain)", name); } printf("\n"); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points LIGOTimeGPS t = seg[0]->epoch; if (n == 0) // check if we're done goto end; printf("%s", XLALGPSToStr(tstr, XLALGPSAdd(&t, j * seg[0]->deltaT))); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }
int main(int argc, char *argv[]) { const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const double srate = 16384.0; // sampling rate in Hertz const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); for (i = 0; i < numDetectors; ++i) seg[i] = XLALCreateREAL8TimeSeries("STRAIN", &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop double t0 = XLALGPSGetREAL8(&seg[0]->epoch); size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points if (n == 0) // check if we're done goto end; printf("%.9f", t0 + j * seg[0]->deltaT); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }