igmhub / baofit

Fits cosmological data to measure baryon acoustic oscillations.
9 stars 5 forks source link

Improve reporting of failed multipole integrals #12

Open dkirkby opened 10 years ago

dkirkby commented 10 years ago

A k-space model can fail if the 1D k-space multipole integral fails. Nicolas has seen an example of this in a chisq scan. Currently this integral is done using integrateSmooth in cosmo/TransferFunctionPowerSpectrum.cc:

double local::getMultipole(likely::GenericFunctionPtr fOfMuPtr, int ell, double epsAbs, double epsRel) {
    MultipoleIntegrand multipoleIntegrand(fOfMuPtr,ell);
    likely::Integrator::IntegrandPtr integrand(new likely::Integrator::Integrand(
        boost::ref(multipoleIntegrand)));
    likely::Integrator integrator(integrand,epsAbs,epsRel);
    // Factor of two is because we integrate over 0 < mu < 1 instead of -1 < mu < +1.
    return 2*integrator.integrateSmooth(0,1);
}

Should catch the resulting cosmo::RuntimeError and give a more useful error message.

dkirkby commented 10 years ago

Catch any std::runtime_error when fitting for a scan-point and keep going (saving the initial best-fit parameter values updated for this scan point and a chisq value of zero).

A better solution might be to make the getMultipole integrator more robust. To be revisited if this continues to be a problem (after applying reasonable priors on beta, etc).

dkirkby commented 10 years ago

TODO: Print number of failed fits at the end of the scan.