GromacsWrapper icon indicating copy to clipboard operation
GromacsWrapper copied to clipboard

XPM reader does not handle multiple frames

Open synapticarbors opened this issue 12 years ago • 2 comments

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.

synapticarbors avatar Feb 19 '13 18:02 synapticarbors

Ok, I'd be happy to integrate a patch!

orbeckst avatar Mar 12 '13 02:03 orbeckst

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.)

orbeckst avatar Nov 30 '15 05:11 orbeckst