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

[WIP] Script: Filter & Copy Particles #1390

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Mar 21, 2023

Notebook that filters & copies particles and their attributes in chunk-wise (fixed slice) manner. This is a prototype of functionality.

The filter can be a criteria on any point-wise combination of records of the current slice/chunk.

This is a common data map-reduce operation and we need to provide a API/tool for this functionality to filter very large data sets for interesting particles. Example: laser-plasma beam from a laser-plasma source, filtered by momentum and position.

We could maybe implement this in openpmd-pipe.

Alternatively, we could parallelize this as a tool and simplify it. Our pandas converter could simplify filters and chunking for the actual data. We could implement a lazily evaluated from_df for writing.
Or we could extent our Dask reader and even could think about parallelism.

@ax3l ax3l added this to the 0.16.0 milestone Mar 21, 2023
@ax3l ax3l requested a review from franzpoeschel March 21, 2023 01:10
@ax3l ax3l changed the title Script: Filter & Copy Particles [WIP] Script: Filter & Copy Particles Mar 21, 2023
Notebook that filters & copies particles and their attributes in
chunk-wise (fixed slice) manner.
... and do only one time step.
@franzpoeschel
Copy link
Contributor

We could maybe implement this in openpmd-pipe.

The Notebook does reimplement a lot of the functionality that openPMD-pipe has already, yes.
One major difference:
openpmd-pipe does all operations per iteration at once, there is only one flush per Series and iteration. This is in order to reduce communication in streaming situations. In your Notebook, you do sliced reading/writing in order to save memory.
We don't really have a notion of IO-flexibility in this question..

@ax3l
Copy link
Member Author

ax3l commented Mar 28, 2023

