xpsi-group / xpsi

X-PSI: X-ray Pulse Simulation and Inference
Other
34 stars 21 forks source link

Better error handling for background marginalisation #353

Closed thjsal closed 7 months ago

thjsal commented 9 months ago

Some checks should be added to https://github.com/xpsi-group/xpsi/blob/main/xpsi/likelihoods/default_background_marginalisation.pyx to make sure that the given background support fulfills the conditions that are required from it, and an error message should be raised if not.

It would be good to check that the length of the background vector is the same as the energy dimension of the model/data arrays, e.g. like this:

if(components[0].shape[0]!=support[0].shape[0]):
    raise TypeError('The length of the background support does not match the length of the model/data.') 

Currently, providing a background vector with the wrong size does not produce any errors, but only causes sporadic problems in the GSL integration over the background.

We should also add a check to ensure the background upper limit is non-zero and always larger than the lower limit.