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

TableLoader #1771

Merged
merged 26 commits into from
Sep 20, 2021
Merged

TableLoader #1771

merged 26 commits into from
Sep 20, 2021

Conversation

maxnoe
Copy link
Member

@maxnoe maxnoe commented Jul 30, 2021

I adapted this from the class in the dl1 benchmarks workshop, but changed the structure a bit.

I added options for what to load and for now a single method load_telescope_events(tel_id) to read / join all needed columns for one telescope.

Methods to come:

  • loading only stereo data
  • loading events for multiple tel_ids (as dict by type or just as single table).
  • more?

Needs #1769

@maxnoe maxnoe requested review from HealthyPear and kosack and removed request for HealthyPear July 30, 2021 13:33
@codecov
Copy link

codecov bot commented Jul 30, 2021

Codecov Report

Merging #1771 (7700d48) into master (63e0df4) will increase coverage by 0.03%.
The diff coverage is 93.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1771      +/-   ##
==========================================
+ Coverage   91.80%   91.84%   +0.03%     
==========================================
  Files         188      190       +2     
  Lines       14910    15237     +327     
==========================================
+ Hits        13688    13994     +306     
- Misses       1222     1243      +21     
Impacted Files Coverage Δ
ctapipe/core/tool.py 93.22% <ø> (ø)
docs/conf.py 86.00% <ø> (ø)
ctapipe/instrument/telescope.py 86.48% <50.00%> (-10.07%) ⬇️
ctapipe/io/astropy_helpers.py 89.85% <68.18%> (-10.15%) ⬇️
ctapipe/conftest.py 94.48% <91.66%> (-0.94%) ⬇️
ctapipe/io/tableloader.py 95.23% <95.23%> (ø)
ctapipe/instrument/subarray.py 92.82% <100.00%> (+0.37%) ⬆️
ctapipe/instrument/tests/test_subarray.py 100.00% <100.00%> (ø)
ctapipe/io/__init__.py 100.00% <100.00%> (ø)
ctapipe/io/tests/test_table_loader.py 100.00% <100.00%> (ø)
... and 3 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 63e0df4...7700d48. Read the comment docs.

@HealthyPear
Copy link
Member

HealthyPear commented Aug 2, 2021

Updates

I have improved the current PR with

  • loading DL2 shower geometry
  • refactoring to ensure loading of any single table and of every (almost, see below) combination
  • added a generic call function that makes the usage blind to dataset split mode

(Current) Caveats

  • loading of trigger + instrument alone cannot work for now because they refer to different things and have no column in common
  • I read shower geometry by pre-pending the name of the reconstruction algorithm in case there is more than 1, perhaps in the case of only 1 it can be avoided

TODO

  • check for missing unit-tests or testing cases
  • improve documentation (docstrings and docs)

@HealthyPear HealthyPear linked an issue Aug 2, 2021 that may be closed by this pull request
@HealthyPear HealthyPear marked this pull request as ready for review August 2, 2021 22:44
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
ctapipe/io/tableloader.py Outdated Show resolved Hide resolved
@maxnoe
Copy link
Member Author

maxnoe commented Sep 2, 2021

Ok, I came finally around to doing this. I think the code is much cleaner now, especially by itroducing the _allow_empty_join function, much of the complicated checking if a table is already there is gone.

There are now only three public methods:

read_subarray_events, read_telescope_events and read_telescope_events_by_type.

The latter two support the use cases of the previous many functions by having this List[Union[str, int, TelescopeDescription]] as argument.

@maxnoe maxnoe requested a review from kosack September 2, 2021 14:32
Copy link
Contributor

@kosack kosack left a comment

Choose a reason for hiding this comment

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

Look good! Much simpler, and works in all my use cases.

@kosack kosack marked this pull request as ready for review September 2, 2021 16:13
Copy link
Member

@LukasNickel LukasNickel left a comment

Choose a reason for hiding this comment

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

There are a lot of codacy complaints. Some are false positives, some are minor issues. I dont see any of them as severe, but want to bring up the topic before approving.

Copy link
Contributor

@kosack kosack left a comment

Choose a reason for hiding this comment

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

I somehow missed all the codacy complaints. I agree with @LukasNickel that most are minor, but a few should be addressed. It would be good to at least:

  • document get_structure (it is a public function, exported from the module in __all__, and is really not clear at all what it does from the name)
  • document read_subarray_events
  • probably want a # pylint: disable= protected-access at the top of any files that uses low-level hdf5 commands (like _v_*, which give false-positive warnings)
  • don't use the variable name tables (used a few times), since it shadows the tables module, and that could lead to bugs in the future
  • either disable the warning, or document each test with at least a few words about what the test does: e.g.
def test_read_subarray_events(test_file_dl2):
     """ check that we get some expected columns when reading a file with DL2 """
  • It's not clear to my why we suddenly are getting redefined-outer-name warnings in the tests
  • also not sure why we get a List[TelescopeDescription] is not iterable warning here: (aren't lists iterable?)
valid_tel_types = {str(tel_type) for tel_type in self.telescope_types}

Edit: it's a @lazyproperty, so I guess that gives a false positive, since it looks like a function to the linter

@maxnoe
Copy link
Member Author

maxnoe commented Sep 17, 2021

@kosack I think I addressed most/all relevant codacy issues

@maxnoe
Copy link
Member Author

maxnoe commented Sep 17, 2021

Ok, now the docs should be fixed as well, at least with regard to table loader and processor tool, for the rest I opened #1786

@@ -425,6 +425,7 @@ good-names=i,
x,
y,
n,
f,
Copy link
Member

Choose a reason for hiding this comment

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

The indentation seems off here, tab vs spaces?

@kosack kosack merged commit 5ff5401 into master Sep 20, 2021
@kosack kosack deleted the tableloader branch September 20, 2021 20:51
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.

Add reading functions to ctapipe.io
4 participants