[yt-users] Question in the projection plot
Nathan Goldbaum
nathan12343 at gmail.com
Tue Oct 9 21:12:26 PDT 2012
Hi Junhwan,
The projection objects accept a field_cuts keyword argument that you can
use to control data selection in the projection. If you create the
projection directly:
proj = pf.h.proj('z','Density', field_cuts= "np.abs(grid['z'] - 0.5) < 0.2")
and then supply the projection object as a data source when you create
the plot:
pc.add_projection("Density",2,data_source=proj)
you should get a plot back that matches what you're looking for.
The field_cuts parameter is evaluated internally using eval, so it needs
to be properly formatted python. For reference, the eval happens in a
function that looks like this: http://paste.yt-project.org/show/2773/
Unfortunately, I just tried to create a plot that way and either I'm
doing something wrong or there's a bug somewhere that breaks this
functionality. I could create the projection object, but when I
supplied the projection object as a data source in add_projection, it
failed (traceback here:http://paste.yt-project.org/show/2775/). Can
someone else on the list let us know if I'm doing something wrong here?
To at least take a look at your data while we sort out this problem, you
could do this:
width, resolution = (0.4, 800)
frb = proj.to_frb(width, resolution)
image = frb['Density']
The second line creates a FixedResolutionBuffer object, which outputs an
image array of a field by querying the projection data object. The
width is the width of the FRB in code units and the resolution is the
resolution of the image array. This example would make an image which
you could plot using matplotlib.imshow.
There's a similar function (proj.to_pw()) which should return a nice
plot window plot that you could save, but that functionality is
definitely broken at the moment due to a recent change. Looking at the
code, I think I see how to fix this functionality and I'll let you know
as soon as it's working.
Cheers,
Nathan
On 10/9/12 8:31 PM, Jun-Hwan Choi wrote:
> Hi all,
>
> I would like to know how can I control the projection width in the
> projection plot.
> For example, if I make a projection plot using add_projection such as
> >pc.add_projection("Density",2)
> It makes a projection through entire z-axis from 0 to 1.
> What do I need to do if I want to make projection only from 0.3 to 0.7
> through z axis?
> I think that set_width command controls xy width not z width.
>
> Thank you in advance,
> Junhwan
>
>
> --
> --------------------------------------------------------------
> Jun-Hwan Choi, Ph.D.
> Department of Physics and Astronomy, University of Kentucky
> Tel: (859) 897-6737 Fax: (859) 323-2846
> Email: jhchoi at pa.uky.edu <mailto:jhchoi at pa.uky.edu> URL:
> http://www.pa.uky.edu/~jhchoi <http://www.pa.uky.edu/%7Ejhchoi>
> --------------------------------------------------------------
>
>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
More information about the yt-users
mailing list