Closed kli-jfp closed 8 months ago
p_w = electrons["weighting"][io.Record_Component.SCALAR]
dataset = io.Dataset(np.dtype("float32"), extent=[N])
p_w.reset_dataset(dataset)
p_w.store_chunk(w)
I think that you used the example from the dev branch on GitHub? Can you try if this version helps you: https://github.com/openPMD/openPMD-api/blob/0.15.2/examples/7_extended_write_serial.py:
electrons["weighting"][SCALAR] \
.reset_dataset(Dataset(np.dtype("float32"), extent=[1])) \
.make_constant(1.e-5)
Specifying this [SCALAR]
bit is no longer necessary on the dev branch, but it's required in the released versions.
@ax3l The documentation at https://openpmd-api.readthedocs.io/en/0.15.2/usage/examples.html links to the dev versions of the examples, regularly causing confusion when there are API additions reflected in them. Is there any way to have the links point to the correct release?
Hi! I'm having trouble saving particle data, specifically weights, to a h5 file. I tried variations of the same code used in openPMD-api/examples/ /7_extended_write_serial.py,
but this gives an AttributeError: 'openpmd_api.openpmd_api_cxx.Record' object has no attribute 'reset_dataset'
This is the code I'm using. What is the correct way to store the weights (e.g. this h5 file is going to be used in a WarpX sim)?
Python:
Software Environment: I have installed openPMD-api with conda (ubuntu os) openpmd-api 0.15.1 pypi_0 pypi openpmd-viewer 1.6.0 pyhd8ed1ab_0 conda-forge