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

Improvements to Container classes #1123

Merged
merged 27 commits into from
Oct 25, 2019

Conversation

kosack
Copy link
Contributor

@kosack kosack commented Sep 30, 2019

This is the first of a set of PRs that are needed for #1066. These are just some naming cleanups and new containers (not a full redesign of the event structure yet). It includes:

Deprecation of Fields

new DeprecatedField class to mark fields that are going away soon

Normalizing the names of the Concentration and Leakage fields:

Writing ConcentrationContainers lead to columns named "concentration_concentration_cog", now removed the redundant prefix

  • same for leakage parameters: use "leakage" prefix, and remove that prefix from the names.
  • renamed leakage1_pixel to pixels_width_1 (similar for pixels_width_2), and and leakage1_intensity to intensity_width_1 to be clearer what they mean. These then get written with the prefix as leakage_intensity_width_1, for example

Added an ImageParametersContainer

Just for collecting all of the various parameter sets. May eventually be replaced with a less hard-coded version, but is useful now.

Added EventIndexContainer and TelEventIndexContainer

Store things like event_id, tel_id, and obs_id in one central place, so you can add them to any event list easily. Deprecated places where they were filled elsewhere.

Added a few new containers for later use:

  • added a MorphologyContainer for morphology parameters (calculation will be added in separate PR)
  • added a SimulatedShowerDistribution container, for storing the sim_telarray thrown shower histograms.

Updated SimTelEventSource

  • Fill new index containers correctly
  • use pathlib, allow filenames to include ~ or environment variables

- Writing `ConcentrationContainers` lead to columns named "concentration_concentration_cog", now removed the redundant prefix
- same for leakage parameters: use "leakage" prefix, and remove that prefix from the names.
- renamed `leakage1_pixel` to `one_pixel_percent` and `leakage1_intensity` to `one_pixel_intensity` to be clearer what they mean
These contain just basic event header data like tel_id and obs_id
the old LeakageContainer had the wrong prefix and confusingly named fields. Now a LeakageContainer becomes the following when turned into columns of an output Table:

- leakage_intensity_1pix
- leakage_percent_1pix
- leakage_intensity_2pix
- leakage_percent_2pix
- Added `DeprecatedField`  class to be able to describe fields that will disappear soon
- Introduce `EventIndexContainer` and `TelEventIndexContainer` to store event  index info (event_id, tel_id, obs_id), and deprecated places where these were used elsewhere
- added a MorphologyContainer for morphology parameters (calculation will be added in separate PR)
- added a `SimulatedShowerDistribution` container, for storing the sim_telarray thrown shower historgrams.
- fill index containers correctly
- fix bug where missing input_url didn't always fil correctly.
- allow `~` and env vars in input filenames
ctapipe/io/containers.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 30, 2019

Codecov Report

Merging #1123 into master will increase coverage by <.01%.
The diff coverage is 97.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1123      +/-   ##
==========================================
+ Coverage   85.88%   85.89%   +<.01%     
==========================================
  Files         182      182              
  Lines       11410    11300     -110     
==========================================
- Hits         9800     9706      -94     
+ Misses       1610     1594      -16
Impacted Files Coverage Δ
ctapipe/core/__init__.py 100% <100%> (ø) ⬆️
ctapipe/image/tests/test_leakage.py 100% <100%> (ø) ⬆️
ctapipe/image/concentration.py 100% <100%> (ø) ⬆️
ctapipe/io/tests/test_hdf5.py 97.59% <100%> (ø) ⬆️
ctapipe/image/leakage.py 100% <100%> (ø) ⬆️
ctapipe/image/tests/test_concentration.py 91.66% <100%> (ø) ⬆️
ctapipe/core/traits.py 97.87% <100%> (ø) ⬆️
ctapipe/core/tests/test_container.py 100% <100%> (ø) ⬆️
ctapipe/io/simteleventsource.py 98.52% <100%> (+0.02%) ⬆️
ctapipe/io/containers.py 100% <100%> (ø) ⬆️
... and 6 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 6ab838f...c8e7313. Read the comment docs.

ctapipe/image/leakage.py Outdated Show resolved Hide resolved
watsonjj
watsonjj previously approved these changes Oct 22, 2019
- added Deprecated
- changed deprecated members to use it
- also added  a "version" attribute
- added test
Copy link
Contributor

@watsonjj watsonjj left a comment

Choose a reason for hiding this comment

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

You have accidentally committed provenance.log

Copy link
Member

@maxnoe maxnoe left a comment

Choose a reason for hiding this comment

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

The deprecated class does not really work in general unfortunately. If you have multiple containers, all will return the same value because value is only saved on the deprecated instance which is only created once.

@kosack
Copy link
Contributor Author

kosack commented Oct 23, 2019

The deprecated class does not really work in general unfortunately.

Ah, yes, that is a problem - perhaps a simple class decorator may be better, but then you get a warning when the Container is constructed, not on access.

@kosack
Copy link
Contributor Author

kosack commented Oct 23, 2019

Do you have a better suggestion? I could just go back to my original idea: A DeprecatedField class that is a subclass of Field and that raises a warning on access? (I just never got around to adding the warning)

@maxnoe
Copy link
Member

maxnoe commented Oct 23, 2019

No, unfortunately I couldn't get it to work.

@kosack
Copy link
Contributor Author

kosack commented Oct 23, 2019

I think we can figure out later how to warn in a nicer way (on use). For now, I think it's fine just to mark the class as deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants