-
Notifications
You must be signed in to change notification settings - Fork 270
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
Hillas parameters in telescope frame #1591
Conversation
- x,y replaced by lon and lat - units changed to deg from m
- Requires pixel positions in the nominal frame instead of a geom object - Most of the code is a duplicate of the reconstruction in the camera frame for now
From the point of view of
Of course, I see no problem in adding the possibility of having the parameters in yet another frame, but that would complicate #1408 and it's encapsulation in stage2 and I think merging that before would make things clearer also for this PR. Anyway here you just add the possibility to have the parameters in that frame, so it doesn't harm the rest. |
Yeah, the HillasReconstructor does not really care about this. |
What we discussed was something else. The task for the next ctapipe release should be to have the DL1 in degrees. For now, let's keep it simple.
|
Ok, lets do it like this. |
- Decide which container to return based on pixel position unit
- Save image parameters calculated in the nominal frame - This affects the hillas parameters and the timing slope - The coordinate transformations happen in the image processor
Since we want to switch to the hillas parameters in degree by default I think it would make sense to actually make the @kosack @HealthyPear opinions? |
I like the idea! |
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.
- Use telescope frame
- Make it default in the image processor
- Make the normal containers without prefix the ones with stuff in degrees
- Keep the old ones with a prefix
Camera....
- Remove any hard coded sites / array pointings /
- Stage 1 and the connected tools now calculate the hillas parameters in the telescope frame - Hillas and TimingParametersContainer now store values as deg. Old containers persist as CameraHillas/TimingParametersContainer - In order to keep a single ImageParametersContainer, base containers have been added for hillas and timing parameters - Failing tests adapted: x/y -> lon/lat, reconstruction algorithms use the CameraHillasParametersContainer
A few comments:
|
I feel like this makes it harder to keep track of the units and coordinate frames. The reconstructor could then not rely on getting a HillasParametersContainer alone, but would also need to check if its in the correct frame. Also
Do you mean, that you want to save results in both coordinate frames in the dl1 output?
General conversion functions for the dl2 reconstructors could be handy, agreed. If we agree on a list of functions, I can add them here, in a new pr or we see it as part of #1408. |
Regarding the failing test: |
Will be fixed by merging #1589 or removing your cache |
I also like the idea of making the HillasContainer a bit more adaptive (I tried to propose this during #1408 in fact). If there's a way to do this It would be cool to build a HillasContainer with a frame object and a unit, so even if unit is degrees one can differentiate between TelescopeFrame and NominalFrame. Also because in #1408 I didn't change the Hillass containers, I just write to them in a frame, but I think that for a dummy event the units would be wrong (the values instead would be always either 0 or NaN) |
@HealthyPear No, please don't! We should keep containers simple without any logic other then storing / validating data. I think they are too complex as it is. |
Then if we want to store Hillas parameters in more than one frame we have to create at least 2 of them, one for meters and one for degrees. |
|
ctapipe/image/image_processor.py
Outdated
@@ -65,6 +65,7 @@ def __init__( | |||
self, | |||
subarray: SubarrayDescription, | |||
is_simulation, | |||
use_telescope_frame=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.
This should be a Traitlet, not a construction option. Otherwise it is not configurable. The default should be set to 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.
That will not change the data model - it is only a configuration option, and the current data model supports both units in the output. However, we may in the future deprecate the CameraFrame one and clean up all that code as I said before, but now we want to be able to run the full analysis twice on a large dataset and ensure they results are compatible with both frames.
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.
While we are at it, please also remove the is_simulation
option. It should not be needed. Code that needs to check that should just check if event.simulation is None
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.
Sorry, not really connected. Will just make a PR
for some reason clicking "request changes" didn't work
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 did a quick check running in both the telescope (using this version) and camera frame (using the master version) and comparing the differences. It all looks good. There are some slight differences, but this may be due to rounding error. We may need to investigate a bit though, but that can come later. For example, not sure why delta alt is not centered on 0: there is a small bias
Sorry, thought I pushed that yesterday. @kosack What did you use for that comparison? Diffuse or pointlikes? |
It shouldn't matter, but better check with both. |
point-like. This was just a quick test to make sure it was not crazy. We should do a proper benchmark later. The errors are all quite small. |
we should have a small diffuse test file with 10 showers if I recall correctly |
It shouldnt, I am just curious especially if there is a bias |
I dont think 10 showers will suffice for this kind of benchmark |
@HealthyPear There's already a unit test for this for HillasReconstructor, |
Related discussions about this can be found in:
This changes the calculation of the image parameter for the dl1 output to be performed in the nominal frame.
For this, new containers have been added. This is kind of the brute force way. Since it is only relevant for a few container fields (x,y,length, width...), we could also make their unit configurable. However, that might lead to confusion, because the field names do not reflect that difference. Or let one container have both fields of which only one is filled?
Side note: Some code (e.g. calculation of the concentration) explicitly names things x and y, which I did not change.
So maybe a naming of the coordinate axes, that does not indicate the use of a certain coordinate frame could be a way out?
All of these changes are written out by the stage1-tool. Coordinate transformations happen in the ImageProcessor.
Since new frames are constructed for each event, this might be slower. I do not know how to access all pointings at once without iterating over the events though.
Regarding the change of the data model version:
We probably want to collect test files of older versions in order to make sure, that we do not break their functionality.
Is adding dl1 files to ctapipe-extra the way to go or is there another solution?
Not longer relevant (keeping it for context):
The more I think about this, the less certain I am if we even want to calculate features in the nominal frame or if a later conversion makes more sense. Anyway, lets discuss this.
Status:
For now this adds a new method and a new container for the calculation of the parameters in the nominal frame.
Since conversion from the camera geometry to the nominal frame requires the telescope pointings, I figured it would be easiest to perform this transformation outside and call the function with a SkyCoord containing the pixel positions. After writing the code I learnt that the camera geometry also has a
transform_to
method, so thats another possibility. Would make the API clearer but adds some overhead to the calculation.There is of course a lot of duplicated code right now since the performed steps are pretty much identical. So if we decide to follow up on this approach, it would be beneficial to put some of that code into an extra function.
Some feature (Intensity/Skewness/...) are identical. If we want to include them in the NominalHillasParametersContainer as well probably depends on whether we want both sets of parameters in stage1 or only one of them.
With the coordinate frames at hand, it is possible to convert from one set of parameters to the other and the results should match.
Questions / Points to discuss
Images, Cog, length and width in the nominal frame: