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

Enable access to subarray information from file before event loop #1157

Merged
merged 4 commits into from Nov 12, 2019

Conversation

watsonjj
Copy link
Contributor

In #1155 I encountered another situation where it would be useful to have the subarray information available immediately after initialising the eventsource (before starting the event loop).

This appears to be a fairly straightforward change, which could help keep a lot of other code tidy.

This idea was originally suggested in #722

@watsonjj
Copy link
Contributor Author

@kosack In #722 you suggested in addition to attaching the SubarrayDescription to the EventSource, to also:

  • attach MCHeaderContainer to the EventSource
  • mark event.inst as deprecated

Should I include that in this PR?

@codecov
Copy link

codecov bot commented Oct 26, 2019

Codecov Report

Merging #1157 into master will increase coverage by 0.04%.
The diff coverage is 96.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1157      +/-   ##
==========================================
+ Coverage   85.93%   85.98%   +0.04%     
==========================================
  Files         182      182              
  Lines       11365    11392      +27     
==========================================
+ Hits         9767     9795      +28     
+ Misses       1598     1597       -1
Impacted Files Coverage Δ
ctapipe/io/hessioeventsource.py 93.82% <100%> (+1.42%) ⬆️
ctapipe/io/tests/test_hessio_event_source.py 100% <100%> (ø) ⬆️
ctapipe/io/tests/test_simteleventsource.py 100% <100%> (ø) ⬆️
ctapipe/io/eventsource.py 94.82% <100%> (+0.18%) ⬆️
ctapipe/io/simteleventsource.py 97.76% <100%> (+0.02%) ⬆️
ctapipe/io/tests/test_event_source.py 95.45% <50%> (-4.55%) ⬇️

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 554fe93...409f3c3. Read the comment docs.

@kosack
Copy link
Contributor

kosack commented Oct 28, 2019

yes, this will be solved with the major restructuring of the eventsource/instrument that I proposed a while ago. I should really write up a more detailed description.

Related are:

@kosack
Copy link
Contributor

kosack commented Oct 28, 2019

I think #1041 is the most relevant: see the proposals there for how to separate it. My preference would be to have it be an attribute that can be accessed from an EventSource (header info), or have it returned in the event source loop (less ideal).

@@ -190,6 +190,18 @@ def is_stream(self):
"""
return False

@property
@abstractmethod
def subarray(self):
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if that's a good idea. Are we we sure, subarray info can come from an event source?
I don't think this is the case for e.g. LST real data event source

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the current scheme the event source must provide it in one way or another (to attach it to the event container), even if the information is not located in the file. So I don't think this change should be a problem.

Copy link
Member

Choose a reason for hiding this comment

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

ah ok

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, the name EventSource may be confusing, but that's the idea - it provides the events + any other data associated with them (it already does this in fact! Just mixes the two concepts, so I don't see a problem)

@watsonjj
Copy link
Contributor Author

So the inst container is already deprecated.

On second thoughts, I would like to avoid doing the same for the MCHeader in this PR. It isn't as simple to disentangle from the event building as the SubarrayDescription as its being updated per event at the moment...

Can this PR be accepted?

@kosack
Copy link
Contributor

kosack commented Oct 28, 2019

[moved comment to #1041 ]

@kosack
Copy link
Contributor

kosack commented Oct 28, 2019

Ok, lets leave the big .changes for another PR. I'll move my previous comment to the issue

@@ -51,6 +51,12 @@ def is_compatible(file_path):
'''This class should never be chosen in event_source()'''
return False

@property
def subarray(self):
with self.pyhessio.open_hessio(self.input_url) as file:
Copy link
Contributor

Choose a reason for hiding this comment

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

this of course will fail if the file is a stream. Do we want to break that idea? I think you can change the logic to still work with streams.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its done this way because of the limitation of the hessio library. Do we have to account for streams with hessio?

pyeventio allows the SubarrayDescription to be generated before starting the event loop.

Copy link
Contributor

@kosack kosack Oct 30, 2019

Choose a reason for hiding this comment

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

The HESSIOEventSource is no longer maintained (and is deprecated), so I think we can drop it. We can remove the cross-check test in the next version., and just remove hessioeventsource.py

kosack
kosack previously approved these changes Nov 6, 2019
* remotes/upstream/master:
  Move gain selection from CameraCalibrator to EventSource (cta-observatory#1167)
  Pointing container (cta-observatory#1141)
  Replace resolve with __getitem__
  Correct variable name
  Add resolving to the TelescopeParamter
  fixed bug where telescope name and TelescopeDescription were conflused
  Add instructions for Slack

# Conflicts:
#	ctapipe/io/tests/test_simteleventsource.py
@watsonjj watsonjj merged commit ba35c2f into cta-observatory:master Nov 12, 2019
watsonjj added a commit to watsonjj/ctapipe that referenced this pull request Nov 13, 2019
@watsonjj watsonjj deleted the subarray branch April 15, 2020 15:17
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.

None yet

4 participants