<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hey Tom, <br>
<br>
Sure, from now on I will send my questions to chimera-users email
address. Sorry about that.<br>
<br>
The Numeric flat() method doesn't work for me. Error is:<br>
ValueError: flattened indexing only available for contiguous array<br>
<br>
So, instead I just wrote a loop to 'flatten' the array down:<br>
for i in m:<br>
for x in i:<br>
for j in x:<br>
for u in j:<br>
sum = sum + u<br>
Does that seem fine, or is .flat() doing something else?<br>
<br>
Cheers, <br>
Eran.<br>
Thomas Goddard wrote:
<blockquote cite="mid200604122317.k3CNH6fQ1954720@guanine.cgl.ucsf.edu"
type="cite">
<pre wrap="">Hi Eran,
Ok, here is code to read an MRC file and print the sum of map values
without using Chimera. You need Python, the Numeric Python module which
handles multidimensional arrays and the VolumeData module from Chimera.
Numeric is obtained from sourceforge:
<a class="moz-txt-link-freetext" href="http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351">http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351</a>
The VolumeData module is in your Chimera distribution.
chimera/share/VolumeData
Here's an example running the script where I've set PYTHONPATH to have
access to the VolumeData module:
% env PYTHONPATH=/usr/local/chimera/share python2.4 volumesum2.py
Sum of values of groel.mrc = 21720.8984375
Send future questions to <a class="moz-txt-link-abbreviated" href="mailto:chimera-users@cgl.ucsf.edu">chimera-users@cgl.ucsf.edu</a> so others who
have similar problems can benefit. I get that email just as fast.
Tom
-------
file volumesum2.py follows:
# Script to print the sum of volume data values.
# Does not need Chimera, just the VolumeData module and Numeric and Python.
path = 'groel.mrc'
# Read the MRC volume data and get the 3-D Numeric array.
from VolumeData.mrc.mrc_format import MRC_Data
data = MRC_Data(path)
m = data.matrix()
# Compute the sum of the elements of the volume matrix.
import Numeric
sum = Numeric.sum(m.flat)
# Print the sum
print 'Sum of values of', path, ' = ', sum
-------
</pre>
<blockquote type="cite">
<pre wrap="">Date: Wed, 12 Apr 2006 14:46:14 -0700
From: Eran Shacham <a class="moz-txt-link-rfc2396E" href="mailto:eshacham@burnham.org"><eshacham@burnham.org></a>
To: Thomas Goddard <a class="moz-txt-link-rfc2396E" href="mailto:goddard@cgl.ucsf.edu"><goddard@cgl.ucsf.edu></a>
Subject: Re: Sum of volume data values
Hey Tom,
Thanks for your reply. However, I would like to do that from within a
script I already wrote. i.e I would like to integrate a read_in method
for an MRC file, access it values and then calculate the sum. I would
like to avoid doing that by opening my file in Chimera at this stage of
the program. Can it be done by importing some of your code?
Thanks,
Eran.
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>