Skip to content
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

Container Improvements and Cleanup for DL1 #1301

Merged
merged 27 commits into from
May 6, 2020

Conversation

kosack
Copy link
Contributor

@kosack kosack commented Apr 28, 2020

This is just a small first pass of cleaning up the containers relating to DL1. I don't intend this to be the full refactoring of all containers yet, I'm just doing it in small stages. So far, this just removes the need for defining new Containers to make a DL1 dumper (see #1066). For future proposed changes see #1165 and #1224

Container Changes:

  • DL1CameraContainer:
    • renamed pulse_timepeak_time in anticipation of other pulse times (like rise_time, etc)
    • added selected_gain_channel (also to DL0 container), since this is needed
    • added image parameters as a sub-container
    • added image_mask to store the cleaning mask (still need to think what to do in case of non-mask based denoising, but that can come later)
  • Created an MCDL1CameraContainer that extends this container to add:
    • true_image (photo electrons from MC without noise)
    • true_parameters (set of parameters computed from the true_image)
    • note this might not need a new container, it could just be an MC version of the DL1CameraContainer with the prefix set to "true_", though that contains some fields that are maybe not available in the MCs
  • EventIndexContainer:
    • removed deprecated fields for event_id, obs_id, and event_type elsewhere
    • make sure everything uses it
    • added event_type and made it an Enum (was a string, which doesn't store well)

Features

  • Fields now have optional dtype, ndim, and allow_none metadata attributes
  • Field and Container now have .validate() methods that check the values against the given metadata, if specified

things that are not so nice still:

  • MCDL1CameraContainer and MCCameraEventContainer should be merged / cleaned up
    • right now MCEventContainer is shower info (could rename MCShowerContainer instead)
    • the telescope-wise MC info in MCCameraEventContainer is not really event-wise info: it contains pointing info (that could be removed), and calibration coefficients that do not change per event. For this reason I do not want to write this container to DL1, since it adds a lot of "images" that do not change. I think the calibration info should move either to be under the the MCHeaderContainer (assuming it does not change during an observation file), or otherwise it could be migrated to the real Calibration containers.
  • I'd like to drop "MC" jargon and replace it with "Simulation" for containers, and "true_X" for parameters if possible.

There are lots of other general issues, but those can be discussed in the issues linked above.

download-1

for reference, here is the MCEventContainer and MCCameraEventContainer(in the latter, I think nearly everything could be moved elsewhere, and the former renamed to "SimulatedShowerContainer")
download-2

-  pulse_time → peak_time (in anticipation of later adding other pulse times, like rise_time, etc.)
- added selected_gain_channel (also to DL0, where it was missing)
EventType was a string, but that doesn't write easily to a file, so now it is an integer Enum
@kosack kosack requested a review from watsonjj as a code owner April 28, 2020 13:52
@maxnoe
Copy link
Member

maxnoe commented Apr 28, 2020

I'd like to drop "MC" jargon and replace it with "Simulation" for containers, and "true_X" for parameters if possible.

Whole heartedly agree

ctapipe/containers.py Outdated Show resolved Hide resolved
- by default not used
- if speficied, will fail in Field.validate()
- added a Field.validate() and Container.validate() method
- fixed a warning in DeprecateField test
@kosack
Copy link
Contributor Author

kosack commented Apr 28, 2020

I've now gone a bit further and fixed #1224 by adding Field and Container validation. You can now also optionally specify ndims and dtype of Fields, and they can be checked. So far this is not used yet in the TableWriter but could be.

For now, I will start to fill in at least the dtypes and ndims for the DL1 info as needed, rather than relying on the documentation only to specify that.

@kosack kosack changed the title First pass Container Cleanup for DL1 Container Imrovement and Cleanup for DL1 Apr 28, 2020
@kosack kosack changed the title Container Imrovement and Cleanup for DL1 Container Improvements and Cleanup for DL1 Apr 28, 2020
@@ -18,33 +24,111 @@ class Field:
Help text associated with the item
unit: `astropy.units.Quantity`
unit to convert to when writing output, or None for no conversion
ucd: str
ucd: str or astropy.unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucd should not be a unit, right?

ctapipe/core/container.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #1301 into master will increase coverage by 0.03%.
The diff coverage is 94.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1301      +/-   ##
==========================================
+ Coverage   90.49%   90.53%   +0.03%     
==========================================
  Files         184      184              
  Lines       11883    11980      +97     
==========================================
+ Hits        10754    10846      +92     
- Misses       1129     1134       +5     
Impacted Files Coverage Δ
ctapipe/plotting/bokeh_event_viewer.py 91.84% <ø> (ø)
ctapipe/tools/display_events_single_tel.py 71.60% <ø> (ø)
ctapipe/tools/display_summed_images.py 90.90% <ø> (ø)
ctapipe/visualization/tests/test_mpl.py 100.00% <ø> (ø)
ctapipe/tools/extract_charge_resolution.py 71.42% <50.00%> (ø)
ctapipe/io/simteleventsource.py 94.89% <76.92%> (-0.45%) ⬇️
ctapipe/image/extractor.py 80.95% <83.33%> (ø)
ctapipe/tools/display_dl1.py 86.27% <88.23%> (ø)
ctapipe/core/container.py 78.76% <90.00%> (+4.00%) ⬆️
ctapipe/calib/camera/calibrator.py 100.00% <100.00%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fd6a02...21cdfc2. Read the comment docs.

@maxnoe maxnoe merged commit db99095 into cta-observatory:master May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants