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.

#!/usr/bin/python

# Esben Jannik Bjerrum 2014

#Write DX format

import math

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 grid points

f = open("tester.dx","w")

f.write("#Comment\n")

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

mx=1.5*(x-nx/2.)

my=2*(y-nx/2.)

mz=3*(z-nz/2.)

#Write values of point number (x,y,z)

f.write("%e "%(1.-2./math.exp(math.sqrt(mx*mx+my*my+mz*mz)/10.0)))

#f.write("(%s,%s,%s)"%(x,y,z))

if i == 2:

f.write("\n")

i = 0

else: i += 1

f.write("\n")

f.close()

Best Regards

Esben

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.

#!/usr/bin/python

# Esben Jannik Bjerrum 2014

#Write DX format

import math

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 grid points

f = open("tester.dx","w")

f.write("#Comment\n")

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

mx=1.5*(x-nx/2.)

my=2*(y-nx/2.)

mz=3*(z-nz/2.)

#Write values of point number (x,y,z)

f.write("%e "%(1.-2./math.exp(math.sqrt(mx*mx+my*my+mz*mz)/10.0)))

#f.write("(%s,%s,%s)"%(x,y,z))

if i == 2:

f.write("\n")

i = 0

else: i += 1

f.write("\n")

f.close()

Best Regards

Esben

On Thursday, January 30, 2014 11:45 PM, Thomas Holder <thomas.holder@schrodinger.com> wrote:

Hi Esben,

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)

cmd.load_brick(b, 'yourmap')

Hope that helps.

Cheers,

Thomas

On 30 Jan 2014, at 16:24, Jason Vertrees <jason.vertrees@schrodinger.com> wrote:

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

>

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

>

> Cheers,

>

> -- Jason

>

>

> On Wed, Jan 29, 2014 at 8:02 AM, Esben Jannik Bjerrum <esbenjannik@rocketmail.com> wrote:

> >

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

--

Thomas Holder

PyMOL Developer

Schrödinger, Inc.

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)

cmd.load_brick(b, 'yourmap')

Hope that helps.

Cheers,

Thomas

On 30 Jan 2014, at 16:24, Jason Vertrees <jason.vertrees@schrodinger.com> wrote:

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

>

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

>

> Cheers,

>

> -- Jason

>

>

> On Wed, Jan 29, 2014 at 8:02 AM, Esben Jannik Bjerrum <esbenjannik@rocketmail.com> wrote:

> >

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

--

Thomas Holder

PyMOL Developer

Schrödinger, Inc.