VERITAS-Observatory / gammapy-tools

Repository with tools for gammapy analysis
GNU General Public License v3.0
2 stars 0 forks source link

Unable to produce significance distributions for > 2.5 deg maps #44

Closed samanthalwong closed 4 months ago

samanthalwong commented 4 months ago

Related to issue #43, when the OFF significance distribution is plotted as significance_off[exclusion_mask.data.flatten()] and I'm making a map larger than 2.5 deg, I get the following error while running rbm_plots (in rbm.py), which has to do with array shape differences between significance_off and exclusion_mask.data:

IndexError: boolean index did not match indexed array along dimension 0; dimension is 89904 but corresponding boolean dimension is 90000

I can't find anywhere where exclusion_mask.data is being defined as a larger array than the map size (and only for larger maps). This might not be an actual issue but it's been driving me crazy and I would appreciate another set of eyes to figure out why this is happening.

Right now it's an either/or situation for whether I can get a significance distribution or a map showing the full FoV, which is not ideal.

steob92 commented 4 months ago

Is the error related to these two lines: https://github.com/VERITAS-Observatory/gammapy-tools/blob/ba7bd0a8ee0d15e2bc22d9ee33a280a71be8a59e/gammapy_tools/analysis/rbm.py#L305

The above will return an array with shape equal to wherever we have finite data.

https://github.com/VERITAS-Observatory/gammapy-tools/blob/ba7bd0a8ee0d15e2bc22d9ee33a280a71be8a59e/gammapy_tools/analysis/rbm.py#L318

The above line attempts to apply the original data mask of known shape, to the returned array with unknown shape.

Instead use something like:

significance_off = significance_map_off.data[np.isfinite(significance_map_off.data) & exclusion_mask.data.flatten()] 
samanthalwong commented 4 months ago

Ah ok that's right. I added a similar fix and that'll get put into the PR!