openPMD / openPMD/openPMD-api

Reading a sample of particle data - list-indexing

Open
#1,335 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
161
Forks
59
Avg merge
2d 22h
Merged PRs (30d)
7

Description

It appears to not be possible to select a "sample" of particles from a file except by reading all particles (en-block or in chunks) and selecting thereafter.

I'd like to be able to read the particle data (here: positions) only for a list of particle indices:

An attempt along the lines of :
```python

timestep=106000
species="e"
particleIndices = [1024, 123, 42]

iteration = series.iterations[timestep]
xpos_incell = iteration.particles[species]["position"]["x"][particleIndices]
```

fails with the following:
```
TypeError: __getitem__(): incompatible function arguments. The following argument types are supported:
1. (self: openpmd_api.openpmd_api_cxx.Record_Component, tuple of index slices: tuple) -> numpy.ndarray
2. (self: openpmd_api.openpmd_api_cxx.Record_Component, slice: slice) -> numpy.ndarray
3. (self: openpmd_api.openpmd_api_cxx.Record_Component, axis index: int) -> numpy.ndarray

[...]
```

If such an access is not envisioned this should be noted explicitly (e.g. in the documentation). If there is a way of achieving the above I'd welcome the help.

**Software Environment:**
Using openPMD 0.14.4 installed from source and reading from an ADIOS2 file.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.