Openpmd-api: Incorrect reading of patches (probably, incorrect datatype)

Created on 8 Nov 2019  路  4Comments  路  Source: openPMD/openPMD-api

Describe the bug
Incorrect reading of patches (probably, incorrect datatype).

An incorrect result is returned while reading patches. Records "numParticles", "numParticlesOffset" have wrong datatypes.
Patch_Record_Component.load() returned incorrect values
([ 40235664 140320876527616 1441437753781782131 15708555500268357122])
insead of ([321792, 76800, 321792, 76800])

To Reproduce

checkpoint_0_err.zip

Python:

import openpmd_api
series = openpmd_api.Series("checkpoint_0_err.h5", openpmd_api.Access_Type.read_only)

iteration = series.iterations[0]
carbon = iteration.particles["C"]
dataset = carbon.particle_patches["numParticles"][openpmd_api.Mesh_Record_Component.SCALAR].load()
print(dataset)

Software Environment

  • version of openPMD-api: 0.5.0-dev
  • installed openPMD-api via: pip install openpmd-api
  • operating system: Ubuntu 18.04.2
  • name and version of Python implementation: Python 3.6
  • version of HDF5: 1.10.0
Python3 question

Most helpful comment

Yes, now it works. Thank you for answer.:)

All 4 comments

Thank you for the report!

Are you sure you are using openPMD-api 0.5.0-dev and not 0.9.0-alpha or 0.10.0-dev?
Otherwise can you please update to the latest release?

I think I spotted an little bug in the usage. You have to call series.flush() before you can access the loaded data, otherwise it is still allocated but uninitialized (random).

import openpmd_api
SCALAR = api.Mesh_Record_Component.SCALAR

series = openpmd_api.Series("checkpoint_0_err.h5", openpmd_api.Access_Type.read_only)

iteration = series.iterations[0]
carbon = iteration.particles["C"]
numParticles = carbon.particle_patches["numParticles"][SCALAR].load()

series.flush()  # read all the data
print(numParticles)

(I am working on making this more comfortable in the future via #484, but a logic issue needs to be decluttered first inside some internal routines.)

Yes, now it works. Thank you for answer.:)

Great, glad this helped! :)
Feel free to open more issues if anything does not work as expected or if something is undocumented.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

titoiride picture titoiride  路  3Comments

ax3l picture ax3l  路  7Comments

lucafedeli88 picture lucafedeli88  路  3Comments

C0nsultant picture C0nsultant  路  5Comments

ax3l picture ax3l  路  4Comments