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

Introduce universally Timestep.time as part of the Reader/Timestep API #308

Closed
dotsdl opened this issue Jun 14, 2015 · 7 comments
Closed

Comments

@dotsdl
Copy link
Member

dotsdl commented Jun 14, 2015

Subtask of #252:

Introduce universally Timestep.time (as part of the API):

  • If the trajectory records time, it will contain the current frame's time (in MDA units)
  • If the trajectory records time between frames dt and frame numbers N, it will calculate the time as N * dt.
  • If the trajectory does not contain time information then log a warning and pretend that dt = 1 and use the N * dt calculated time.

deprecate Reader.time (for 1.0)

@richardjgowers
Copy link
Member

So with this I've realised that Timesteps don't actually have a pointer to their Reader. So to give time as dt * frame is impossible because the Timestep can't see Reader.dt.

@richardjgowers
Copy link
Member

Ah, I've just seen #307 fixes this, so this is reliant on that.

@dotsdl
Copy link
Member Author

dotsdl commented Jul 14, 2015

So with this I've realised that Timesteps don't actually have a pointer to their Reader. So to give time as dt * frame is impossible because the Timestep can't see Reader.dt.

Should we give Timesteps a pointer to their Reader? What are the reasons to do it / not to do it?

@richardjgowers
Copy link
Member

I actually started hacking on this today, what I did was make Reader.dt a property that updated its timestep.

I do like that Timesteps can work alone and are essentially a simple container, but maybe adding an optional hook to their Reader might simplify things.

@orbeckst
Copy link
Member

I'd leave Timesteps decoupled from Readers if possible. I don't think that anything will break horribly if it is included (unless we're talking pickling of Timestep instances...) but it is cleaner and it forces us to think properly through how to design both Timestep and Readers. #307 is a case in point and see #350 for discussion.

@richardjgowers
Copy link
Member

With this, I've changed it so that single frame readers now return a dt of 1.0 ps. They previously raised a KeyError. I figure this would make it more uniform for readers to always have a dt which you can kwarg in if you want. Might also help with the ChainReader issues. #309

Is this logic terrible?

@orbeckst
Copy link
Member

Makes sense and I don't think it will be a problem. Throwing the KeyError is pretty unhelpful (at least it should have been NoDataError or similar) but in the grand scheme of things not having to catch an exception for something one is unlikely to care about seems ok to me. Do add a warning and a version changed to the single frame reader Timestep, though.

richardjgowers added a commit that referenced this issue Jul 19, 2015
fixed, skip_timestep, periodic, skip and delta no longer required for
Readers (Issue #350)

All writers now refer to time between steps as "dt" (was previously
delta in XTC, TRR and NCDF Writers) (Issue #206)

Timesteps now have a default dt of 1.0 ps (and issue warning when using
this)

Timestep attribute time now tries to return data['time'] first, then dt
* frame, using the default value of 1.0 ps if necessary. (Issue #308)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants