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
Vectorize operations in HillasReconstructor #2036
Conversation
Codecov ReportBase: 92.49% // Head: 92.49% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2036 +/- ##
==========================================
- Coverage 92.49% 92.49% -0.01%
==========================================
Files 197 197
Lines 16246 16276 +30
==========================================
+ Hits 15027 15054 +27
- Misses 1219 1222 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
as suggested in #1922 perhaps we should also drop the CameraFrame support in HillasReconstructor (either here or in a separate PR) to simplify this code even more and remove a few branch points. |
@kosack If you look at the code, the branching for I am investigating a few issues with astropy concerning performance and I have identified several spots where astropy can be much improved. For now, I would keep it in the current version I think, we already get a very noticeable speedup. |
46be9e6
to
91dd16a
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.
Looks good!
Before merging, It might be a good idea to do a regression test on a largish number of events to be sure the results have not changed since before the refactoring. (if you have not done that already).
Will do |
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.
One minor annoyance that would be nice to fix in this is that the azimuths end up in a strange quadrant (negative). It would be nice for sources with azimuth=180.0 that the reconstructed position is centered there, not at -180.0. It's still correct, but may be confusing when we use that value in a ML algorithm without any transforms.
Sure, I'll wrap the angle into [-180, 180) |
Astropy.coord seems to wrap to (0,360], not sure which is better (either way the user has to do a wrap transform if you are one of the usual North or South pointings). At least we should make all Reconstructors consistent. I think HillasIntersection returns something in (0,360]. Not sure about ImPACT. I only noticed this in #2073 when using multiple reconstructors |
Ok, let's go with the astropy default then |
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.
I guess the small differences are just due to the different order of operations. In any case as the results are generally better, I think it's ok.
This gives me a 5.5 times speed-up compared to current master.
…cope frame transforms
20b2e05
to
0f5d4c5
Compare
Had to rebase, please re-review @kosack @nbiederbeck @LukasNickel |
error in docs |
point_tel = point_cam.transform_to(telframe) | ||
self._cam_radius_deg[cam] = point_tel.fov_lon | ||
_cam_radius_deg[cam] = point_tel.fov_lon.to_value(u.deg) |
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.
Not directly related to this PR, but is anyone else really disliking this code block and would rather have the cam radius in meter and degree be a property of the camera geometry?
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.
We currently have the geometry strictly in one frame and I quite like this...
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.
This should rather be replaced by dropping support for doing high-level things in camera frame
self._cam_radius_deg[cam] = point_tel.fov_lon | ||
_cam_radius_deg[cam] = point_tel.fov_lon.to_value(u.deg) | ||
|
||
# store for each tel_id to avoid costly hash of camera |
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.
For my understanding:
Why not directly assign to self._cam_radius_x
above?
I am guessing you save calculations by performing them once per camery type above and only then looping over the actual telescopes down here?
Errors should be fixed now |
Timing script:
On master:
on this branch:
Units tests are passing, but I will also process a larger DL2 run and check that results are the same.
Most time is not spend in astropy coordinate transforms and project_to_ground.