<div dir="ltr"><div><div>Dear (very helpful) yt folk:<br><br></div>I have been struggling with trying to make a slice plot of some FLASH data that is an odd size; the volume is 1 kpc square in x and y, and 40 kpc tall in z. The grid sizes vary widely, as expected. I have two questions: one, I would like to understand the odd behavior that I get with regular SlicePLots, and I would like some help using the FixedResolutionBuffer, which I *suspect* is the way I want to go, but I have not been able to make it work. I am using the newest version of yt (upgraded this morning!) on Mac OS 10.7.5.<br>
<br></div>The SlicePlot weirdnesses:<br>from yt.mods import *<br>%matplotlib inline<br>import matplotlib.pyplot as plt<br>import matplotlib.image as mpimg<br>import matplotlib.colorbar as cb<br>import numpy as np<br clear="all">
<div><div><div>pf = load("Strat_Box_hdf5_plt_cnt_0064")<br></div><div>#First try a 20 kpc tall box<br>slc = SlicePlot(pf, 'x', 'Density',center='c',width=((1,"kpc"),(20.0,"kpc")))<br>
slc.annotate_title('This is a Density plot')<br>slc.save('test_20kpc.png')<br>slc.show()<br></div><div>#Please see plot at <a href="http://i.imgur.com/N65CNfU.png">http://i.imgur.com/N65CNfU.png</a><br><br>
</div><div>#Now try a 5 kpc tall plot<br>slc = SlicePlot(pf, 'x', 'Density',center='c',width=((1,"kpc"),(5.0,"kpc")))<br>slc.annotate_title('This is a Density plot')<br>
slc.save('test_5kpc.png')<br>slc.show()<br></div><div><br></div><div>#Please see plot at <a href="http://i.imgur.com/L1YORNK.png">http://i.imgur.com/L1YORNK.png</a> ; note that it seems to filling<br></div><div>#a different part of the plotting "window"<br>
<br></div><div>#Now try a 2 kpc tall plot<br>slc = SlicePlot(pf, 'x', 'Density',center='c',width=((1,"kpc"),(2.0,"kpc")))<br>slc.annotate_title('This is a Density plot')<br>
slc.save('test_2kpc.png')<br>slc.show()<br><br><div>#Please see plot at <a href="http://i.imgur.com/Bq1WaIP.png">http://i.imgur.com/Bq1WaIP.png</a> ; note that it seems to filling<br></div>#even MORE of the plotting "window", but that the density labels were cut off a bit.<br>
<br><br></div><div>OK, now the part that doesn't work. After reading, I decided that an frb must be<br>the way to go, so I tried<br>frb = FixedResolutionBuffer(slc, (0.0, 1.0, 0.0, 1.0), (1024,1024))<br>plt.imshow(frb['Density'])<br>
plt.savefig('test_figure.png')<br><br></div><div>and I get the following error. Note: I also tried slc.to_frb and that didn't work either.<br><div style class=""><div class=""><div class=""><pre><span class="">---------------------------------------------------------------------------</span>
<span class="">AttributeError</span> Traceback (most recent call last)
<span class=""><ipython-input-17-e68719d58ae4></span> in <span class=""><module><span class="">()</span>
<span class="">----> 1<span class=""> </span>frb</span> <span class="">=</span> </span>FixedResolutionBuffer<span class="">(</span>slc<span class="">,</span> <span class="">(</span><span class="">0.0</span><span class="">,</span> <span class="">1.0</span><span class="">,</span> <span class="">0.0</span><span class="">,</span> <span class="">1.0</span><span class="">)</span><span class="">,</span> <span class="">(</span><span class="">1024</span><span class="">,</span><span class="">1024</span><span class="">)</span><span class="">)</span><span class=""></span>
<span class=""> 2</span> plt<span class="">.</span>imshow<span class="">(</span>frb<span class="">[</span><span class="">'Density'</span><span class="">]</span><span class="">)</span><span class=""></span>
<span class=""> 3</span> plt<span class="">.</span>savefig<span class="">(</span><span class="">'test_figure.png'</span><span class="">)</span><span class=""></span>
<span class=""> 4</span> <span class=""></span>
<span class=""> 5</span> <span class=""></span>
<span class="">/Users/kde/yt-x86_64/src/yt-hg/yt/visualization/fixed_resolution.pyc</span> in <span class="">__init__<span class="">(self, data_source, bounds, buff_size, antialias, periodic)</span>
<span class=""> 89</span> </span>self<span class="">.</span>antialias <span class="">=</span> antialias<span class=""></span>
<span class=""> 90</span> self<span class="">.</span>data <span class="">=</span> <span class="">{</span><span class="">}</span><span class=""></span>
<span class="">---> 91<span class=""> </span>self</span><span class="">.</span>axis <span class="">=</span> data_source<span class="">.</span>axis<span class=""></span>
<span class=""> 92</span> self<span class="">.</span>periodic <span class="">=</span> periodic<span class=""></span>
<span class=""> 93</span> <span class=""></span>
<span class="">AttributeError</span>: 'SlicePlot' object has no attribute 'axis'
</pre></div></div></div>THanks in advance for any help. <br></div><div>cheers<br></div><div>kathy<br><br><br></div><div>-- <br>Kathy DeGioia Eastwood, Ph.D.<br>Professor of Physics and Astronomy<br>Northern Arizona University<br>
Flagstaff, AZ 86011-6010<br>Ph: 928-523-7159 FX: 928-523-1371<br><a href="mailto:Kathy.Eastwood@nau.edu" target="_blank">Kathy.Eastwood@nau.edu</a><br>deliveries: 602 S. Humphreys St., Bldg 19 Rm 209
</div></div></div></div>