-
Notifications
You must be signed in to change notification settings - Fork 696
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
Add time step parameter to XTC Writers and Readers #4905
Comments
Create a PR and then we can see what this would look like. XTC and TRR files do not store the dt but include each individual time (and we just calculate dt from the first two frames) so I am not sure that the same approach as for DCD will work. You could try a custom on-the-fly transformation https://userguide.mdanalysis.org/stable/trajectories/transformations.html where you set the Timestep.time to frame * time: import MDAnalysis as mda; import MDAnalysisTests.datafiles as data
u = mda.Universe(data.TPR, data.XTC)
print("Original dt", u.trajectory.dt)
print("Original times", [ts.time for ts in u.trajectory]) gives
Now we are adding the transformation def set_time(dt):
"""Set time to frame * dt"""
def wrapped(ts):
ts.dt = dt
ts.time = ts.frame * dt
return ts
return wrapped
u.trajectory.add_transformations(set_time(33.33))
print("New dt", u.trajectory.dt)
print("New times", [ts.time for ts in u.trajectory]) and we get
(You can then analyze the trajectory or write it out to another XTC but with correct time stamps.) |
I think that #4908 should implement what I suggest. In general it is quite similar to |
Is your feature request related to a problem?
In some cases (when xtc is created with DESMOND) the timestep saved in xtc file is incorrect. It can be easier to set up the correct timestep for the loaded trajectory.
This feature is available for DCD writer and reader, and at least for the reader it should be straightforward to implement. I can work on it next week.
Describe the solution you'd like
Implement the support of timestep setting for XTC writer and reader.
Describe alternatives you've considered
My current workaround is to load xtc, then write dcd with the desired timestep and then read it back.
Additional context
The text was updated successfully, but these errors were encountered: