-
Notifications
You must be signed in to change notification settings - Fork 661
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
H5MD
Can not read observables/<group>/<observable>/...
#4598
Comments
yes, this is related to point 1) in #4561 basically, At the moment, |
the same thing is happening in #4320 |
@PythonFZ how would you expect MDAnalysis to support groups, i.e., what exactly should be happening? |
I could reproduce with import MDAnalysis as mda
import numpy as np
u = mda.Universe.empty(100, n_residues=100, atom_resindex=np.arange(100), trajectory=True)
u.load_new("licl_100.h5", format="H5MD", convert_units=False) and failed with
If this is an otherwise legal H5MD file then we should be able to at least read the particles information, even if we ignore observables. So this may count as a bug in our H5MD reader and I tentatively assign the defect label. However, I tried reading
and note that @PythonFZ 's H5MD file cannot be loaded by pyh5md, presumably because it is missing the mandatory h5md root level group (see https://www.nongnu.org/h5md/h5md.html#h5md-root-level ). I don't have time to dissect the h5 file further so could you please comment and demonstrate that the test file does indeed fully conform to the spec? |
that's interesting... should our implementation also fail immediately if the root h5md group is missing? |
yes — it's mandatory |
Thanks for looking into this @orbeckst. This archive md.zip contains two updated files that fulfill the H5MD standard. The Both files have been created using
I think it would be beneficial to load the data into |
Observables in H5MD. Let's assume we have the below:
@PythonFZ, do you expect to always get What should happen when, say, as auxiliaries??We have solved some of these questions with the auxiliary readers already; for instance, auxiliaries can "hold" a value for steps where it wasn't recorded — the details are in Auxiliaries and trajectories. Perhaps it makes more sense to create an H5MD AuxReader (which may, under the hood, pull data out of the H5MDReader so that we don't open a trajectory twice) instead of trying to drop everything in The docs for auxiliaries are not very clear for users; at least the ones for the EDRReader and trajectories shows you what it looks like in practice and for h5md it might be u = mda.Universe(topology, "trj.h5md")
aux = mda.auxiliary.H5MD.H5MDObservablesReader(u.trajectory) # can pass reader instance!
u.trajectory.add_auxiliary({"obs1": "obervable1",
"group1_obs3": "group1/observable3"},
"group1/observable99": "group1/observable99"},
aux)
for ts in u.trajectory:
print("observable1 = ", ts.aux.obs1)
print("observable3 (group1) = ", ts.aux.group1_obs3)
print("observable99 (group 1) = ", ts.aux["group1/observable99"]) # only dict Would this be of interest? It's also helpful if you write out code that you would have liked to use because that tells us how we should be structuring our user interface. (Also, there are no promises that anyone is actually going to work on any of this. But if enough people think it would be useful then it becomes more attractive as a project for someone to pick it up.) |
I think the flexible timesteps in general are difficult to handle. I'd suggest to do this in two steps:
I'm happy to help with this. Currently, I don't have a use case for the
|
Xref: #4615 (review) prototype for just dumping observables of the |
* skip observables contained in particle groups * This is not a fix for #4598 but enables reading files that contain data in observables \-- <group1> | \-- <observable2> | \-- step: Integer[variable] | \-- time: Float[variable] | \-- value: <type>[variable][D][D] * add test: open file * add and test with `malformed.h5md` * update CHANGELOG * Update AUTHORS --------- Co-authored-by: Hugo MacDermott-Opeskin <hugomacdermott@gmail.com> Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
Expected behavior
The H5MD standard defines two main ways to define observables. Either directly as group below the root
observables
or as a group specific observableobservables/group
.Both should be supported.
Actual behavior
In my experience only the observables after root are supported but
observables/group
are not. It leads toKeyError: "Unable to synchronously open object (object 'value' doesn't exist)"
. This seems to be briefly discussed in #4320 but I wanted to give more information here.Code to reproduce the behavior
I've attached a file licl_100.h5.zip because the
cobrotoxin.h5md
test file only containsobservables/lambda
but no group specific observables.Current version of MDAnalysis
python -c "import MDAnalysis as mda; print(mda.__version__)"
) 2.7.0python -V
)? 3.10.9The text was updated successfully, but these errors were encountered: