<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 1:10 PM, Slavin, Jonathan <span dir="ltr"><<a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif">Hi all,</div><div style="font-family:arial,helvetica,sans-serif"><br></div><div style="font-family:arial,helvetica,sans-serif">I'm new to using yt, though I'm an experienced python and matplotlib user.  I've been doing runs with FLASH and would like to be able to plot the results with matplotlib.  I've used yt "interactively" in an ipython notebook and found it a bit cumbersome - e.g. you can't pan and zoom like you can with matplotlib.  On the other hand yt has some nice facilities for accessing the data.  So my question is, how do I get a slice, such as is plotted using the yt.SlicePlot function, in an array that I can then manipulate, plot, etc.?  If I do:</div><div style="font-family:arial,helvetica,sans-serif">ds = yt.load(file)</div><div style="font-family:arial,helvetica,sans-serif">slc = ds.slice(2,0.)</div><div style="font-family:arial,helvetica,sans-serif">d = slc['density']</div><div style="font-family:arial,helvetica,sans-serif">I have a YTArray that's apparently 1-D:</div><div style="font-family:arial,helvetica,sans-serif"><div style="font-family:arial,helvetica,sans-serif">d.shape</div><div style="font-family:arial,helvetica,sans-serif">(138496,)</div><div>I should mention that this is a 2-D, cylindrically symmetric (r-z) run.  Thanks in advance for any help you can offer.</div></div></div></blockquote><div><br></div><div>If you have a yt plot object (e.g. a SlicePlot or a ProjectionPlot), you can do:</div><div><br></div><div>slc = yt.SlicePlot(...)</div><div>densit_image = slc.frb['density']</div><div><br></div><div>"frb" here is a FixedResolutionBuffer object which translates the multiresolution 1-D array you ran into above into a 2D pixelized representation of your data.</div><div><br></div><div>You can also create a FixedResolutionBuffer object directly: <a href="http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays" target="_blank">http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays</a></div><div><br></div><div>The image arrays you get back from a FixedResolutionBuffer object can be passed directly to e.g. matplotlib's imshow command.</div><div><br></div><div>By the way, Matt Turk has an open pull request to add the interactive panning and zooming you were looking for:</div><div><br></div><div><a href="http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays" target="_blank">http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays</a><br></div><div><br></div><div>I'm hoping to finish up that pull request soon, since having interactive plots both in the notebook and using matplotlib's interactive backends is a common feature request.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif"><div><br></div><div>Regards,</div><div>Jon Slavin</div></div><span><font color="#888888"><div><br></div>-- <br><div><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: <a href="tel:%28617%29%20496-7981" value="+16174967981" target="_blank">(617) 496-7981</a>       Cambridge, MA 02138-1516<br>cell: <a href="tel:%28781%29%20363-0035" value="+17813630035" target="_blank">(781) 363-0035</a>             USA<br>________________________________________________________<br><br></div></div></div></div>
</font></span></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div></div>