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

Coordinates don't exist in output error - document hdf5 heirarchy #54

Closed
samiransen23 opened this issue Mar 30, 2021 · 9 comments
Closed
Labels
bug Something isn't working

Comments

@samiransen23
Copy link
Contributor

Coordinates don't exist in output error for utils/hdf_to_gro.py

python3 utils/hdf_to_gro.py sim.h5 --out traj.gro
>
Traceback (most recent call last):
  File "utils/hdf_to_gro.py", line 18, in <module>
    shape = f_hd5["coordinates"].shape[0]
...
KeyError: "Unable to open object (object 'coordinates' doesn't exist)"

sim.h5 is a short trajectory output of the sample dppc.gro in HyMD-2021/

@samiransen23
Copy link
Contributor Author

> f_hd5 = h5py.File(args.hdf5_file, "r")
> f_hdf5.keys()
<KeysViewHDF5 ['connectivity', 'h5md', 'observables', 'parameters', 'particles']>
> particles = f_hd5.get('particles')
> particles
<HDF5 group "/particles" (1 members)>
> np.array(particles)
['all']

A 'particles'-like attribute called 'coordinates' should exist.

@samiransen23
Copy link
Contributor Author

'coordinates' is an attribute for the input .h5 file, not for the output sim.h5
'time' exists for the output sim.h5 and not for the input .h5 of course, so I don't know why utils/hdf_to_gro.py uses both time and coordinates as attributes

@samiransen23 samiransen23 changed the title Coordinates don't exist in output error Coordinates don't exist in output error - document hdf5 heirarchy Mar 30, 2021
@Lun4m
Copy link
Member

Lun4m commented Mar 30, 2021

Isn't there a "position" attribute inside "particles"?

@samiransen23
Copy link
Contributor Author

samiransen23 commented Mar 30, 2021 via email

@samiransen23 samiransen23 added the bug Something isn't working label Mar 30, 2021
@mortele
Copy link
Member

mortele commented Mar 30, 2021

Isn't there a "position" attribute inside "particles"?

Actually, the H5MD format specification states that the structure should be

particles
 \-- <group1>
      \-- box
      \-- (position)
      |    \-- step: Integer[variable]
      |    \-- time: Float[variable]
      |    \-- value: <type>[variable][N][D]

with the particle coordinates being called position and not coordinates. Not sure why this is the case in our output, probably because the old output Sigbjørn wrote had them named as such. We should change this at some point. Glancing over the VMD plugin code, it seems to also expect the coordinates in an HDF5 property called /particles/all/position.

@mortele
Copy link
Member

mortele commented Mar 30, 2021

Something like this: f_hd5['particles/all/position’] Working on it to make the conversion work. Now it doesn’t. Samiran Sen --------------------------------------- Hylleraas Centre for Quantum Molecular Sciences, University of Oslo, Norway

On 30 Mar 2021, at 11:45, Manuel Carrer @.***> wrote: Isn't there a "position" attribute inside "particles"? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#54 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOHBZUVOSFG3HIZ6J4EUFQ3TGGMSPANCNFSM42BOFY7A.

Not entirely sure if you fixed this yet or what you want to use it for, but #5 and #31 might be useful for functionality to convert HyMD output to HyMD input if that is your intended use.

@samiransen23
Copy link
Contributor Author

Isn't there a "position" attribute inside "particles"?

Actually, the H5MD format specification states that the structure should be

particles
 \-- <group1>
      \-- box
      \-- (position)
      |    \-- step: Integer[variable]
      |    \-- time: Float[variable]
      |    \-- value: <type>[variable][N][D]

with the particle coordinates being called position and not coordinates. Not sure why this is the case in our output, probably because the old output Sigbjørn wrote had them named as such. We should change this at some point. Glancing over the VMD plugin code, it seems to also expect the coordinates in an HDF5 property called /particles/all/position.

Exactly...there is a nomenclature mismatch between input and output files, though both are .h5 files.

@mortele
Copy link
Member

mortele commented Mar 30, 2021

@samiransen23 Yes, I think we talked about matching them up in one of our previous meetings, just no one got around to actually doing it yet. It is an artifact of Sigbjørn using a different standard of trajectory output in the earlier code. H5MD is just one of several different trajectory format specifications that people have defined under the HDF5 file type. I believe the one Sigbjørn was (somewhat loosely) following was MDTraj HDF5.

@mortele
Copy link
Member

mortele commented Apr 17, 2021

Closing this, moving discussion about format and changing input/output to #79. Discussion about hdf_to_gro.py not working moved to #80.

@mortele mortele closed this as completed Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants