-
Notifications
You must be signed in to change notification settings - Fork 639
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
[WIP] Issue 785 add auxiliary #868
[WIP] Issue 785 add auxiliary #868
Conversation
@@ -216,6 +224,9 @@ def __init__(self, n_atoms, **kwargs): | |||
self.has_forces = kwargs.get('forces', False) | |||
|
|||
self._unitcell = self._init_unitcell() | |||
|
|||
# set up aux namespace for adding auxiliary data | |||
self.aux = Namespace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just replace this with a simple dictionary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on how we want to access the auxiliary data. In all the discussions we assumed something like ts.aux.force
; this requires a class as what @fiona-naughton used. ts.aux['force']
is fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually would prefer the first ts.aux.force
because I can TAB complete very easily in an interactive session. (yeah I'm lazy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the Namespace solution. (tab-completion plus I'm lazy to type square brackets)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like it with the Namespace; it doesn't make much difference, but it's that little bit easier to type! (and it's nice to be lazy sometimes >_< )
Looks good. With the xvgreader, you can probably get away with reading the entire file at once, then seeking is just finding places in the numpy array that stores it. That said, all that is just an implementation detail, get the tests up and running as they will mostly stay the same as you keep working on this. These can (and should) be very simple, eg you could have an xvg file with just [1, 2, 3] in it, then check that reading this gives you 1, 2, 3 again. |
## the auxreader is the first step 'belonging' of the next ts... | ||
|
||
def reset_ts(self, ts): | ||
self.ts_data = np.array([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you're passing in ts
and not using it?
I just added a comment/question in #785 to expand on @richardjgowers' idea of reading data all at once. I raised this also because the current purpose of the |
d3bc64a
to
3875179
Compare
Ok so now the PR you did has gone through, you need to update your local version of develop (fetch and pull) and then merge develop into this branch to get the changes you recently made into this branch. You might get a merge conflict on files that changed in each branch, you just need to go over it carefully maybe using something like meld or diffuse. |
Please to a rebase instead of a merge. It keeps a cleaner history and it is easier to spot when the git-merge conflict solver does unintended things (removed code can reappear or added code can be deleted by accident!) |
Ah, just merged it sorry (but doesn't look like it even worked completely... I'm using GitHub desktop at the moment, and not entirely sure what it's done?). Might leave it to figure out tomorrow when I'm back at work and not on Windows... |
9de9ab3
to
77cf750
Compare
It seems that you broke something with
Since different readers are broken in the same way, the breakage most likely happened in the |
class Namespace(object): | ||
# set up a basic class so we can make an 'aux' namespace in Timestep | ||
# for auxiliary data; might be better defined elsewhere...? | ||
# There's probably a better way to do this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me as the good way and the good place to do this, as there seems to be a consensus around the namespace vs the dictionary. The class can be moved latter to .lib.util
if it get duplicated.
I've made a bunch of changes, largely to make the matching of auxiliary steps to trajectory timesteps a little nicer (I think) and hopefully clearer. There's now a (The failed tests were due to my forgetting to add a return line; it's fixed now. I'll finish properly writing up some tests for the new stuff and hopefully add that soon) |
When reading in a trajectory, auxiliary data steps are 'assigned' the | ||
closest trajectory timestep. | ||
|
||
Attributes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…election; assort fixes
…d error-raises when options invalid
…Namespace to Utils
Optimise perf from use of range in auxiliaries
fix step_to_frame when trajectory starts after 0
… various renaming and doc fixes
…ux take into account cutoff tidy docs + tests
f6d7d98
to
a9e067d
Compare
Rebased + had a go at squashing some of the commits - hopefully nothing went disastrously wrong and it still makes sense! |
Changes Unknown when pulling a9e067d on fiona-naughton:issue-785-add-auxiliary into * on MDAnalysis:develop*. |
Youhou! It is finally merged! Congrats! |
@fiona-naughton congratulations! Thank you for this exciting new feature and your participation in GSoC! I hope we see more of you, even after the end of GSoC. |
…uxiliary [WIP] Issue 785 add auxiliary
WIP for #785.
Currently, allows adding data from an xvg file to a trajectory by
add_auxiliary(filename, name, **kwargs)
. When reading the next trajectory timestep, the auxiliary timesteps closest to that trajectory timestep are read through, and a 'representative' value calculated from these and stored in the timestep in an aux namespace, asts.aux.name
. The 'representative' value can be either an average or the value from the closest timepoint (with an optional cutoff).The
XVGReader
itself also hasgo_to_step
andgo_to_ts
methods for jumping to specified auxiliary steps/trajectory timesteps; the latter's used to bring the auxiliary to the same time as the trajectory when it's first added, but I've not hooked it up with the equivalent trajectory method yet.There's a couple things that seem to work but I'm not sure I've gone about the right way (particularly the
go_to
methods; they currently just start reading form the top of the file and wait till the times match up...); apologies if I'm doing anything particularly silly!TODO
dt
, rather than trajectory'sPR Checklist