25#include <lal/GenerateInspiral.h>
26#include <lal/LALInference.h>
27#include <lal/FrequencySeries.h>
29#include <lal/StringInput.h>
30#include <lal/TimeSeries.h>
31#include <lal/LALInferencePrior.h>
32#include <lal/LALInferenceTemplate.h>
33#include <lal/LALInferenceProposal.h>
34#include <lal/LALInferenceLikelihood.h>
35#include <lal/LALInferenceReadData.h>
36#include <lal/LALInferenceReadBurstData.h>
37#include <lal/LALInferenceInit.h>
38#include <lal/GenerateBurst.h>
39#include <lal/LALSimBurst.h>
40#include <lal/LALInferenceCalibrationErrors.h>
41#include <lal/LALInferenceInit.h>
42#include <lal/LIGOLwXMLRead.h>
62 for (t = 0; t < nthreads; t++) {
63 thread = &(run_state->
threads[t]);
70 while (
data != NULL) {
85 if ((devrandom = fopen(
"/dev/urandom",
"r")) == NULL) {
87 randomseed = tv.tv_sec + tv.tv_usec;
89 fread(&randomseed,
sizeof(randomseed), 1, devrandom);
93 thread->
GSLrandom=gsl_rng_alloc(gsl_rng_mt19937);
94 gsl_rng_set(thread->
GSLrandom, randomseed + t);
103 char help[]=
"(--approx [SineGaussian,SineGaussianF,Gaussian,GaussianF,RingdownF]\tSpecify approximant to use (default SineGaussianF)\n";
128 fprintf(stdout,
"Using fast sine gaussian frequency domain likelihood.\n WARNING: this disables most of the extra features like marginalization. Also assumes you are using a SineGaussianF template and know what you are doing. Be careful\n");
131 fprintf(stderr,
"ERROR: can only use fastSineGaussianLikelihood with SineGaussianF approximants.\n");
145 ------------------------------------------------------------------------------------------------------------------\n\
146 --- Injection Arguments ------------------------------------------------------------------------------------------\n\
147 ------------------------------------------------------------------------------------------------------------------\n\
148 (--inj injections.xml) Sim Burst XML file to use.\n\
149 (--event N) Event number from Injection XML file to use.\n\
151 ------------------------------------------------------------------------------------------------------------------\n\
152 --- Template Arguments -------------------------------------------------------------------------------------------\n\
153 ------------------------------------------------------------------------------------------------------------------\n\
154 (--use-hrss) Jump in hrss instead than loghrss.\n\
155 --approx Specify a burst template approximant to use.\n\
156 Available approximants:\n\
157 modeldomain=\"time\": SineGaussian,Gaussian,DumpedSinusoidal.\n\
158 default modeldomain=\"frequency\": SineGaussianF,GaussianF,DumpedSinusoidalF.\n\
160 ------------------------------------------------------------------------------------------------------------------\n\
161 --- Starting Parameters ------------------------------------------------------------------------------------------\n\
162 ------------------------------------------------------------------------------------------------------------------\n\
163 You can generally have MCMC chains to start from a given parameter value by using --parname VALUE. Names currently known to the code are:\n\
164 time Waveform time (overrides random about trigtime).\n\
165 frequency Central frequency [Hz], (not used for Gaussian WF).\n\
166 quality Quality factor for SG and DumpedSin \n\
167 duration Duration [s] (Gaussian WF only)\n\
168 hrss hrss (requires --use-hrss)\n\
170 rightascension Rightascensions\n\
171 declination Declination.\n\
172 polarisation Polarisation angle.\n\
173 \n ------------------------------------------------------------------------------------------------------------------\n\
174 --- Prior Arguments ----------------------------------------------------------------------------------------------\n\
175 ------------------------------------------------------------------------------------------------------------------\n\
176 You can generally use --paramname-min MIN --paramname-max MAX to set the prior range for the parameter paramname\n\
177 The names known to the code are listed below.\n\
178 Time has dedicated options listed here:\n\n\
179 (--trigtime time) Center of the prior for the time variable.\n\
180 (--dt time) Width of time prior, centred around trigger (0.2s).\n\
181 (--malmquistPrior) Rejection sample based on SNR of template \n\
183 (--varyFlow, --flowMin, --flowMax) Allow the lower frequency bound of integration to vary in given range.\n\
184 (--pinparams) List of parameters to set to injected values [frequency,quality,etc].\n\
185 ------------------------------------------------------------------------------------------------------------------\n\
186 --- Fix Parameters ----------------------------------------------------------------------------------------------\n\
187 ------------------------------------------------------------------------------------------------------------------\n\
188 You can generally fix a parameter to be fixed to a given values by using both --paramname VALUE and --fix-paramname\n\
189 where the known names have been listed above\n\
190 ------------------------------------------------------------------------------------------------------------------\n\
191 --- Spline Calibration Model -------------------------------------------------------------------------------------\n\
192 ------------------------------------------------------------------------------------------------------------------\n\
193 (--enable-spline-calibration) Enable cubic-spline calibration error model.\n\
194 (--spline-calibration-nodes N) Set the number of spline nodes per detector (default 5)\n\
195 (--spline-calibration-amp-uncertainty X) Set the prior on relative amplitude uncertainty (default 0.1)\n\
196 (--spline-calibration-phase-uncertainty X) Set the prior on phase uncertanity in degrees (default 5)\n";
225 fprintf(stderr,
"Using LALInferenceBurstVariables!\n");
231 REAL8 endtime_from_inj=-1;
237 char *pinned_params=NULL;
246 if(
ppt)signal_flag=0;
251 UINT4 malmquistflag=1;
270 fprintf(stdout,
"WARNING: You did not provide an event number with you --binj. Using default event=0 which may not be what you want!!!!\n");
286 fprintf(stdout,
"WARNING: You did not provide an event number with you --inj. Using default event=0 which may not be what you want!!!!\n");
289 if(!(BinjTable || inj_table || endtime>=0.0 )){
290 printf(
"Did not provide --trigtime or an xml file and event... Exiting.\n");
293 if (endtime_from_inj!=endtime){
294 if(endtime_from_inj>0 && endtime>0)
295 fprintf(stderr,
"WARNING!!! You set trigtime %lf with --trigtime but event %i seems to trigger at time %lf\n",endtime,
event,endtime_from_inj);
296 else if(endtime_from_inj>0)
297 endtime=endtime_from_inj;
303 memset(&tempParams,0,
sizeof(tempParams));
312 char *
name=strings[
N];
315 else {
fprintf(stderr,
"Error: Cannot pin parameter %s. No such parameter found in injection!\n",
name);}
334 fprintf(stderr,
"ERROR. Unknown approximant number %i. Unable to choose time or frequency domain model.",
approx);
344 REAL8 qMin=3., qMax=100.0;
345 REAL8 ffMin=40., ffMax=1024.0;
348 REAL8 hrssMin=1.e-23, hrssMax=1.0e-15;
349 REAL8 loghrssMin=log(hrssMin),loghrssMax=log(hrssMax);
355 REAL8 timeParam = timeMin + (timeMax-timeMin)*gsl_rng_uniform(GSLrandom);
359 timeMin=endtime-
dt; timeMax=endtime+
dt;
360 timeParam = timeMin + (timeMax-timeMin)*gsl_rng_uniform(GSLrandom);
366 printf(
"Using detector-based sky frame\n");
393 fprintf(stderr,
"ERROR: cannot use margphi or margtimephi with burst approximants. Please use margtime or no marginalization\n");
398 if (!strcmp(
"SineGaussian",
ppt->
value) || !strcmp(
"SineGaussianF",
ppt->
value)|| !strcmp(
"DampedSinusoid",
ppt->
value) || !strcmp(
"DampedSinusoidF",
ppt->
value)){
403 else if (!strcmp(
"Gaussian",
ppt->
value) || !strcmp(
"GaussianF",
ppt->
value)){
423 model->
deltaT = state->
data->timeData->deltaT;
424 model->
deltaF = state->
data->freqData->deltaF;
427 while (dataPtr != NULL)
429 dataPtr = dataPtr->
next;
434 &(state->
data->timeData->epoch),
438 state->
data->timeData->data->length);
440 &(state->
data->timeData->epoch),
444 state->
data->timeData->data->length);
446 &(state->
data->freqData->epoch),
450 state->
data->freqData->data->length);
452 &(state->
data->freqData->epoch),
456 state->
data->freqData->data->length);
483 char *pinned_params=NULL;
488 memset(&tempParams,0,
sizeof(tempParams));
496 while (dataPtr != NULL)
498 dataPtr = dataPtr->
next;
507 struct varSettings {
const char *
name;
REAL8 val, min,
max;};
509 struct varSettings setup[]=
511 {.name=
"time", .val=0.001, .min=-0.006410, .max=0.008410},
512 {.name=
"frequency", .val=210., .min=205.560916, .max=216.439084},
513 {.name=
"quality", .val=6.03626, .min=5.252647, .max=6.747353},
514 {.name=
"loghrss", .val=-46., .min=-46.964458, .max=-45.035542},
515 {.name=
"polarisation", .val=0.73, .min=0.425622, .max=0.974378},
516 {.name=
"rightascension", .val=
LAL_PI, .min=2.864650, .max=3.418535},
517 {.name=
"declination", .val=0.04, .min=-0.306437, .max=0.306437},
518 {.name=
"polar_angle", .val=0.58, .min=0.224279, .max=0.775721},
519 {.name=
"polar_eccentricity",.val=0.3,.min=0.0760747287,.max=0.4239252713},
520 {.name=
"END", .val=0., .min=0., .max=0.}
523 while(strcmp(
"END",setup[
i].
name))
539 char *pinned_params=NULL;
544 memset(&tempParams,0,
sizeof(tempParams));
551 while (dataPtr != NULL)
553 dataPtr = dataPtr->
next;
560 struct varSettings {
const char *
name;
REAL8 val, min,
max;};
562 struct varSettings setup[]=
564 {.name=
"time", .val=0.0061, .min= -0.006410, .max=0.020266},
565 {.name=
"frequency", .val=215., .min=205.560916, .max=225.141619},
566 {.name=
"quality", .val=6.50, .min=5.252647, .max=7.943119},
567 {.name=
"loghrss", .val=-45., .min=-46.964458, .max=-43.492410},
568 {.name=
"polarisation", .val=0.93, .min=0.425622,.max=1.413383},
569 {.name=
"rightascension", .val=
LAL_PI, .min=2.864650, .max=3.861644},
570 {.name=
"declination", .val=0.0, .min=-0.306437, .max=0.796736},
571 {.name=
"polar_angle", .val=0.75, .min=0.224279, .max=1.216874},
572 {.name=
"polar_eccentricity",.val=0.4,.min=0.076075,.max=0.702206},
573 {.name=
"END", .val=0., .min=0., .max=0.}
575 while(strcmp(
"END",setup[
i].
name))
int XLALSimBurstImplementedTDApproximants(BurstApproximant approximant)
int XLALGetBurstApproximantFromString(const CHAR *inString)
XLAL function to determine burst approximant from a string.
LALSimBurstWaveformCache * XLALCreateSimBurstWaveformCache(void)
Construct and initialize a waveform cache.
int XLALSimBurstImplementedFDApproximants(BurstApproximant approximant)
Checks whether the given approximant is implemented in lalsimulation's XLALSimInspiralChooseFDWavefor...
BurstApproximant
Enum that specifies the PN approximant to be used in computing the waveform.
void LALInferenceRegisterUniformVariableREAL8(LALInferenceRunState *state, LALInferenceVariables *var, const char *name, REAL8 startval, REAL8 min, REAL8 max, LALInferenceParamVaryType varytype)
Register a variable in vars for the model with given name, and a uniform prior.
void LALInferenceInitCalibrationVariables(LALInferenceRunState *runState, LALInferenceVariables *currentParams)
LALInferenceModel * LALInferenceInitModelReviewBurstEvidence_bimod(LALInferenceRunState *state)
LALInferenceModel * LALInferenceInitBurstModel(LALInferenceRunState *state)
Initialise state variables needed for LALInferenceNest or LALInferenceMCMC to run on a CBC signal.
LALInferenceModel * LALInferenceInitModelReviewBurstEvidence_unimod(LALInferenceRunState *state)
LALInferenceTemplateFunction LALInferenceInitBurstTemplate(LALInferenceRunState *runState)
Initialise the template for a standard burst signal.
void LALInferenceInitBurstThreads(LALInferenceRunState *run_state, INT4 nthreads)
LALInferenceVariables currentParams
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
Add a variable named name to vars with initial value referenced by value.
LALInferenceThreadState * LALInferenceInitThreads(INT4 nthreads)
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
Remove name from vars Frees the memory for the name structure and its contents.
LALInferenceParamVaryType
An enumerated type for denoting the topology of a parameter.
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
Deep copy the variables from one to another LALInferenceVariables structure.
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
LALInferenceVariableItem * LALInferenceGetItem(const LALInferenceVariables *vars, const char *name)
Return the list node for "name" - do not rely on this.
void(* LALInferenceTemplateFunction)(struct tagLALInferenceModel *model)
Type declaration for template function, which operates on a LALInferenceIFOData structure *data.
void LALInferenceParseCharacterOptionString(char *input, char **strings[], UINT4 *n)
parses a character string (passed as one of the options) and decomposes it into individual parameter ...
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
@ LALINFERENCE_PARAM_CIRCULAR
A parameter that simply has a maximum and a minimum.
@ LALINFERENCE_PARAM_LINEAR
void LALInferenceBurstInjectionToVariables(SimBurst *theEventTable, LALInferenceVariables *vars)
Fill the variables passed in vars with the parameters of the injection passed in event will over-writ...
void LALInferenceTemplateXLALSimBurstSineGaussianF(LALInferenceModel *model)
void LALInferenceTemplateXLALSimBurstChooseWaveform(LALInferenceModel *model)
void LALInferenceTemplateXLALSimInspiralChooseWaveform(LALInferenceModel *model)
"XLALSimInspiralChooseWaveform{TD,FD}" wrapper.
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalDimensionlessUnit
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
Structure to contain IFO data.
struct tagLALInferenceIFOData * next
ROQ data.
Structure to constain a model and its parameters.
REAL8 * ifo_loglikelihoods
Network SNR at params
REAL8 * ifo_SNRs
Array of single-IFO likelihoods at params
REAL8FFTPlan * timeToFreqFFTPlan
Burst Waveform cache for LIB.
COMPLEX16FrequencySeries * freqhPlus
Time series model buffers.
REAL8TimeSeries * timehCross
LALSimBurstWaveformCache * burstWaveformCache
Waveform cache.
REAL8TimeSeries * timehPlus
LALInferenceVariables * params
REAL8 deltaT
End frequency for waveform generation.
COMPLEX16FrequencySeries * freqhCross
REAL8FFTPlan * freqToTimeFFTPlan
REAL8Window * window
Pre-calculated FFT plans for forward and reverse FFTs.
LALInferenceTemplateFunction templt
Domain of model.
LALSimulationDomain domain
IFO-dependent parameters and buffers.
Structure containing inference run state This includes pointers to the function types required to run...
ProcessParamsTable * commandLine
LALInferenceVariables * proposalArgs
The data from the interferometers.
INT4 nthreads
Array of live points for Nested Sampling.
struct tagLALInferenceIFOData * data
Log sample, i.e.
LALInferenceVariables * priorArgs
Common arguments needed by proposals, to be copied to thread->cycle.
LALInferenceThreadState * threads
Structure containing chain-specific variables.
LALInferenceVariables * currentParams
Prior boundaries, etc.
LALInferenceVariables * priorArgs
Stope things such as output arrays.
LALInferenceModel * model
Cycle of proposals to call.
REAL8 * currentIFOLikelihoods
Array storing single-IFO SNRs of current sample.
LALInferenceVariables * proposalArgs
The LALInferenceVariableItem list node structure This should only be accessed using the accessor func...
LALInferenceVariableType type
LALInferenceParamVaryType vary
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
CHAR value[LIGOMETA_VALUE_MAX]
struct tagSimBurst * next
LIGOTimeGPS time_geocent_gps
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next