Commit 264bf3bc authored by John Douglas Veitch's avatar John Douglas Veitch

Store injection sample in HDF5 file

parent 0719a93c
......@@ -21,6 +21,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>
......@@ -1209,6 +1210,13 @@ void LALInferenceNestedSamplingAlgorithm(LALInferenceRunState *runState)
XLALH5FileAddScalarAttribute(groupPtr, "cpu_time", &execution_time, LAL_D_TYPE_CODE);
}
LALInferenceVariables *injParams = NULL;
if ( (injParams=LALInferencePrintInjectionSample(runState)) )
{
LALInferenceH5VariablesArrayToDataset(groupPtr, &injParams, 1, "injection_params");
LALInferenceClearVariables(injParams);
XLALFree(injParams);
}
XLALH5FileClose(h5file);
}
......
......@@ -2190,7 +2190,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";
......@@ -2209,7 +2209,7 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
ProcessParamsTable *ppt = LALInferenceGetProcParamVal(runState->commandLine,"--inj");
if (!ppt)
return;
return(NULL);
SimInspiralTableFromLIGOLw(&injTable, ppt->value, 0, 0);
......@@ -2240,7 +2240,7 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
if (!(approx && order)){
fprintf(stdout,"Unable to print injection sample: No approximant/PN order set\n");
return;
return(NULL);
}
REAL8 fref = 100.;
......@@ -2294,9 +2294,8 @@ void LALInferencePrintInjectionSample(LALInferenceRunState *runState) {
LALInferencePrintSample(outfile, injparams);
fclose(outfile);
LALInferenceClearVariables(injparams);
XLALFree(injparams);
return;
//LALInferenceClearVariables(injparams);
return(injparams);
}
int 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