<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Monotype.com">Hi yt-users,<br>
<br>
I try to make a density projection of my simulation.<br>
I would like to make a small modification that if the cell density
higher than a given density ceiling the density value becomes the
density ceiling.<br>
And, I made a following script:<br>
############################################<br>
from yt.mods import *<br>
import matplotlib.pylab as pylab<br>
<br>
def _DensityCeiling(field, data):<br>
Ceiling = 1e-22<br>
nx, ny, nz = data["Density"].shape<br>
DensityCeiling = na.zeros(data["Density"].shape,
dtype='float64')<br>
DensityCeiling = data["Density"]<br>
for ix, in range(0,nx):<br>
for iy, in range(0,ny):<br>
for iz, in range(0,nz):<br>
if(data["DensityCeiling"][ix,iy,iz] >
Ceiling):<br>
DensityCeiling[ix,iy,iz] = Ceiling<br>
return DensityCeiling<br>
add_field("DensityCeiling", function=_DensityCeiling,
units=r"\rm{g}/\rm{cm^3}")<br>
<br>
<br>
# load up a dataset<br>
pf = load("DD0000/DD0000")<br>
all_center = [0.5, 0.5, 0.5]<br>
<br>
pc = PlotCollection(pf,center=all_center)<br>
pc.add_slice("DensityCeiling", 0)<br>
pc.add_slice("DensityCeiling", 2)<br>
pc.add_projection("DensityCeiling", 0)<br>
pc.add_projection("DensityCeiling", 2)<br>
<br>
pc.set_width(6, 'kpc')<br>
pc.save("cen_t%04.1f_L6K" % pf.current_time)<br>
pc.set_width(1, 'kpc')<br>
pc.save("cen_t%04.1f_L1K" % pf.current_time)<br>
#######################################################<br>
<br>
And then, I got a following error.<br>
File "DenViz.py", line 6, in _DensityCeiling<br>
nx, ny, nz = data["Density"].shape<br>
ValueError: need more than 1 value to unpack<br>
<br>
It turns out that the data</font><font face="Monotype.com">["Density"]
is not always 3d array but sometimes become 1d array.<br>
Is there any way to fix the derived field to avoid this problem?<br>
<br>
Thank you in advance,<br>
Junhwan<br>
</font><font face="Monotype.com"><br>
<br>
</font>
<pre class="moz-signature" cols="72">--
--------------------------------------------------------------
Jun-Hwan Choi, Ph.D.
Department of Physics and Astronomy, University of Kentucky
Tel: (859) 897-6737 Fax: (859) 323-2846
Email: <a class="moz-txt-link-abbreviated" href="mailto:jhchoi@pa.uky.edu">jhchoi@pa.uky.edu</a> URL: <a class="moz-txt-link-freetext" href="http://www.pa.uky.edu/~jhchoi">http://www.pa.uky.edu/~jhchoi</a>
--------------------------------------------------------------
</pre>
</body>
</html>