I realized the attribute copying changes a few attributes, some of which are then unexpected types and need to be fixed/preserved in type:

  EXTRACT                                                                                                 INPUT
  string    /author                                                       attr				  string    /author                                                       attr
  string    /basePath                                                     attr				  string    /basePath                                                     attr
  uint8_t   /data/9000/closed                                             attr				  uint8_t   /data/9000/closed                                             attr
  double    /data/9000/dt                                                 attr				  double    /data/9000/dt                                                 attr
  uint8_t   /data/9000/particles/electrons/charge/macroWeighted           attr			   |	  uint32_t  /data/9000/particles/electrons/charge/macroWeighted           attr
  uint64_t  /data/9000/particles/electrons/charge/shape                   attr				  uint64_t  /data/9000/particles/electrons/charge/shape                   attr
  double    /data/9000/particles/electrons/charge/timeOffset              attr			   |	  float     /data/9000/particles/electrons/charge/timeOffset              attr
  double    /data/9000/particles/electrons/charge/unitDimension           attr				  double    /data/9000/particles/electrons/charge/unitDimension           attr
  double    /data/9000/particles/electrons/charge/unitSI                  attr				  double    /data/9000/particles/electrons/charge/unitSI                  attr
  double    /data/9000/particles/electrons/charge/value                   attr				  double    /data/9000/particles/electrons/charge/value                   attr
  double    /data/9000/particles/electrons/charge/weightingPower          attr				  double    /data/9000/particles/electrons/charge/weightingPower          attr
  string    /data/9000/particles/electrons/currentDeposition              attr				  string    /data/9000/particles/electrons/currentDeposition              attr
  uint8_t   /data/9000/particles/electrons/id/macroWeighted               attr			   |	  uint32_t  /data/9000/particles/electrons/id/macroWeighted               attr
  double    /data/9000/particles/electrons/id/timeOffset                  attr			   |	  float     /data/9000/particles/electrons/id/timeOffset                  attr
  double    /data/9000/particles/electrons/id/unitDimension               attr				  double    /data/9000/particles/electrons/id/unitDimension               attr
  double    /data/9000/particles/electrons/id/unitSI                      attr				  double    /data/9000/particles/electrons/id/unitSI                      attr
  double    /data/9000/particles/electrons/id/weightingPower              attr				  double    /data/9000/particles/electrons/id/weightingPower              attr
  uint8_t   /data/9000/particles/electrons/mass/macroWeighted             attr			   |	  uint32_t  /data/9000/particles/electrons/mass/macroWeighted             attr
  uint64_t  /data/9000/particles/electrons/mass/shape                     attr				  uint64_t  /data/9000/particles/electrons/mass/shape                     attr
  double    /data/9000/particles/electrons/mass/timeOffset                attr			   |	  float     /data/9000/particles/electrons/mass/timeOffset                attr
  double    /data/9000/particles/electrons/mass/unitDimension             attr				  double    /data/9000/particles/electrons/mass/unitDimension             attr
  double    /data/9000/particles/electrons/mass/unitSI                    attr				  double    /data/9000/particles/electrons/mass/unitSI                    attr
  double    /data/9000/particles/electrons/mass/value                     attr				  double    /data/9000/particles/electrons/mass/value                     attr
  double    /data/9000/particles/electrons/mass/weightingPower            attr				  double    /data/9000/particles/electrons/mass/weightingPower            attr
  uint8_t   /data/9000/particles/electrons/momentum/macroWeighted         attr			   |	  uint32_t  /data/9000/particles/electrons/momentum/macroWeighted         attr
  double    /data/9000/particles/electrons/momentum/timeOffset            attr			   |	  float     /data/9000/particles/electrons/momentum/timeOffset            attr
  double    /data/9000/particles/electrons/momentum/unitDimension         attr				  double    /data/9000/particles/electrons/momentum/unitDimension         attr
  double    /data/9000/particles/electrons/momentum/weightingPower        attr				  double    /data/9000/particles/electrons/momentum/weightingPower        attr
  double    /data/9000/particles/electrons/momentum/x/unitSI              attr				  double    /data/9000/particles/electrons/momentum/x/unitSI              attr
  double    /data/9000/particles/electrons/momentum/y/unitSI              attr				  double    /data/9000/particles/electrons/momentum/y/unitSI              attr
  double    /data/9000/particles/electrons/momentum/z/unitSI              attr				  double    /data/9000/particles/electrons/momentum/z/unitSI              attr
  string    /data/9000/particles/electrons/particleInterpolation          attr				  string    /data/9000/particles/electrons/particleInterpolation          attr
  string    /data/9000/particles/electrons/particlePush                   attr				  string    /data/9000/particles/electrons/particlePush                   attr
  double    /data/9000/particles/electrons/particleShape                  attr				  double    /data/9000/particles/electrons/particleShape                  attr
  double    /data/9000/particles/electrons/particleShapes                 attr				  double    /data/9000/particles/electrons/particleShapes                 attr
  string    /data/9000/particles/electrons/particleSmoothing              attr				  string    /data/9000/particles/electrons/particleSmoothing              attr
  uint8_t   /data/9000/particles/electrons/position/macroWeighted         attr			   |	  uint32_t  /data/9000/particles/electrons/position/macroWeighted         attr
  uint8_t   /data/9000/particles/electrons/positionOffset/macroWeighted   attr			   |	  uint32_t  /data/9000/particles/electrons/positionOffset/macroWeighted   attr
  double    /data/9000/particles/electrons/positionOffset/timeOffset      attr			   |	  float     /data/9000/particles/electrons/positionOffset/timeOffset      attr
  double    /data/9000/particles/electrons/positionOffset/unitDimension   attr				  double    /data/9000/particles/electrons/positionOffset/unitDimension   attr
  double    /data/9000/particles/electrons/positionOffset/weightingPower  attr				  double    /data/9000/particles/electrons/positionOffset/weightingPower  attr
  uint64_t  /data/9000/particles/electrons/positionOffset/x/shape         attr				  uint64_t  /data/9000/particles/electrons/positionOffset/x/shape         attr
  double    /data/9000/particles/electrons/positionOffset/x/unitSI        attr				  double    /data/9000/particles/electrons/positionOffset/x/unitSI        attr
  double    /data/9000/particles/electrons/positionOffset/x/value         attr				  double    /data/9000/particles/electrons/positionOffset/x/value         attr
  uint64_t  /data/9000/particles/electrons/positionOffset/y/shape         attr				  uint64_t  /data/9000/particles/electrons/positionOffset/y/shape         attr
  double    /data/9000/particles/electrons/positionOffset/y/unitSI        attr				  double    /data/9000/particles/electrons/positionOffset/y/unitSI        attr
  double    /data/9000/particles/electrons/positionOffset/y/value         attr				  double    /data/9000/particles/electrons/positionOffset/y/value         attr
  uint64_t  /data/9000/particles/electrons/positionOffset/z/shape         attr				  uint64_t  /data/9000/particles/electrons/positionOffset/z/shape         attr
  double    /data/9000/particles/electrons/positionOffset/z/unitSI        attr				  double    /data/9000/particles/electrons/positionOffset/z/unitSI        attr
  double    /data/9000/particles/electrons/positionOffset/z/value         attr				  double    /data/9000/particles/electrons/positionOffset/z/value         attr
  double    /data/9000/particles/electrons/position/timeOffset            attr			   |	  float     /data/9000/particles/electrons/position/timeOffset            attr
  double    /data/9000/particles/electrons/position/unitDimension         attr				  double    /data/9000/particles/electrons/position/unitDimension         attr
  double    /data/9000/particles/electrons/position/weightingPower        attr				  double    /data/9000/particles/electrons/position/weightingPower        attr
  double    /data/9000/particles/electrons/position/x/unitSI              attr				  double    /data/9000/particles/electrons/position/x/unitSI              attr
  double    /data/9000/particles/electrons/position/y/unitSI              attr				  double    /data/9000/particles/electrons/position/y/unitSI              attr
  double    /data/9000/particles/electrons/position/z/unitSI              attr				  double    /data/9000/particles/electrons/position/z/unitSI              attr
  uint8_t   /data/9000/particles/electrons/weighting/macroWeighted        attr			   |	  uint32_t  /data/9000/particles/electrons/weighting/macroWeighted        attr
  double    /data/9000/particles/electrons/weighting/timeOffset           attr			   |	  float     /data/9000/particles/electrons/weighting/timeOffset           attr
  double    /data/9000/particles/electrons/weighting/unitDimension        attr				  double    /data/9000/particles/electrons/weighting/unitDimension        attr
  double    /data/9000/particles/electrons/weighting/unitSI               attr				  double    /data/9000/particles/electrons/weighting/unitSI               attr
  double    /data/9000/particles/electrons/weighting/weightingPower       attr				  double    /data/9000/particles/electrons/weighting/weightingPower       attr
  uint8_t   /data/9000/particles/hydrogen/charge/macroWeighted            attr			   |	  uint32_t  /data/9000/particles/hydrogen/charge/macroWeighted            attr
  uint64_t  /data/9000/particles/hydrogen/charge/shape                    attr				  uint64_t  /data/9000/particles/hydrogen/charge/shape                    attr
  double    /data/9000/particles/hydrogen/charge/timeOffset               attr			   |	  float     /data/9000/particles/hydrogen/charge/timeOffset               attr
  double    /data/9000/particles/hydrogen/charge/unitDimension            attr				  double    /data/9000/particles/hydrogen/charge/unitDimension            attr
  double    /data/9000/particles/hydrogen/charge/unitSI                   attr				  double    /data/9000/particles/hydrogen/charge/unitSI                   attr
  double    /data/9000/particles/hydrogen/charge/value                    attr				  double    /data/9000/particles/hydrogen/charge/value                    attr
  double    /data/9000/particles/hydrogen/charge/weightingPower           attr				  double    /data/9000/particles/hydrogen/charge/weightingPower           attr
  string    /data/9000/particles/hydrogen/currentDeposition               attr				  string    /data/9000/particles/hydrogen/currentDeposition               attr
  uint8_t   /data/9000/particles/hydrogen/id/macroWeighted                attr			   |	  uint32_t  /data/9000/particles/hydrogen/id/macroWeighted                attr
  double    /data/9000/particles/hydrogen/id/timeOffset                   attr			   |	  float     /data/9000/particles/hydrogen/id/timeOffset                   attr
  double    /data/9000/particles/hydrogen/id/unitDimension                attr				  double    /data/9000/particles/hydrogen/id/unitDimension                attr
  double    /data/9000/particles/hydrogen/id/unitSI                       attr				  double    /data/9000/particles/hydrogen/id/unitSI                       attr
  double    /data/9000/particles/hydrogen/id/weightingPower               attr				  double    /data/9000/particles/hydrogen/id/weightingPower               attr
  uint8_t   /data/9000/particles/hydrogen/mass/macroWeighted              attr			   |	  uint32_t  /data/9000/particles/hydrogen/mass/macroWeighted              attr
  uint64_t  /data/9000/particles/hydrogen/mass/shape                      attr				  uint64_t  /data/9000/particles/hydrogen/mass/shape                      attr
  double    /data/9000/particles/hydrogen/mass/timeOffset                 attr			   |	  float     /data/9000/particles/hydrogen/mass/timeOffset                 attr
  double    /data/9000/particles/hydrogen/mass/unitDimension              attr				  double    /data/9000/particles/hydrogen/mass/unitDimension              attr
  double    /data/9000/particles/hydrogen/mass/unitSI                     attr				  double    /data/9000/particles/hydrogen/mass/unitSI                     attr
  double    /data/9000/particles/hydrogen/mass/value                      attr				  double    /data/9000/particles/hydrogen/mass/value                      attr
  double    /data/9000/particles/hydrogen/mass/weightingPower             attr				  double    /data/9000/particles/hydrogen/mass/weightingPower             attr
  uint8_t   /data/9000/particles/hydrogen/momentum/macroWeighted          attr			   |	  uint32_t  /data/9000/particles/hydrogen/momentum/macroWeighted          attr
  double    /data/9000/particles/hydrogen/momentum/timeOffset             attr			   |	  float     /data/9000/particles/hydrogen/momentum/timeOffset             attr
  double    /data/9000/particles/hydrogen/momentum/unitDimension          attr				  double    /data/9000/particles/hydrogen/momentum/unitDimension          attr
  double    /data/9000/particles/hydrogen/momentum/weightingPower         attr				  double    /data/9000/particles/hydrogen/momentum/weightingPower         attr
  double    /data/9000/particles/hydrogen/momentum/x/unitSI               attr				  double    /data/9000/particles/hydrogen/momentum/x/unitSI               attr
  double    /data/9000/particles/hydrogen/momentum/y/unitSI               attr				  double    /data/9000/particles/hydrogen/momentum/y/unitSI               attr
  double    /data/9000/particles/hydrogen/momentum/z/unitSI               attr				  double    /data/9000/particles/hydrogen/momentum/z/unitSI               attr
  string    /data/9000/particles/hydrogen/particleInterpolation           attr				  string    /data/9000/particles/hydrogen/particleInterpolation           attr
  string    /data/9000/particles/hydrogen/particlePush                    attr				  string    /data/9000/particles/hydrogen/particlePush                    attr
  double    /data/9000/particles/hydrogen/particleShape                   attr				  double    /data/9000/particles/hydrogen/particleShape                   attr
  double    /data/9000/particles/hydrogen/particleShapes                  attr				  double    /data/9000/particles/hydrogen/particleShapes                  attr
  string    /data/9000/particles/hydrogen/particleSmoothing               attr				  string    /data/9000/particles/hydrogen/particleSmoothing               attr
  uint8_t   /data/9000/particles/hydrogen/position/macroWeighted          attr			   |	  uint32_t  /data/9000/particles/hydrogen/position/macroWeighted          attr
  uint8_t   /data/9000/particles/hydrogen/positionOffset/macroWeighted    attr			   |	  uint32_t  /data/9000/particles/hydrogen/positionOffset/macroWeighted    attr
  double    /data/9000/particles/hydrogen/positionOffset/timeOffset       attr			   |	  float     /data/9000/particles/hydrogen/positionOffset/timeOffset       attr
  double    /data/9000/particles/hydrogen/positionOffset/unitDimension    attr				  double    /data/9000/particles/hydrogen/positionOffset/unitDimension    attr
  double    /data/9000/particles/hydrogen/positionOffset/weightingPower   attr				  double    /data/9000/particles/hydrogen/positionOffset/weightingPower   attr
  uint64_t  /data/9000/particles/hydrogen/positionOffset/x/shape          attr				  uint64_t  /data/9000/particles/hydrogen/positionOffset/x/shape          attr
  double    /data/9000/particles/hydrogen/positionOffset/x/unitSI         attr				  double    /data/9000/particles/hydrogen/positionOffset/x/unitSI         attr
  double    /data/9000/particles/hydrogen/positionOffset/x/value          attr				  double    /data/9000/particles/hydrogen/positionOffset/x/value          attr
  uint64_t  /data/9000/particles/hydrogen/positionOffset/y/shape          attr				  uint64_t  /data/9000/particles/hydrogen/positionOffset/y/shape          attr
  double    /data/9000/particles/hydrogen/positionOffset/y/unitSI         attr				  double    /data/9000/particles/hydrogen/positionOffset/y/unitSI         attr
  double    /data/9000/particles/hydrogen/positionOffset/y/value          attr				  double    /data/9000/particles/hydrogen/positionOffset/y/value          attr
  uint64_t  /data/9000/particles/hydrogen/positionOffset/z/shape          attr				  uint64_t  /data/9000/particles/hydrogen/positionOffset/z/shape          attr
  double    /data/9000/particles/hydrogen/positionOffset/z/unitSI         attr				  double    /data/9000/particles/hydrogen/positionOffset/z/unitSI         attr
  double    /data/9000/particles/hydrogen/positionOffset/z/value          attr				  double    /data/9000/particles/hydrogen/positionOffset/z/value          attr
  double    /data/9000/particles/hydrogen/position/timeOffset             attr			   |	  float     /data/9000/particles/hydrogen/position/timeOffset             attr
  double    /data/9000/particles/hydrogen/position/unitDimension          attr				  double    /data/9000/particles/hydrogen/position/unitDimension          attr
  double    /data/9000/particles/hydrogen/position/weightingPower         attr				  double    /data/9000/particles/hydrogen/position/weightingPower         attr
  double    /data/9000/particles/hydrogen/position/x/unitSI               attr				  double    /data/9000/particles/hydrogen/position/x/unitSI               attr
  double    /data/9000/particles/hydrogen/position/y/unitSI               attr				  double    /data/9000/particles/hydrogen/position/y/unitSI               attr
  double    /data/9000/particles/hydrogen/position/z/unitSI               attr				  double    /data/9000/particles/hydrogen/position/z/unitSI               attr
  uint8_t   /data/9000/particles/hydrogen/weighting/macroWeighted         attr			   |	  uint32_t  /data/9000/particles/hydrogen/weighting/macroWeighted         attr
  double    /data/9000/particles/hydrogen/weighting/timeOffset            attr			   |	  float     /data/9000/particles/hydrogen/weighting/timeOffset            attr
  double    /data/9000/particles/hydrogen/weighting/unitDimension         attr				  double    /data/9000/particles/hydrogen/weighting/unitDimension         attr
  double    /data/9000/particles/hydrogen/weighting/unitSI                attr				  double    /data/9000/particles/hydrogen/weighting/unitSI                attr
  double    /data/9000/particles/hydrogen/weighting/weightingPower        attr				  double    /data/9000/particles/hydrogen/weighting/weightingPower        attr
  double    /data/9000/time                                               attr				  double    /data/9000/time                                               attr
  double    /data/9000/timeUnitSI                                         attr				  double    /data/9000/timeUnitSI                                         attr
  string    /date                                                         attr				  string    /date                                                         attr
  string    /iterationEncoding                                            attr				  string    /iterationEncoding                                            attr
  string    /iterationFormat                                              attr				  string    /iterationFormat                                              attr
  string    /meshesPath                                                   attr				  string    /meshesPath                                                   attr
  string    /openPMD                                                      attr				  string    /openPMD                                                      attr
  uint8_t   /openPMDextension                                             attr			   |	  uint32_t  /openPMDextension                                             attr
  uint64_t  __openPMD_internal/openPMD2_adios2_schema                     attr			   <
  uint8_t   __openPMD_internal/useSteps                                   attr				  uint8_t   __openPMD_internal/useSteps                                   attr
  string    /particlesPath                                                attr				  string    /particlesPath                                                attr
  string    /software                                                     attr				  string    /software                                                     attr
  string    /softwareVersion                                              attr				  string    /softwareVersion                                              attr

@ax3l
Copy link
Member Author

ax3l commented Mar 29, 2023

Added a work-around to conserve particle attribute dtypes more carefully.

dataset.options = json.dumps(dataset_config_resizable)
out_p_rc.reset_dataset(dataset)
out_p_rc[out_slice] = data[accepted]
output_series.flush()
Copy link
Member Author

Choose a reason for hiding this comment

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

We could avoid OOM for the output of the while step by using:

  • BP5 and adding
  • flush_target="disk"

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking into the documentation on this, I notice a documentation bug.
https://openpmd-api.readthedocs.io/en/0.15.1/backends/adios2.html mentions adios2.preferred_flush_target = "disk" while https://openpmd-api.readthedocs.io/en/0.15.1/details/backendconfig.html talks of adios2.engine.preferred_flush_target = "disk".
The correct one is with engine, so: series.flush("""adios2.engine.preferred_flush_target = "disk" """)

}
}
}
dataset_config['adios2']['dataset'] = {
Copy link
Member Author

Choose a reason for hiding this comment

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

This should work now with ADIOS 2.9.0+

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.

2 participants