00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <string.h>
00032 #include <gsl/gsl_rng.h>
00033 #include <lal/Date.h>
00034 #include <lal/GenerateBurst.h>
00035 #include <lal/LALConstants.h>
00036 #include <lal/LALDatatypes.h>
00037 #include <lal/LALDetectors.h>
00038 #include <lal/LALSimBurst.h>
00039 #include <lal/LALSimulation.h>
00040 #include <lal/LIGOMetadataTables.h>
00041 #include <lal/TimeSeries.h>
00042
00043
00044 NRCSID(GENERATEBURSTC, "$Id: GenerateBurst.c,v 1.52 2008/08/26 21:34:04 kipp Exp $");
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 int XLALGenerateSimBurst(
00064 REAL8TimeSeries **hplus,
00065 REAL8TimeSeries **hcross,
00066 const SimBurst *sim_burst,
00067 double delta_t
00068 )
00069 {
00070 static const char func[] = "XLALGenerateSimBurst";
00071
00072 if(!strcmp(sim_burst->waveform, "BTLWNB")) {
00073
00074
00075
00076
00077
00078
00079
00080
00081 double int_hdot_squared_dt = sim_burst->egw_over_rsquared * LAL_MSUN_SI * 4 * LAL_G_SI / LAL_C_SI / LAL_PC_SI / LAL_PC_SI;
00082
00083
00084
00085 gsl_rng *rng = gsl_rng_alloc(gsl_rng_mt19937);
00086
00087 if(!rng)
00088 XLAL_ERROR(func, XLAL_ENOMEM);
00089 gsl_rng_set(rng, sim_burst->waveform_number);
00090
00091 XLALPrintInfo("%s(): BTLWNB: f = %.16g Hz, df = %.16g Hz, dt = %.16g s, hdot^2 = %.16g\n", func, sim_burst->frequency, sim_burst->bandwidth, sim_burst->duration, int_hdot_squared_dt);
00092 if(XLALGenerateBandAndTimeLimitedWhiteNoiseBurst(hplus, hcross, sim_burst->duration, sim_burst->frequency, sim_burst->bandwidth, int_hdot_squared_dt, delta_t, rng)) {
00093 gsl_rng_free(rng);
00094 XLAL_ERROR(func, XLAL_EFUNC);
00095 }
00096 gsl_rng_free(rng);
00097 } else if(!strcmp(sim_burst->waveform, "StringCusp")) {
00098 XLALPrintInfo("%s(): string cusp: A = %.16g, fhigh = %.16g Hz\n", func, sim_burst->amplitude, sim_burst->frequency);
00099 if(XLALGenerateStringCusp(hplus, hcross, sim_burst->amplitude, sim_burst->frequency, delta_t))
00100 XLAL_ERROR(func, XLAL_EFUNC);
00101 } else if(!strcmp(sim_burst->waveform, "SineGaussian")) {
00102 XLALPrintInfo("%s(): sine-Gaussian: f = %.16g Hz, Q = %.16g, hrss = %.16g\n", func, sim_burst->frequency, sim_burst->q, sim_burst->hrss);
00103 if(XLALSimBurstSineGaussian(hplus, hcross, sim_burst->q, sim_burst->frequency, sim_burst->hrss, sim_burst->pol_ellipse_e, sim_burst->pol_ellipse_angle, delta_t))
00104 XLAL_ERROR(func, XLAL_EFUNC);
00105 } else {
00106
00107 XLALPrintError("%s(): error: unrecognized waveform\n", func);
00108 XLAL_ERROR(func, XLAL_EINVAL);
00109 }
00110
00111
00112
00113 return 0;
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 int XLALBurstInjectSignals(
00125 REAL8TimeSeries *series,
00126 const SimBurst *sim_burst,
00127 const COMPLEX16FrequencySeries *response
00128 )
00129 {
00130 static const char func[] = "XLALBurstInjectSignals";
00131
00132 const LALDetector *detector;
00133
00134 LALDetector detector_copy;
00135
00136 REAL8TimeSeries *hplus, *hcross;
00137
00138 REAL8TimeSeries *h;
00139
00140
00141 const double injection_window = 600.0;
00142
00143
00144
00145
00146 detector = XLALInstrumentNameToLALDetector(series->name);
00147 if(!detector)
00148 XLAL_ERROR(func, XLAL_EFUNC);
00149 XLALPrintInfo("%s(): channel name is '%s', instrument appears to be '%s'\n", func, series->name, detector->frDetector.prefix);
00150 detector_copy = *detector;
00151
00152
00153
00154 for(; sim_burst; sim_burst = sim_burst->next) {
00155
00156
00157
00158 if(XLALGPSDiff(&series->epoch, &sim_burst->time_geocent_gps) > injection_window || XLALGPSDiff(&sim_burst->time_geocent_gps, &series->epoch) > (series->data->length * series->deltaT + injection_window))
00159 continue;
00160
00161
00162
00163
00164
00165 if(XLALGenerateSimBurst(&hplus, &hcross, sim_burst, series->deltaT))
00166 XLAL_ERROR(func, XLAL_EFUNC);
00167
00168
00169
00170
00171
00172
00173 XLALGPSAddGPS(&hcross->epoch, &sim_burst->time_geocent_gps);
00174 XLALGPSAddGPS(&hplus->epoch, &sim_burst->time_geocent_gps);
00175
00176
00177
00178
00179 h = XLALSimDetectorStrainREAL8TimeSeries(hplus, hcross, sim_burst->ra, sim_burst->dec, sim_burst->psi, &detector_copy);
00180 XLALDestroyREAL8TimeSeries(hplus);
00181 XLALDestroyREAL8TimeSeries(hcross);
00182 if(!h)
00183 XLAL_ERROR(func, XLAL_EFUNC);
00184
00185
00186
00187
00188 if(XLALSimAddInjectionREAL8TimeSeries(series, h, response)) {
00189 XLALDestroyREAL8TimeSeries(h);
00190 XLAL_ERROR(func, XLAL_EFUNC);
00191 }
00192 XLALDestroyREAL8TimeSeries(h);
00193 }
00194
00195
00196
00197 return 0;
00198 }