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

Pandas: ParticleContainer_*.to_df() #220

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Nov 5, 2023

Copy all particles into a pandas.DataFrame. Supports local and MPI-gathered results.

Future Directions (Attribute Names in AMReX)

At the moment, we make up generic names for the AoS and SoA attributes when we convert them to numpy, cupy and pandas.

It would generally be nice if AMReX supported the functionality to name particle attributes. In WarpX, we added this as NamedParticleContainer, but as a mainstream implementation we could avoid deriving yet another class type (because if we do, we will again have additional compile-time to bind that custom type in pyAMReX), and instead could just extend the particle classes with these runtime details.

Future Directions (Write)

Once the AMReX SoA transition is complete in:

we might even be able to provide node-local, zero-copy write access in Pandas and cuDF particle data frames... (follow-up PRs).

Copy all particles into a `pandas.DataFrame`. Supports local and
MPI-gathered results.
next_df[f"SoA_real_{idx}"] = array
for idx, array in enumerate(soa_np_int):
next_df[f"SoA_int_{idx}"] = array

Copy link
Member Author

@ax3l ax3l Nov 5, 2023

Choose a reason for hiding this comment

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

todo: I think this might miss on the runtime attributes (they are also in SoA format).

This should go into SoA::to_numpy aka soa_to_numpy & soa_to_cupy,

Copy link
Member Author

Choose a reason for hiding this comment

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

Requires to call:

  • AddRealComp
  • query current number of real components
  • call ResizeRuntimeRealComp again with redundant info (again the comm and number of components)

but AMReX-Codes/amrex#3615 could simplify this.

@ax3l ax3l mentioned this pull request Nov 5, 2023
7 tasks
@ax3l ax3l merged commit 038727f into AMReX-Codes:development Nov 6, 2023
25 checks passed
@ax3l ax3l deleted the topic-pc-to-df branch November 6, 2023 19:48
ax3l added a commit to ax3l/impactx that referenced this pull request Nov 9, 2023
ax3l added a commit to ax3l/impactx that referenced this pull request Nov 19, 2023
ax3l added a commit to ax3l/impactx that referenced this pull request Nov 20, 2023
ax3l added a commit to ax3l/impactx that referenced this pull request Nov 20, 2023
ax3l added a commit to ax3l/impactx that referenced this pull request Nov 20, 2023
ax3l added a commit to ECP-WarpX/impactx that referenced this pull request Nov 20, 2023
* Pandas: `ImpactXParticleContainer.to_df()`

Copy all particles into a `pandas.DataFrame`.
Supports local and MPI-gathered results.

* AMReX & pyAMReX: latest development

X-ref:
AMReX-Codes/pyamrex#220

* DataFrame: Add Test
atmyers pushed a commit to AMReX-Codes/amrex that referenced this pull request Mar 29, 2024
## Summary

When adding new `Real`/`Int` runtime components, they could be made
available without additional calls.

The cost should be the same as calling it explicitly later, but
clarifies the usage. Alternatively, we should add API contract details
to the `AddRealComp`/`AddIntComp` doc strings to make sure people use it
right.

## Additional background

- AMReX-Codes/pyamrex#220
- AMReX-Codes/pyamrex#222

## Checklist

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [x] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant