-
Notifications
You must be signed in to change notification settings - Fork 658
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
Slicing fixes #916
Slicing fixes #916
Changes from 1 commit
93b52b0
9a58b1b
8145421
0649737
9e7d439
e9b6586
04dc85d
1983709
cb5852e
1b1d4f2
320b1dc
55910a0
83c7e4f
beffbea
8e24480
d687cc7
6893abd
6b27588
32fce06
68ae897
6f9e57d
e476ee5
d036859
0c268ed
d3d4dad
6833e3a
76ec586
0f62787
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ cdef extern from "correl.h": | |
|
||
import numpy as np | ||
|
||
def __read_timecorrel(object self, object atoms, object atomcounts, object format, object auxdata, int sizedata, int lowerb, int upperb, int start, int stop, int skip): | ||
def __read_timecorrel(object self, object atoms, object atomcounts, object format, object auxdata, int sizedata, int lowerb, int upperb, int start, int stop, int step): | ||
cdef dcdhandle* dcd | ||
cdef numpy.ndarray atomlist, atomcountslist, auxlist | ||
cdef numpy.ndarray data, temp | ||
|
@@ -69,8 +69,10 @@ def __read_timecorrel(object self, object atoms, object atomcounts, object forma | |
|
||
dcd = <dcdhandle*>PyCObject_AsVoidPtr(self._dcd_C_ptr) | ||
cdef int n_frames | ||
if (stop == -1): stop = dcd.nsets | ||
n_frames = (stop-start+1) / skip | ||
|
||
if stop == dcd.nsets: stop -= 1; | ||
n_frames = ((stop-start) / step) + 1; | ||
if (stop-start) % step == 0: n_frames -= 1; | ||
cdef int numdata | ||
numdata = len(format) | ||
if numdata==0: | ||
|
@@ -109,18 +111,25 @@ def __read_timecorrel(object self, object atoms, object atomcounts, object forma | |
cdef int index, numskip | ||
cdef int i, j | ||
cdef float unitcell[6] | ||
cdef int remaining_frames = stop-start | ||
numskip = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment said "We should check for fixed atoms here but we have not implemented it". I don't think that you are addressing fixed atoms anywhere (it's an obscure feature in CHARMM DCD files where only the first frame contains the positions of the frozen atoms and all later frames do not have these positions, which are unchanging.) Therefore, please leave this comment in. |
||
print n_frames | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
for i from 0 <= i < n_frames: | ||
if (skip > 1): | ||
if (step > 1 and i > 0): | ||
# Check if we have fixed atoms | ||
# XXX not done | ||
numskip = skip - (dcd.setsread % skip) - 1 | ||
numskip = step - 1 | ||
if(remaining_frames < numskip): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? Can you add a comment to explain, please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a comment, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks – I am interested in the summary of thoughts that go into these few lines (not "subtract one from step and call it numskip"....). Clearly, this is one of the key points where you put thought into so for others to quickly catch up it is important to get them on the right track when reading the code. |
||
numskip = 1 | ||
|
||
rc = skip_dcdstep(dcd.fd, dcd.natoms, dcd.nfixed, dcd.charmm, numskip) | ||
if (rc < 0): | ||
raise IOError("Error skipping frame from DCD file") | ||
dcd.setsread = dcd.setsread + numskip | ||
dcd.setsread = dcd.setsread + numskip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that this should now be one level out, i.e. not inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything is fine, current tests account for this, the logic is sound too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. Btw, can we write this aesthetically more pleasingly as dcd.setsread += numskip |
||
rc = read_dcdsubset(dcd.fd, dcd.natoms, lowerb, upperb, tempX, tempY, tempZ, unitcell, dcd.nfixed, dcd.first, dcd.freeind, dcd.fixedcoords, dcd.reverse, dcd.charmm) | ||
dcd.first=0 | ||
dcd.setsread = dcd.setsread + 1 | ||
dcd.first = 0 | ||
dcd.setsread += 1 | ||
remaining_frames = stop - dcd.setsread | ||
if (rc < 0): | ||
raise IOError("Error reading frame from DCD file") | ||
# Copy into data array based on format | ||
|
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.
add a comment to explain the
stop
gymnastics