Commit 2afe7f3c authored by John Douglas Veitch's avatar John Douglas Veitch

Store injection sample in HDF5 file

parent c9243f16
......@@ -19,6 +19,7 @@
#include <lal/LALInferencePrior.h>
#include <lal/LALInferenceLikelihood.h>
#include <lal/LALInferenceProposal.h>
#include <lal/LALInferenceReadData.h>
#include <lal/LALInferenceHDF5.h>
#include <lal/LALInferencePriorVolumes.h>
......@@ -1175,6 +1176,13 @@ void LALInferenceNestedSamplingAlgorithm(LALInferenceRunState *runState)
XLALH5FileAddScalarAttribute(groupPtr, "number_live_points", &Nlive, LAL_U4_TYPE_CODE);
XLALH5FileAddScalarAttribute(groupPtr, "log_prior_volume", &logvolume, LAL_D_TYPE_CODE);
LALInferenceVariables *injParams = NULL;
if ( (injParams=LALInferencePrintInjectionSample(runState)) )
{
LALInferenceH5VariablesArrayToDataset(groupPtr, &injParams, 1, "injection_params");
LALInferenceClearVariables(injParams);
XLALFree(injParams);
}
XLALH5FileClose(h5file);
}
......
......@@ -2094,7 +2094,7 @@ void LALInferenceInjectionToVariables(SimInspiralTable *theEventTable, LALInfere
}
void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
LALInferenceVariables *LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
int errnum=0;
char *fname=NULL;
char defaultname[]="injection_params.dat";
......@@ -2113,7 +2113,7 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
ProcessParamsTable *ppt = LALInferenceGetProcParamVal(runState->commandLine,"--inj");
if (!ppt)
return;
return(NULL);
SimInspiralTableFromLIGOLw(&injTable, ppt->value, 0, 0);
......@@ -2144,7 +2144,7 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
if (!(approx && order)){
fprintf(stdout,"Unable to print injection sample: No approximant/PN order set\n");
return;
return(NULL);
}
/* Fill named variables */
LALInferenceInjectionToVariables(theEventTable, injparams);
......@@ -2180,9 +2180,8 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
LALInferencePrintSample(outfile, injparams);
fclose(outfile);
LALInferenceClearVariables(injparams);
XLALFree(injparams);
return;
//LALInferenceClearVariables(injparams);
return(injparams);
}
void enforce_m1_larger_m2(SimInspiralTable* injEvent){
......
......@@ -66,7 +66,7 @@ void LALInferenceInjectionToVariables(SimInspiralTable *theEventTable, LALInfere
* \brief Function to output a sample with logL values etc for the injection, if one is made.
* Requires --inj, --outfile and optionally --event (if not 0).
*/
void LALInferencePrintInjectionSample(LALInferenceRunState *runState);
LALInferenceVariables *LALInferencePrintInjectionSample(LALInferenceRunState *runState);
void LALInferenceInjectFromMDC(ProcessParamsTable *commandLine, LALInferenceIFOData *IFOdata);
/*@}*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment