Implement the Earth Horizon cut #622
Conversation
Added test for Earth Horizon cut in unbinned data.
Documentation build overview
14 files changed ·
|
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
|
Thanks @GallegoSav. It's fine for now, but it would be good to make it an EventSelector instead. We plan to refactor the DataIO anyway, see #344 |
|
Quick review, mainly for performance issues since you indicated that you were interested in speed on a large set of events:
|
|
(BTW, if the lack of acceleration for einsum is a real thing, we should be worrying about it elsewhere in cosipy as well. It comes up in relative coordinates conversion, location and attitude interpolation in SpacecraftHistory, and whatever is happening in optimized_unbinned_folding.py) |
|
OK, after some further investigation, it's not clear that the einsums noted above are bottlenecks, or that they can easily be replaced by dot/tensordot calls. So maybe never mind on that point. (More specifically, the operation in this code is equivalent to np.vecdot(), but the latter, despite being advertised as using CBLAS under the hood, refuses to use more than one core no matter how large I make either the number of vectors or the vector length. vecdot() is actually somewhat slower on my machine than the corresponding einsum() call, which is appalling. I can get the expected performance with multiple cores if I explicitly rewrite the vecdot() operation with Numba, but I'm not sure it's worth it here.) |
|
@GallegoSav I'm happy to start looking at this next week if somebody hasn't approved it yet. |
|
@israelmcmc @jdbuhler Thanks for your comments ! I will try to make it an |
|
@israelmcmc @jdbuhler I implemented a However, I get small differences in the distributions of
|
|
Interesting. Assuming there not an error somewhere, I think the largest difference will come from the PsiChi local to Galactic conversion. It would be good to distribution of the difference between these 2 ways to convert PsiChi. I think @ckarwin looked into this at some point. @GallegoSav are you using the 1s cadence ori file or larger? This and issues that have come up have convince me that I would be move convenient and efficient if PsiChi were available in both coordinates systems for every event, instead of computing it on the fly every time. This is true for UnbinnedData, but not yet for the interfaces. We would need an equivalent to |
@israelmcmc I tried the 1s ori file but it did not change the result. Yes, my first idea was to make this I added new interfaces for this pull request, where you can have local and galactic PsiChi using It reduced the differences but that is still not perfect. Maybe the conversion from unix time to julian date is making the last differences ? |
Updated comments to reflect changes in method usage and file types.


This pull request add the Earth Horizon cut feature. This is done by 2 steps :
_ez_cartand_min_angle_coscomputed byget_earth_occfor each event. Then compute the angle between PsiChi and_ez_cart.The user can then set a cut value based on this distribution with
cut_EarthHorizon().By using only numpy, this function is pretty fast ( ~3,4 min for 118 M events of the Cosmic photons bg component).
Here an example on how this distribution differs between the Albedo Photons (coming from below the satellite) and the Cosmic Photons (coming from above).
The power of discrimination is not that great but that's not a surprise. This can be of course improve by asking nb of interaction > 2 and applying some cut in Phi, if the signal is a point source , ect...