cositools / cosipy

The COSI high-level data analysis tools
Apache License 2.0
3 stars 16 forks source link

Suppress warning in likelihood calculation #59

Open israelmcmc opened 1 year ago

israelmcmc commented 1 year ago

https://github.com/cositools/cosipy/blob/f9f6043b2843bf25e716cf93a7f7f788d905883b/cosipy/threeml/COSILike.py#L154

In newer version we use nansum, which handles the nan, but it would be better to not have then in the first place (by handling the limit of special values appropriately)

israelmcmc commented 1 month ago

I think this is still an issue. There was a patch that solved the issue temporarily:

https://github.com/cositools/cosipy/blob/7c660b5d551669bfd2dde942cece13585156e5aa/cosipy/threeml/COSILike.py#L133-L135

israelmcmc commented 1 month ago

I think these lines are also related: https://github.com/cositools/cosipy/blob/7c660b5d551669bfd2dde942cece13585156e5aa/cosipy/threeml/COSILike.py#L302-L306

Part of the issue is due to the detector response and the background estimation being too sparse due to limited statistics and lack of interpolation/smoothing. There should never be a case where the total expectation (background + signal) is 0 and the data is non-zero, as it is unphysical. For this case, it's OK to raise a warning, but only 1 instance of the warning is sufficient --i.e. do not fill the logs with the same warning.

However, the code should handle cases where both (the data and the total expectation)are 0 without any warnings.