GromacsWrapper
GromacsWrapper copied to clipboard
XPM reader does not handle multiple frames
In attempting to read an .xpm file generated by g_mdmat with the -frames flag, the xpm reader fails with the error:
216 s = self.unquote(line)
--> 217 data[:, iy] = [colors[s[k:k+nb]] for k in xrange(0,nx,nb)]
218 self.logger.debug("read row %d with %d columns: '%s....%s'",
219 iy, data.shape[0], s[:4], s[-4:])
KeyError: ' '
The xpm reader should probably detect multi-frame files, and either stack them into a 3D numpy array, or fail gracefully with an output to the reader that only single frames can be read.
I'm going to take a crack at proper handling of multi-frame files and will submit a pull request when I get it working.
Ok, I'd be happy to integrate a patch!
Joao M. Damas suggested on gmx-users (24 Oct 2014) numerical matrix from xpm file that the next line should read:
data[:, iy] = [colors[j[k:k+nb]] for k in range(0,nx*nb,nb)]
"if one is using higher -nlevels for the .xpm construction (in g_rms, for example)"
Someone would need to test it.
(I just found the above comment in the source code and added it to the issue tracker so that it does not get forgotten completely.)