-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
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 | ||
|
There was a problem hiding this comment.
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
,
There was a problem hiding this comment.
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.
* 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
## 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
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
andcuDF
particle data frames... (follow-up PRs).