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

Arepo parser #1867

Merged
merged 22 commits into from
Jan 27, 2022
Merged

Arepo parser #1867

merged 22 commits into from
Jan 27, 2022

Conversation

AlexHls
Copy link
Member

@AlexHls AlexHls commented Jan 19, 2022

Parser for Arepo snapshots to csvy files.

Description

Consists of two distinct parts:

  • First part is a wrapper to automatically load snapshots and extract relevant data. This requires arepo-snap-util to beinstalled as an optional dependency
  • Second part is a converter of grid data to csvy model. Accepts any grid data as long as the shape is the same the snapshot would yield. Extracts profiles either along a line, a cone or averages over the whole star

Motivation and context

No parser available yet, need one for my own project.

How has this been tested?

  • Testing pipeline.
  • Other. I tested all functions on my own snapshots.

Examples

https://alexhls.github.io/tardis/branch/arepo-parser/io/configuration/components/models/converters/arepo_to_tardis.html

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Merging #1867 (6b1b420) into master (3471658) will increase coverage by 0.39%.
The diff coverage is n/a.

❗ Current head 6b1b420 differs from pull request most recent head ce9e73c. Consider uploading reports for the commit ce9e73c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1867      +/-   ##
==========================================
+ Coverage   62.12%   62.52%   +0.39%     
==========================================
  Files          66       68       +2     
  Lines        6809     7124     +315     
==========================================
+ Hits         4230     4454     +224     
- Misses       2579     2670      +91     
Impacted Files Coverage Δ
.../montecarlo/montecarlo_numba/r_packet_transport.py 16.45% <0.00%> (ø)
tardis/tardis/io/parsers/arepo.py 69.04% <0.00%> (ø)
tardis/tardis/model/base.py 88.96% <0.00%> (+0.66%) ⬆️
...rdis/tardis/montecarlo/montecarlo_numba/vpacket.py 19.19% <0.00%> (+0.82%) ⬆️
.../montecarlo/montecarlo_numba/single_packet_loop.py 31.25% <0.00%> (+1.46%) ⬆️
...dis/tardis/montecarlo/montecarlo_numba/r_packet.py 48.64% <0.00%> (+23.21%) ⬆️

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 3471658...ce9e73c. Read the comment docs.

@@ -0,0 +1,220 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 20, 2022

Choose a reason for hiding this comment

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

Perhaps a shorter title. Also, you should start the notebook with some information about what Arepo is, what a snapshot is, and link Arepo's documentation/website.


Reply via ReviewNB

@@ -0,0 +1,220 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 20, 2022

Choose a reason for hiding this comment

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

You should explain what those two files are. One other suggestion: instead of using try/except, you could just put the code in a markdown codeblock and explain that it shows how to take the snapshot if you have the package installed.


Reply via ReviewNB

@@ -0,0 +1,220 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

I would explain what is included in the JSON file/how you get the file.

Also, see if you can link the specific section of the API, or just summarize the options (or use the python help function in the notebook, any of those work)


Reply via ReviewNB

@@ -0,0 +1,220 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 20, 2022

Choose a reason for hiding this comment

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

Could you hyperlink the section on the CSVY model?


Reply via ReviewNB

@@ -0,0 +1,220 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 20, 2022

Choose a reason for hiding this comment

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

I think that last line is important enough to create a note box


Reply via ReviewNB

@AlexHls AlexHls marked this pull request as ready for review January 21, 2022 09:44
@AlexHls AlexHls requested a review from andrewfullard January 21, 2022 10:03
@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

nan,nan,nan,nan
nan,nan,nan,nan
nan,nan,nan,nan
nan,nan,nan,nan
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these NaN?

Copy link
Member Author

Choose a reason for hiding this comment

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

When rebinning data with scipy.stats.binned_statistic to a higher resolution, it will insert bins with NaN. This behaviour is intended/ I did not include an error for this since it does not break the export and can be adressed manually later on.

@@ -0,0 +1,364 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 21, 2022

Choose a reason for hiding this comment

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

This should link to io/configuration/components/models/index.rst#csvy-model


Reply via ReviewNB

@@ -0,0 +1,364 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 21, 2022

Choose a reason for hiding this comment

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

While this works I would recommend using:

<div class="alert alert-info">
  
Note

insert text of note here

</div>

in a markdown cell (same for the other notes).


Reply via ReviewNB

@@ -0,0 +1,364 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 21, 2022

Choose a reason for hiding this comment

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

I'd still mention that arepo_snapshot.hdf5 is the output file of arepo.

Reply via ReviewNB

@@ -0,0 +1,364 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 21, 2022

Choose a reason for hiding this comment

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

Do users have to generate the JSON themselves? Or can they get it from arepo? Seems like in either case the user would need the package?


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the JSON files have to be generated by the user themselves. It is really only a shortcut to having the data available for the documentation, as getting it directly from the snapshot would introduce the arepo-snap-util package as a dependency. (This is not really advisable for two reasons: a) the package contains lots of unnecessary other utilties and the reelevant parts are mostly written in c anyway. b) It is as far as I know not publicly available.)

Rewriting the snapshot reader in Python is really not feasible; besides, this PR is written for the development version anyways, which is also not publicly available. And I recon that most people who use the development version also have the arepo-snap-util package. The public version should in principle also work, but I have no idea how these snapshots are read out. Here the users can save the data to JSON files and use the parser this way. But these files have to be generated by the user, because this is intended as a fallback for exotic Arepo snapshots anyway.

Copy link
Contributor

@andrewfullard andrewfullard left a comment

Choose a reason for hiding this comment

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

Approved, will merge once @smithis7 comments are addressed

@wkerzendorf wkerzendorf requested a review from afloers January 24, 2022 16:20
@@ -0,0 +1,395 @@
{
Copy link
Member

@isaacgsmith isaacgsmith Jan 26, 2022

Choose a reason for hiding this comment

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

Very last thing. In the parentheses it should say (see CSVY Model). The link is correct, just the hyperlink text does not match the link.


Reply via ReviewNB

@AlexHls AlexHls requested a review from isaacgsmith January 26, 2022 09:13
Copy link
Member

@isaacgsmith isaacgsmith left a comment

Choose a reason for hiding this comment

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

Docs are approved

@wkerzendorf wkerzendorf merged commit bb4304b into tardis-sn:master Jan 27, 2022
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.

5 participants