[yt-users] help on ProjectionPlot

Sam Skillman samskillman at gmail.com
Mon Oct 1 09:15:41 PDT 2012


Hi again,

Turns out I had the incorrect keyword for the source.  Please use source=
instead of data_source= :

p = pf.h.proj(0, 'Density', weight_field=None, center=center,
source=sp).to_pw()

Best,
Sam


On Mon, Oct 1, 2012 at 8:07 AM, Sam Skillman <samskillman at gmail.com> wrote:

> Hi Renyue,
>
> 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:
>
> import os, sys, time
> from yt.mods import * # set up our namespace
> import h5py as h5
> from yt.utilities.amr_kdtree.api import AMRKDTree
>
> fn = "redshift0085" # parameter file to load
> pf = load(fn, file_style="%s.grid.cpu%%04i") # load data
>
> sp = pf.h.sphere(center, 1.0/pf['mpc'])
>
> # First make the projection object, then produce a ProjectionPlot plot
> window from it.
> # Notice that this pf.h.proj needs 0 instead of 'x'.
> p = pf.h.proj(0, 'Density', weight_field=None, center=center,
> data_source=sp).to_pw()
>
> p.set_width(1.0,'mpc')
> p.save()
>
> Let us know if that works.
>
> Best,
> Sam
>
> On Mon, Oct 1, 2012 at 7:31 AM, Renyue Cen <cen at astro.princeton.edu>wrote:
>
>> Hi,
>>
>> I was trying some simple script for making ProjectionPlot and
>> failed for some reason. Here is the script:
>>
>> import os, sys, time
>> from yt.mods import * # set up our namespace
>> import h5py as h5
>> from yt.utilities.amr_kdtree.api import AMRKDTree
>>
>> fn = "redshift0085" # parameter file to load
>> pf = load(fn, file_style="%s.grid.cpu%%04i") # load data
>>
>> center = [0.5,0.5,0.5]
>> sp = pf.h.sphere(center, 1.0/pf['mpc'])
>>
>> p = ProjectionPlot(sp, "x","Density")
>> p.set_width(1.0,'mpc')
>> p.save()
>>
>>
>> The error message is this:
>>     p = ProjectionPlot(sp, "x","Density")
>> Traceback (most recent call last):
>>   File "projectOVIgasCZ3z0200.py", line 24, in <module>
>>   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__
>>     p = ProjectionPlot(sp, "x","Density")
>>     p = ProjectionPlot(sp, "x","Density")
>>   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__
>>   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__
>>     p = ProjectionPlot(sp, "x","Density")
>>   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__
>>     (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
>>     (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
>>     (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
>>   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
>>   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
>>     (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
>>   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
>>   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
>>     width = (Wx/pf[unit], Wy/pf[unit])
>>   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__
>>     width = (Wx/pf[unit], Wy/pf[unit])
>>   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__
>>     width = (Wx/pf[unit], Wy/pf[unit])
>>   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__
>>     width = (Wx/pf[unit], Wy/pf[unit])
>>   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__
>>     self.get_data(key)
>>     self.get_data(key)
>>     self.get_data(key)
>>     self.get_data(key)
>>   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
>>   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
>>   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
>>   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
>>     if self._generate_field(field):
>>     if self._generate_field(field):
>>   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
>>   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
>>     if self._generate_field(field):
>>   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
>>     if self._generate_field(field):
>>   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
>>     raise KeyError(field)
>>     raise KeyError(field)
>> KeyError: 'unitary'
>>     raise KeyError(field)
>> KeyError: 'unitary'
>> KeyError: 'unitary'
>>     raise KeyError(field)
>> KeyError: 'unitary'
>>
>>
>> Thanks in advance for your help
>> Renyue
>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20121001/75526a3b/attachment.html>


More information about the yt-users mailing list