-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing values interpolation for Background3D #3219
Conversation
Related: #2432 |
Conclusion from the dev meeting today:
|
7f31b98
to
aaa96c9
Compare
I added options to use the fix or not in Background3D (default is False) and MapDatasetMaker (default is True, otherwise we have to set another option in the config file for the high-level interface). |
Codecov Report
@@ Coverage Diff @@
## master #3219 +/- ##
=======================================
Coverage 93.81% 93.82%
=======================================
Files 144 144
Lines 17754 17776 +22
=======================================
+ Hits 16656 16678 +22
Misses 1098 1098
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @QRemy, I have left some comments, I noticed the methods also extrapolates to low energies. Can this be avoided? I guess it would be the more safe behaviour. I think in most cases the background turns over at low energies, however I'm not sure this always the case...
gammapy/makers/map.py
Outdated
""" | ||
|
||
tag = "MapDatasetMaker" | ||
available_selection = ["counts", "exposure", "background", "psf", "edisp"] | ||
|
||
def __init__(self, selection=None, background_oversampling=None): | ||
def __init__( | ||
self, selection=None, background_oversampling=None, fix_background=True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a quick check (analysis_2.ipynb
tutorial) it seems the interpolation of missing values slows down the data reduction by ~20%, maybe don't apply the fix by default? It's only required if data is extrapolated...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now only the missing values within the valid range are interpolated, the zeros outside are filled so it should be faster.
45a4b95
to
4e4f0aa
Compare
Sorry again @QRemy, for the late response here. It had been on my list forever to try this out and check the implementation. I finally managed to do so. Can you please take a look at the following notebook: https://github.com/adonath/notebooks-public/blob/master/missing_value_interpolation.ipynb ? It runs on your Here are a few things I found:
In the beginning I was hesitating a bit do add something like this at all, but now I see that more and more DL3 data is produced (VERITAS, MAGIC, LST etc.) and I doubt we will get fully stable IRFs in the first productions. So now I agree more such a method is useful, possibly for other IRFs as well. So if you like to continue here, I would propose to copy the implementation from the notebook I linked above and move it to the |
I think the implementation in the |
I'm ok with your implementation but I think we need |
-use ScaledRegularGridInterpolator instead of interp1d -avoid masked array
0f4354f
to
49c6105
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @QRemy, no further comments from my side.
This PR adds missing values interpolation for Background3D in order to fix a bug found in CTA background IRF where the clipping of missing values in the ante-last bins of the energy axis was causing aberrantly high extrapolated values.