JohannesBuchner / BXA

Bayesian X-ray analysis (nested sampling for Xspec and Sherpa)
https://johannesbuchner.github.io/BXA/
GNU General Public License v3.0
57 stars 19 forks source link

Fix bug of identity response matrices for PCA background models in Sherpa #55

Closed ruizca closed 6 months ago

ruizca commented 6 months ago

There seems to be a problem in the identity response matrices created for fitting the PCA background models with Sherpa. While they work fine with the PCA model itself, when applied to a gaussian model they return null values for all channels. This causes that any additional gaussian components included into the baseline PCA model are always rejected.

This PR fixes this issue, by using the create_delta_rmf and create_arf functions included in Sherpa. I have tested the new code with XMM, Chandra, Swift, Suzaku, NuSTAR and eROSITA data, and everything seems to work ok. The new script test_auto_background.py runs a battery of test: first, they check that the PCA model parameters obtained without including additional gaussian lines are the same as in the original code (the original values are stored in json files in the corresponding folders); second, a high count excess is injected into the background spectrum at a given channel and check that the new code is able to model that excess with a gaussian line.

JohannesBuchner commented 6 months ago

Thank you, Angel. This should be fixed now and there is a new release of BXA (4.1.4). Please test it and let me know if it works.

ruizca commented 6 months ago

I've tested the new BXA version and everything seems to work fine.

I was wondering if it should be mentioned somewhere that if you update, and run again an old fit, things could change (the new auto_background code could find significant lines in the background spectrum that were previously rejected). It is possible to recover the old results if you run the auto_background function with max_lines=0.

JohannesBuchner commented 6 months ago

Good point. I added it to the Release notes https://johannesbuchner.github.io/BXA/history.html