Hi Renyue,<div><br></div><div>Currently the ProjectionPlot interface doesn't directly support using a data source like a sphere for the projection.  However, I think you can get the behavior you want with the following script:</div>

<div><br></div><div><div>import os, sys, time</div><div>from yt.mods import * # set up our namespace</div><div>import h5py as h5</div><div>from yt.utilities.amr_kdtree.api import AMRKDTree</div><div><br></div><div>fn = "redshift0085" # parameter file to load</div>

<div>pf = load(fn, file_style="%s.grid.cpu%%04i") # load data</div></div><div><br></div><div>sp = pf.h.sphere(center, 1.0/pf['mpc'])</div><div><div><div><br></div><div># First make the projection object, then produce a ProjectionPlot plot window from it.</div>

<div># Notice that this pf.h.proj needs 0 instead of 'x'.</div><div>p = pf.h.proj(0, 'Density', weight_field=None, center=center, data_source=sp).to_pw()</div><div></div></div><div><br></div><div>p.set_width(1.0,'mpc')</div>

<div>p.save()</div></div><div><br></div><div>Let us know if that works.</div><div><br></div><div>Best,</div><div>Sam</div><div><br><div class="gmail_quote">On Mon, Oct 1, 2012 at 7:31 AM, Renyue Cen <span dir="ltr"><<a href="mailto:cen@astro.princeton.edu" target="_blank">cen@astro.princeton.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi,<div><br></div><div>I was trying some simple script for making ProjectionPlot and </div>

<div>failed for some reason.<font color="#ff3e29"> Here is the script:</font></div><div><br></div><div><div>import os, sys, time</div><div>from yt.mods import * # set up our namespace</div><div>import h5py as h5</div><div>

from yt.utilities.amr_kdtree.api import AMRKDTree</div><div><br></div><div>fn = "redshift0085" # parameter file to load</div><div>pf = load(fn, file_style="%s.grid.cpu%%04i") # load data</div><div><br>

</div><div>center = [0.5,0.5,0.5]</div><div>sp = pf.h.sphere(center, 1.0/pf['mpc'])</div><div><br></div><div>p = ProjectionPlot(sp, "x","Density")</div><div>p.set_width(1.0,'mpc')</div>

<div>p.save()</div></div><div><br></div><div><br></div><div><font color="#ff3e29">The error message is this:</font></div><div><div>    p = ProjectionPlot(sp, "x","Density")</div><div>Traceback (most recent call last):</div>

<div>  File "projectOVIgasCZ3z0200.py", line 24, in <module></div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 828, in __init__</div>

<div>    p = ProjectionPlot(sp, "x","Density")</div><div>    p = ProjectionPlot(sp, "x","Density")</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 828, in __init__</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 828, in __init__</div><div>    p = ProjectionPlot(sp, "x","Density")</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 828, in __init__</div><div>    (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)</div>

<div>    (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)</div><div>    (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 136, in GetBoundsAndCenter</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 136, in GetBoundsAndCenter</div><div>    (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 136, in GetBoundsAndCenter</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/visualization/plot_window.py", line 136, in GetBoundsAndCenter</div>

<div>    width = (Wx/pf[unit], Wy/pf[unit])</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 327, in __getitem__</div><div>

    width = (Wx/pf[unit], Wy/pf[unit])</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 327, in __getitem__</div><div>    width = (Wx/pf[unit], Wy/pf[unit])</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 327, in __getitem__</div><div>    width = (Wx/pf[unit], Wy/pf[unit])</div><div>

  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 327, in __getitem__</div><div>    self.get_data(key)</div><div>    self.get_data(key)</div>

<div>    self.get_data(key)</div><div>    self.get_data(key)</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 2510, in get_data</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 2510, in get_data</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 2510, in get_data</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 2510, in get_data</div><div>    if self._generate_field(field):</div><div>    if self._generate_field(field):</div>

<div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 360, in _generate_field</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 360, in _generate_field</div>

<div>    if self._generate_field(field):</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 360, in _generate_field</div><div>

    if self._generate_field(field):</div><div>  File "/u/jhwise/local/lib/python2.7/site-packages/yt-2.4dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.py", line 360, in _generate_field</div><div>    raise KeyError(field)</div>

<div>    raise KeyError(field)</div><div>KeyError: 'unitary'</div><div>    raise KeyError(field)</div><div>KeyError: 'unitary'</div><div>KeyError: 'unitary'</div><div>    raise KeyError(field)</div>

<div>KeyError: 'unitary'</div></div><div><br></div><div><br></div><div>Thanks in advance for your help </div><span class="HOEnZb"><font color="#888888"><div>Renyue</div><div><br></div></font></span></div><br>_______________________________________________<br>


yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>