<meta http-equiv="Content-Type" content="text/html; charset=utf-8">Hi Johanna,<br><br>If you're interested, please feel free to file a pull request to include this. New users are oftentimes the ideal candidates to contribute docs fixes.<div><br></div><div>-Nathan</div><br><div class="gmail_quote">On Wed Dec 03 2014 at 5:21:19 PM Johanna Malinen <<a href="mailto:pjmaline@gmail.com">pjmaline@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the info and the script. While waiting for the possible<br>
update, it would be helpful for new users if this was mentioned e.g.<br>
on pages<br>
<a href="http://yt-project.org/doc/quickstart/simple_visualization.html" target="_blank">http://yt-project.org/doc/<u></u>quickstart/simple_<u></u>visualization.html</a><br>
and FAQ.<br>
<br>
Johanna<br>
<br>
On Tue, Dec 2, 2014 at 7:37 PM, Timothy Waters <<a href="mailto:waterst3@unlv.nevada.edu" target="_blank">waterst3@unlv.nevada.edu</a>> wrote:<br>
> Hi Johanna,<br>
><br>
> I had also wondered about this.  I took to scripting with<br>
> FixedResolutionBuffer like Nathan mentioned, and I have had good luck with<br>
> Matplotlib's ImageGrid command.  I use it to make both publishable plots and<br>
> animations/movies.  Below is a basic version of the type of script I use in<br>
> case that is helpful to you.<br>
><br>
> Tim<br>
><br>
> ------------------------------<u></u>------------------------------<u></u>---<br>
> import yt<br>
> import array as ar<br>
> import numpy as np<br>
> import pylab as plt<br>
> #from pylab import *<br>
> import matplotlib.animation as animation<br>
> from yt.visualization.fixed_<u></u>resolution import FixedResolutionBuffer<br>
> from mpl_toolkits.axes_grid1 import ImageGrid<br>
><br>
> ################<br>
> # Globals<br>
> ################<br>
> GATHER_IMAGES = False<br>
> ANIMATE = False<br>
> dumps = ar.array('i',(i for i in range(1,101,1)))<br>
> imagefolder = 'images'<br>
> xpix,ypix = 1024,512 #doesn't have to be resolution of simulation<br>
> xmin,xmax = 0.,1.<br>
> ymin,ymax = 0.,0.5<br>
><br>
> ################<br>
> # Specify files<br>
> ################<br>
> # ...<br>
><br>
> ################<br>
> # Gather images<br>
> ################<br>
> if GATHER_IMAGES:<br>
> for i in dumps:<br>
> ds = yt.load(file)<br>
> gs = ds.index.select_grids(ds.<u></u>index.max_level)<br>
> grid = gs[0]<br>
> #xaxis = grid['x'][:,0,0] #can access variables if needed<br>
> for var in vars:<br>
> prj = ds.proj(var,2)<br>
> prj_frb = FixedResolutionBuffer(prj, (xmin,xmax,ymin,ymax),(ypix,<u></u>xpix))<br>
> img_prj = prj_frb[var]<br>
> #at this step, can apply functions to prj_frb to alter image data, e.g.:<br>
> #img_prj = doSomething(img_frb[var])<br>
> img = np.array(img_prj)<br>
> img_name = var + `i` # (for example)<br>
> print "Saving image {}...".format(img_name)<br>
> file = open(imagefolder + img_name, 'w')<br>
> np.save(file,img)<br>
> file.close()<br>
><br>
> ##################<br>
> # Setup ImageGrid<br>
> ##################<br>
> N_SUBPLOTS = 2<br>
> fig = plt.figure(1, (7., 8.))<br>
> grid = ImageGrid(fig, 111, # similar to subplot(111)<br>
>                 nrows_ncols = (2, 1), # creates 2x1 grid of axes<br>
>                 axes_pad=0.15, # pad between axes in inch.<br>
>                 direction='column',<br>
>                 cbar_location='right',<br>
>                 cbar_mode='each',<br>
>                 cbar_pad =0.15,<br>
>                 cbar_size='3.0%'<br>
>                 )<br>
><br>
> def plotImages(iter):<br>
> i = dumps[0] + iter<br>
> for iplot in range(N_SUBPLOTS):<br>
> plt.setp(grid[iplot].get_<u></u>yticklabels(), visible=False)<br>
> plt.setp(grid[iplot].get_<u></u>xticklabels(), visible=False)<br>
> if iplot == 0: #plot density<br>
> img_name = 'density' + `i`<br>
> img = np.load(imagefolder + img_name)<br>
> vmin = min(map(min,img))<br>
> vmax = max(map(max,img))<br>
> im = grid[iplot].imshow(img,vmin=<u></u>vmin, vmax=vmax,<br>
> cmap='Spectral',extent=[xmin,<u></u>xmax,ymin,ymax])<br>
> elif iplot == 1: #plot pressure<br>
> img_name = 'pressure' + `i`<br>
> img = np.load(imagefolder + img_name)<br>
> vmin = min(map(min,img))<br>
> vmax = max(map(max,img))<br>
> im = grid[iplot].imshow(img,vmin=<u></u>vmin, vmax=vmax,<br>
> cmap='Spectral',extent=[xmin,<u></u>xmax,ymin,ymax])<br>
><br>
>   if not(ANIMATE):<br>
> for t in grid.cbar_axes[iplot].get_<u></u>yticklabels():<br>
> t.set_visible(False)<br>
> t.set_fontsize(14)<br>
> t.set_visible(True)<br>
> #show y ticks<br>
> plt.setp(grid[iplot].get_<u></u>yticklabels(), visible=True)<br>
> #set limits<br>
> grid[iplot].set_xlim(xmin,<u></u>xmax)<br>
> grid[iplot].set_ylim(ymin,<u></u>ymax)<br>
> # show x-ticks<br>
> plt.setp(grid[2].get_<u></u>xticklabels(), visible=True)<br>
> # axes labels<br>
> grid[0].set_ylabel('density')<br>
> grid[1].set_ylabel('pressure')<br>
> ############<br>
> # Make Plot<br>
> ############<br>
> if GATHER_IMAGES:<br>
> sys.exit()<br>
> elif ANIMATE:<br>
> ani = animation.FuncAnimation(fig,<u></u>plotImages,init_func=None,<br>
>     frames=len(dumps),interval=<u></u>100, blit=False,repeat=False)<br>
> else:<br>
> idump = 1<br>
> plotProfiles(idump)<br>
><br>
> plt.show()<br>
><br>
> On Tue, Dec 2, 2014 at 2:45 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>><br>
> wrote:<br>
>><br>
>><br>
>><br>
>> On Tue, Dec 2, 2014 at 1:45 PM, Johanna Malinen <<a href="mailto:pjmaline@gmail.com" target="_blank">pjmaline@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> I just installed the yt development version<br>
>>> <a href="http://hg.yt-project.org/yt/raw/yt/doc/install_script.sh" target="_blank">http://hg.yt-project.org/yt/<u></u>raw/yt/doc/install_script.sh</a><br>
>>> Version = 3.1-dev<br>
>>> Changeset = dc2ade033502 (yt) tip<br>
>>> into ubuntu 14.04<br>
>>> with<br>
>>>  INST_ZLIB=0<br>
>>>  INST_FTYPE=0<br>
>>><br>
>>> yt seemed to install properly and it works otherwise, but it doesn't<br>
>>> open any windows when I'm trying to show an image, e.g.,<br>
>>> when running the script<br>
>>> <a href="http://yt-project.org/doc/quickstart/3)_Simple_Visualization.py" target="_blank">http://yt-project.org/doc/<u></u>quickstart/3)_Simple_<u></u>Visualization.py</a><br>
>>> line by line in ipython:<br>
>>> p = yt.ProjectionPlot(ds, "y", "density")<br>
>>> p.show()   #doesn't open a window<br>
>>> In [35]: p.show()<br>
>>> <yt.visualization.plot_window.<u></u>ProjectionPlot at 0x7fe1897941d0><br>
>>> However, saving the image works:<br>
>>> p.save()<br>
>>><br>
>>> When I run that script directly with python, I get the following error:<br>
>>> Traceback (most recent call last):<br>
>>>   File "3)_Simple_Visualization_<u></u>short.py", line 28, in <module><br>
>>>     p.show()<br>
>>>   File<br>
>>> "/home/.../yt/yt-x86_64/src/<u></u>yt-hg/yt/visualization/plot_<u></u>container.py",<br>
>>> line 622, in show<br>
>>>     raise YTNotInsideNotebook<br>
>>> yt.utilities.exceptions.<u></u>YTNotInsideNotebook: This function only works<br>
>>> from within an IPython Notebook.<br>
>>><br>
>>> I'm using<br>
>>> ipython --matplotlib<br>
>>> from pylab import *<br>
>>> and e.g. plot() and figure() open a window normally. Is there a way to<br>
>>> open a window with yt's show() and other functions<br>
>>> using ipython and python, or does that really require IPython Notebook?<br>
>><br>
>><br>
>> Hi Johanna,<br>
>><br>
>> This is a known issue:<br>
>><br>
>><br>
>> <a href="https://bitbucket.org/yt_analysis/yt/issue/660/support-for-interactive-mpl-backends" target="_blank">https://bitbucket.org/yt_<u></u>analysis/yt/issue/660/support-<u></u>for-interactive-mpl-backends</a><br>
>><br>
>> We had a recent discussion about this on the dev mailing list:<br>
>><br>
>><br>
>> <a href="http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/2014-November/013944.html" target="_blank">http://lists.spacepope.org/<u></u>pipermail/yt-dev-spacepope.<u></u>org/2014-November/013944.html</a><br>
>><br>
>> So it's not impossible, but it will take some work.  I've wanted to get<br>
>> this set up for a while, but need to complete my Ph.D. before I can focus on<br>
>> this.  If someone else wants to step up and work on this, I think that would<br>
>> be an excellent contribution.<br>
>><br>
>> For now you do need to work inside of the IPython notebook if you want to<br>
>> interactively work with yt plots.<br>
>><br>
>> You can also manually create your plots using e.g. FixedResolutionBuffer<br>
>> and pyplot.<br>
>><br>
>>> Cheers,<br>
>>> Johanna<br>
>>> ______________________________<u></u>_________________<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" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
>><br>
>><br>
>><br>
>> ______________________________<u></u>_________________<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" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
>><br>
><br>
><br>
> ______________________________<u></u>_________________<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" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
><br>
______________________________<u></u>_________________<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" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
</blockquote></div>