Hi Jason and Thomas,
Thx for you suggestions, Maps are definitely the way to go, and I already have the data it in a numpy array. I also found a nifty example from brick01.py in the examples directory, but to get it to render in linux, numpy needs to be compiled into PyMOL, does this also hold for Your solution Thomas? Loading directly from Python is the way to go in the future.
In the meantime I solved my problem by writing a small script that dumps the data in dx file format, which can subsequently be loaded into PyMOL.
# Esben Jannik Bjerrum 2014
#Write DX format
nx,ny,nz = 100,100,100 # Number of grid point in X,y,z dim
xmin,ymin,zmin = 0,0,0 # coordinate of grid lowest corner.
hx = hy = hz = 0.2 #Spacing between
f = open("tester.dx","w")
f.write("object 1 class gridpositions counts %s %s %s\n"% (nx,ny,nz))
f.write("origin %s %s %s\n"% (xmin,ymin,zmin))
f.write("delta %s 0.0 0.0\ndelta 0.0 %s 0.0\ndelta 0.0 0.0 %s\n"%(hx,hy,hz))
f.write("object 2 class gridconnections counts %s %s %s\n"%(nx,ny,nz))
f.write("object 3 class array type double rank 0 times %s\n"%(nx*ny*nz))
#The data with Z increasing first, then Y, then X.
i = 0
for x in range(nx):
for y in range(ny):
for z in range(nz): #Generation of sample data
mz=3*(z-nz/2.) #Write values of point number (x,y,z)
if i == 2:
i = 0
else: i += 1
On Thursday, January 30, 2014 11:45 PM, Thomas Holder <email@example.com> wrote:
I just pushed a change to the open-source SVN repo which makes loading maps with a script a little easier. If you have your map in a numpy array, you can do:
yourdata = ... # array with shape (a,b,c)
yourgridspacing = (0.2, 0.2, 0.2) # grid spacing
from chempy.brick import Brick
b = Brick.from_numpy(yourdata, yourgridspacing)
Hope that helps.
On 30 Jan 2014, at 16:24, Jason Vertrees <firstname.lastname@example.org
> Hi Esben,
> I have a list of coordinates on a regular grid with associated floating point values from a calculation that I want to visualise in PyMOL. Is it nescessary to write this to an Xplor/CNS/CCP4 file format and subsequently load it, or can it be loaded directly into a map object via some fancy python code?
> It depends on how you want to visualize the data. If dots/points or other discrete representations are okay then you can use a XYZ or a modified structure file. If you want the benefit of a field (volume, gradient, isosurface) then I suggest the
> If you already have the data in a well-formatted brick, check out the asCCP4 function in http://www.pymolwiki.org/index.php/Tiff2ccp4.
That writes the CCP4 header and data (of a TIFF file, but you can modify that for your needs).
> If you want, send me a copy of your data. Or, I also have a very poorly written script that will convert raw volumes of data to CCP4 maps, similar to the aforementioned script. Email me personally and I can send you a copy if you prefer (but it's really ugly code).
> -- Jason
> On Wed, Jan 29, 2014 at 8:02 AM, Esben Jannik Bjerrum <email@example.com
> > Hi All-knowing Pymol'ers.
> > I wonder if anyone had a couple of tips/ pointers / script snippets.
> > I have a list of coordinates on a regular grid with associated floating point values from a calculation that I want to visualise in PyMOL. Is it nescessary to write this to an Xplor/CNS/CCP4 file format and subsequently load it, or can it be loaded directly into a map object via some fancy python code?
> > Best Regards
> > Esben Jannik Bjerrum