Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInference 4.1.9.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALInferenceBurst.c
Go to the documentation of this file.
1/*
2 * InferenceNest.c: Nested Sampling using LALInference
3 *
4 * Copyright (C) 2009 Ilya Mandel, Vivien Raymond, Christian Roever, Marc van der Sluys and John Veitch
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with with program; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
23
24#include <config.h>
25#include <stdio.h>
26#include <string.h>
27#include <lal/Date.h>
28#include <lal/GenerateInspiral.h>
29#include <lal/LALInference.h>
30#include <lal/FrequencySeries.h>
31#include <lal/Units.h>
32#include <lal/StringInput.h>
33#include <lal/TimeSeries.h>
34#include <lal/LALInferenceNestedSampler.h>
35#include <lal/LALInferencePrior.h>
36#include <lal/LALInferenceReadData.h>
37#include <lal/LALInferenceLikelihood.h>
38#include <lal/LALInferenceTemplate.h>
39#include <lal/LALInferenceProposal.h>
40#include <lal/LALInferenceInit.h>
41#include <lal/LALInferenceReadBurstData.h>
42#include <lal/LALInferenceCalibrationErrors.h>
43#include <lal/GenerateBurst.h>
44#include <lal/LALSimBurst.h>
45
46/*************** MAIN **********************/
47
48
49int main(int argc, char *argv[]){
50 char help[]="\
51 LALInferenceNest:\n\
52 Bayesian analysis tool using Nested Sampling algorithm\n\
53 for Burst analysis. Uses LALInference library for back-end.\n\n\
54 Arguments for each section follow:\n\n";
55
57 ProcessParamsTable *procParams=NULL;
58 int helpflag=0;
59 /* Read command line and parse */
60 procParams=LALInferenceParseCommandLine(argc,argv);
61 if(LALInferenceGetProcParamVal(procParams,"--help"))
62 {
63 fprintf(stdout,"%s",help);
64 helpflag=1;
65 }
66
67 /* initialise runstate based on command line */
68 /* This includes reading in the data */
69 /* And performing any injections specified */
70 /* And allocating memory */
71 state = LALInferenceInitRunState(procParams);
72
74 if (!helpflag && (ppt=LALInferenceGetProcParamVal(state->commandLine,"--binj"))){
75 /* Perform injections if data successful read or created */
77 }
78 else{
79 /* Perform CBC injection if required */
80 if(!helpflag)
82 }
83 if (!helpflag && LALInferenceGetProcParamVal(state->commandLine,"--inject_from_mdc")){
84 fprintf(stdout,"WARNING: Injecting a signal from MDC has not been carefully tested yet! \n");
86 }
87
88 /* Simulate calibration errors.
89 * NOTE: this must be called after both ReadData and (if relevant)
90 * injectInspiralTD/FD are called! */
91 if(!helpflag) LALInferenceApplyCalibrationErrors(state->data, state->commandLine);
92 /* Set up the appropriate functions for the nested sampling algorithm */
93 if (state){
94 /* Set up the appropriate functions for the nested sampling algorithm */
97 INT4 one=1;
100 }
101
102 /* Check if recovery is LIB or CBC */
103 if (!helpflag && (ppt=LALInferenceGetProcParamVal(state->commandLine,"--approx"))){
105 /* Set up the threads */
107 /* Init the prior */
109 }
110 else{
111 /* Set up the threads */
113 /* Init the prior */
115 }
116 }
117 else{
118 fprintf(stderr,"Must specify the approximant while using lalinference_burst\n");
119 exit(1);
120 }
121 /* Set up structures for nested sampling */
123
124 for(INT4 i=0;i<state->nthreads;i++)
125 {
128 }
129
130 /* Choose the likelihood and set some auxiliary variables */
132
133 /* Exit since we printed all command line arguments */
134 if(state == NULL || LALInferenceGetProcParamVal(state->commandLine,"--help"))
135 {
136 exit(0);
137 }
138
139 /* Call setupLivePointsArray() to populate live points structures */
141
142 /* write injection with noise evidence information from algorithm */
143 // SALVO FIXME
144 //LALInferencePrintInjectionSample(state);
145
146 /* Call nested sampling algorithm */
147 state->algorithm(state);
148
149 /* end */
150 return(0);
151}
ProcessParamsTable * LALInferenceParseCommandLine(int argc, char *argv[])
int main(int argc, char *argv[])
int XLALCheckBurstApproximantFromString(const CHAR *inString)
void LALInferenceApplyCalibrationErrors(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
LALInferenceRunState * LALInferenceInitRunState(ProcessParamsTable *command_line)
void LALInferenceInitCBCThreads(LALInferenceRunState *run_state, INT4 nthreads)
void LALInferenceInitBurstThreads(LALInferenceRunState *run_state, INT4 nthreads)
void LALInferenceInjectInspiralSignal(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
ProcessParamsTable * ppt
#define fprintf
int32_t INT4
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.
Definition: LALInference.c:395
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
Definition: LALInference.h:130
@ LALINFERENCE_INT4_t
Definition: LALInference.h:105
void LALInferenceInitLikelihood(LALInferenceRunState *runState)
Initialisation function which reads runState->commaneLine and sets up the likelihood function accordi...
void LALInferenceNestedSamplingAlgorithm(LALInferenceRunState *runState)
NestedSamplingAlgorithm implements the nested sampling algorithm, see e.g.
INT4 LALInferenceNestedSamplingOneStep(LALInferenceRunState *runState)
A single iteration of the NS algorithm.
void LALInferenceSetupLivePointsArray(LALInferenceRunState *runState)
Setup the live points by calling runState->initVariables on each of them if it is specified.
void LALInferenceNestedSamplingAlgorithmInit(LALInferenceRunState *runState)
Initialise the nested sampling algorithm by reading from the commandLine and setting up algorithmPara...
void LALInferenceInitCBCPrior(LALInferenceRunState *runState)
Initialize the prior based on command line arguments.
void LALInferenceInitLIBPrior(LALInferenceRunState *runState)
Initialize the LIB prior based on command line arguments.
LALInferenceProposalCycle * LALInferenceSetupDefaultInspiralProposalCycle(LALInferenceVariables *propArgs)
A reasonable default proposal.
LALInferenceVariables * LALInferenceParseProposalArgs(LALInferenceRunState *runState)
Go through all logic for deciding proposals to use.
void LALInferenceRandomizeProposalCycle(LALInferenceProposalCycle *cycle, gsl_rng *rng)
Randomizes the order of the proposals in the proposal cycle.
void LALInferenceInjectBurstSignal(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
Read IFO data according to command line arguments.
void LALInferenceInjectFromMDC(ProcessParamsTable *commandLine, LALInferenceIFOData *IFOdata)
help
Structure containing inference run state This includes pointers to the function types required to run...
Definition: LALInference.h:592
ProcessParamsTable * commandLine
Definition: LALInference.h:593
LALInferenceVariables * proposalArgs
The data from the interferometers.
Definition: LALInference.h:602
LALInferenceVariables * algorithmParams
Any special arguments for the prior function.
Definition: LALInference.h:604
INT4 nthreads
Array of live points for Nested Sampling.
Definition: LALInference.h:606
struct tagLALInferenceIFOData * data
Log sample, i.e.
Definition: LALInference.h:601
LALInferenceThreadState * threads
Definition: LALInference.h:612
LALInferenceAlgorithm algorithm
A function that returns a new set of variables for the model.
Definition: LALInference.h:595
LALInferenceEvolveOneStepFunction evolve
The algorithm function.
Definition: LALInference.h:596
LALInferenceProposalCycle * cycle
The proposal cycle.
Definition: LALInference.h:547
LALInferenceVariables * proposalArgs
Definition: LALInference.h:551
CHAR value[LIGOMETA_VALUE_MAX]