openPMD/openPMD-viewer

openpmd-api backend forgets modes m>1

Closed this issue · 5 comments

Hi,
this might a bit of an edge case issue but it caused a bit of confusion for me so I thought it might be good to document. I have the case where I load a timeseries (fbpic) in a jupyter notebook via d = LpaDiagnostics('lab_diags/hdf5', backend='openpmd-api'), and retrieve the fields with d.get_field(). Now I changed reran the simulation (going from 2 to 3 theta modes). After rerunning the cell to import the timeseries get_field() still returns the old fields now. With backend='h5py' I get the new data as expected.
Is there some sort of caching going on with the openpmd-api that needs to be cleared?

Hi,
sorry I think I misinterpreted the issue, I think the openpmd-api backend is returning the correct data. However it is missing the additional mode when calling get_field(m=2)

Thanks for reporting this!
Do you mean that get_field(m=2) essentially returns an array filled with 0?
or does it raise a Python exception?

ax3l commented

Hi @soerenjalas, can you please post a tiny example file and python example that demonstrates this for debugging?

I looked at the code but cannot spot an obvious bug right away.

Hi all,
sorry for the messy issue. I tried to create a small repro example:
data00000000.zip

The file contains an (empty) hdf5 output from fbpic with 3 modes.

Running,

d = OpenPMDTimeSeries('.', backend='h5py')
d.get_field(iteration=0, field='rho', m=2)

works fine, but

d = OpenPMDTimeSeries('.', backend='openpmd-api')
d.get_field(iteration=0, field='rho', m=2)

raises an OpenPMDException as if the file didn't contain mode 2.

OpenPMDException: The requested mode '2' is not available.
The available modes are: 
 - all
 - 0
 - 1

It looks like on the viewer side the code for h5py and openpmd-api is quite analogue, could this be an issue within the api?

Tested with this constellation:
openpmd-api 0.13.2
openpmd-viewer 1.1.0

ax3l commented

Thank you for the details, this is great!
Sorry for the slight delay - I proposed a fix in #313 based on your example data.