<div dir="ltr"><div class="gmail_extra"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​Hi Nathan,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks!  It seems though that the frb cannot be directly passed to matplotlib's imshow, though np.array(frb) can.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I would like it in general if yt could provide simpler means of accessing arrays or array-like objects such as are plotted up.  There are many reasons for this besides the desire to plot using matplotlib -- e.g. to create plots of ratios of quantities, or to plot scaled variables.​  Perhaps this is possible now, though it's not obvious from the docs.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Regards,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Jon</div><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 2:42 PM,  <span dir="ltr"><<a href="mailto:yt-users-request@lists.spacepope.org" target="_blank">yt-users-request@lists.spacepope.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":v8" class="a3s" style="overflow:hidden">Date: Tue, 11 Aug 2015 13:17:50 -0500<br>
From: Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com">nathan12343@gmail.com</a>><br>
To: Discussion of the yt analysis package<br>
        <<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a>><br>
Subject: Re: [yt-users] getting slice array<br>
Message-ID:<br>
        <CAJXewOmiymap0uUBy0hL=<a href="mailto:zo0Ltf0kG7UErXYFy9dqZseXoapsg@mail.gmail.com">zo0Ltf0kG7UErXYFy9dqZseXoapsg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Tue, Aug 11, 2015 at 1:10 PM, Slavin, Jonathan <<a href="mailto:jslavin@cfa.harvard.edu">jslavin@cfa.harvard.edu</a>><br>
wrote:<br>
<br>
> Hi all,<br>
><br>
> I'm new to using yt, though I'm an experienced python and matplotlib<br>
> user.  I've been doing runs with FLASH and would like to be able to plot<br>
> the results with matplotlib.  I've used yt "interactively" in an ipython<br>
> notebook and found it a bit cumbersome - e.g. you can't pan and zoom like<br>
> you can with matplotlib.  On the other hand yt has some nice facilities for<br>
> accessing the data.  So my question is, how do I get a slice, such as is<br>
> plotted using the yt.SlicePlot function, in an array that I can then<br>
> manipulate, plot, etc.?  If I do:<br>
> ds = yt.load(file)<br>
> slc = ds.slice(2,0.)<br>
> d = slc['density']<br>
> I have a YTArray that's apparently 1-D:<br>
> d.shape<br>
> (138496,)<br>
> I should mention that this is a 2-D, cylindrically symmetric (r-z) run.<br>
> Thanks in advance for any help you can offer.<br>
><br>
<br>
If you have a yt plot object (e.g. a SlicePlot or a ProjectionPlot), you<br>
can do:<br>
<br>
slc = yt.SlicePlot(...)<br>
densit_image = slc.frb['density']<br>
<br>
"frb" here is a FixedResolutionBuffer object which translates the<br>
multiresolution 1-D array you ran into above into a 2D pixelized<br>
representation of your data.<br>
<br>
You can also create a FixedResolutionBuffer object directly:<br>
<a href="http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays" rel="noreferrer" target="_blank">http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays</a><br>
<br>
The image arrays you get back from a FixedResolutionBuffer object can be<br>
passed directly to e.g. matplotlib's imshow command.<br>
<br>
By the way, Matt Turk has an open pull request to add the interactive<br>
panning and zooming you were looking for:<br>
<br>
<a href="http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays" rel="noreferrer" target="_blank">http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays</a><br>
<br>
I'm hoping to finish up that pull request soon, since having interactive<br>
plots both in the notebook and using matplotlib's interactive backends is a<br>
common feature request.<br></div></blockquote></div><br><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">________________________________________________________<br>Jonathan D. Slavin                 Harvard-Smithsonian CfA<br><a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a>       60 Garden Street, MS 83<br>phone: (617) 496-7981       Cambridge, MA 02138-1516<br>cell: (781) 363-0035             USA<br>________________________________________________________<br><br></div></div></div></div>
</div></div>