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

Add option to not parse blocks #21

Merged
merged 2 commits into from
Feb 16, 2023
Merged

Add option to not parse blocks #21

merged 2 commits into from
Feb 16, 2023

Conversation

maxnoe
Copy link
Member

@maxnoe maxnoe commented Oct 26, 2022

When loading large files in-bulk, it's much faster to accumulate the arrays and then parse the low-level float arrays then parsing each event directly.

Added an option to just keep the float array in the event loop.

@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Base: 96.09% // Head: 95.98% // Decreases project coverage by -0.12% ⚠️

Coverage data is based on head (aae021f) compared to base (e13ef5f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
- Coverage   96.09%   95.98%   -0.12%     
==========================================
  Files          19       20       +1     
  Lines         384      473      +89     
==========================================
+ Hits          369      454      +85     
- Misses         15       19       +4     
Impacted Files Coverage Δ
corsikaio/file.py 97.54% <100.00%> (+0.19%) ⬆️
tests/test_file.py 100.00% <100.00%> (ø)
corsikaio/subblocks/run_header.py 84.00% <0.00%> (-3.50%) ⬇️
corsikaio/subblocks/data.py 100.00% <0.00%> (ø)
corsikaio/subblocks/dtypes.py 100.00% <0.00%> (ø)
corsikaio/subblocks/run_end.py 100.00% <0.00%> (ø)
corsikaio/subblocks/__init__.py 100.00% <0.00%> (ø)
corsikaio/subblocks/event_end.py 100.00% <0.00%> (ø)
corsikaio/subblocks/longitudinal.py 100.00% <0.00%> (ø)
tests/test_units.py 100.00% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

corsikaio/file.py Outdated Show resolved Hide resolved
@The-Ludwig
Copy link

Hi @maxnoe! I played around with this in the last week and successfully use this in https://github.com/The-Ludwig/PANAMA .
I parse CORSIKA DAT files to pandas dataframes and using noparse, I am way faster.

I think this is fine to merge, actually, should I add a test?

Only comment I have is: also checking noparse in the derived classes from CorsikaFile seems unneeded, since

@maxnoe
Copy link
Member Author

maxnoe commented Feb 15, 2023

@orelgueta Could you give a quick review here, it's a nice-to-have feature for @The-Ludwig and shouldn't interfere with our usage

@maxnoe maxnoe marked this pull request as ready for review February 15, 2023 13:53
Copy link
Contributor

@orelgueta orelgueta left a comment

Choose a reason for hiding this comment

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

The added code all looks good.
Just for my understanding though, if this option is used, the arrays are remained unparsed and the user has to parse them after reading all the events using their own code. Is that correct?

@The-Ludwig
Copy link

@orelgueta Yes, that is correct. In my testing I am around 5 times faster if I don't parse the particle blocks, put them into a python list, make a pandas dataframe out of them and then name the columns. Of course it depends on the size and structure of the file itself, but there are definitely some good use-cases.

@maxnoe
Copy link
Member Author

maxnoe commented Feb 16, 2023

Not using their own code, the functions here can be used. The difference is basically that for the use case of reading all events in a file into a single data structure, instead of parsing n arrays and then stacking you stack n simple arrays first and then parse once.

@maxnoe maxnoe merged commit 029bcb6 into main Feb 16, 2023
@maxnoe maxnoe deleted the noparse branch February 16, 2023 15:01
This was referenced Mar 27, 2023
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.

3 participants