Hi Kathy,
Sorry you're having trouble!
Whoa! That's pretty squished.
On Tue, Nov 26, 2013 at 1:21 PM, Kathy Eastwood <kathy.eastwood@nau.edu> wrote:
> Dear (very helpful) yt folk:
>
> 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.
>
> The SlicePlot weirdnesses:
> from yt.mods import *
> %matplotlib inline
> import matplotlib.pyplot as plt
> import matplotlib.image as mpimg
> import matplotlib.colorbar as cb
> import numpy as np
> pf = load("Strat_Box_hdf5_plt_cnt_0064")
> #First try a 20 kpc tall box
> slc = SlicePlot(pf, 'x',
> 'Density',center='c',width=((1,"kpc"),(20.0,"kpc")))
> slc.annotate_title('This is a Density plot')
> slc.save('test_20kpc.png')
> slc.show()
> #Please see plot at http://i.imgur.com/N65CNfU.png
Okay, so I *think* I might have an idea what's going on here. I've
>
> #Now try a 5 kpc tall plot
> slc = SlicePlot(pf, 'x', 'Density',center='c',width=((1,"kpc"),(5.0,"kpc")))
> slc.annotate_title('This is a Density plot')
> slc.save('test_5kpc.png')
> slc.show()
>
> #Please see plot at http://i.imgur.com/L1YORNK.png ; note that it seems to
> filling
> #a different part of the plotting "window"
>
> #Now try a 2 kpc tall plot
> slc = SlicePlot(pf, 'x', 'Density',center='c',width=((1,"kpc"),(2.0,"kpc")))
> slc.annotate_title('This is a Density plot')
> slc.save('test_2kpc.png')
> slc.show()
>
> #Please see plot at http://i.imgur.com/Bq1WaIP.png ; note that it seems to
> filling
> #even MORE of the plotting "window", but that the density labels were cut
> off a bit.
>
replicated the problem here, but I don't have any ideas how to fix it.
It's basically just that (automatically) coming up with the right
aspect ratio for the *figure* is tricky when the image is not the
right aspect ratio. I think Devin Silvia, Nathan Goldbaum and Kacper
Kowalik have all worked hard on this but not had a lot of success. It
also looks to me like the FRB may have a uniform aspect ratio
(800x800) which may be contributing to the problem. So, on to FRBs
...
Ah, this one we can fix. Here what the FRB wants is actually the
>
> OK, now the part that doesn't work. After reading, I decided that an frb
> must be
> the way to go, so I tried
> frb = FixedResolutionBuffer(slc, (0.0, 1.0, 0.0, 1.0), (1024,1024))
> plt.imshow(frb['Density'])
> plt.savefig('test_figure.png')
>
> and I get the following error. Note: I also tried slc.to_frb and that
> didn't work either.
>
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call last)
> <ipython-input-17-e68719d58ae4> in <module>()
> ----> 1 frb = FixedResolutionBuffer(slc, (0.0, 1.0, 0.0, 1.0), (1024,1024))
> 2 plt.imshow(frb['Density'])
> 3 plt.savefig('test_figure.png')
> 4
> 5
>
> /Users/kde/yt-x86_64/src/yt-hg/yt/visualization/fixed_resolution.pyc in
> __init__(self, data_source, bounds, buff_size, antialias, periodic)
> 89 self.antialias = antialias
> 90 self.data = {}
> ---> 91 self.axis = data_source.axis
> 92 self.periodic = periodic
> 93
>
> AttributeError: 'SlicePlot' object has no attribute 'axis'
>
slice itself, not the slice plot. There are two ways to do this. The
first is to grab the *existing* slice object:
sl = slc.data_source
and feed sl into a FixedResolutionBuffer creation. But I think, since
you're going to avoid all of the slice plot machinery altogether, it'd
probably make more sense to take control of it with the data object
machinery directly. So you can create a slice, which is a data
source, like this:
sl = pf.h.slice(2, pf.domain_center[2])
What I'm doing here is saying axis 2 (z) and at the z-th coordinate of
the domain center. Now if we query sl, we get all of the data points;
this isn't what we want, since they are all different resolutions, so
we use the FRB. sl objects have a handy way of making FRBs:
sl.to_frb( ...
this takes a width (which can be a tuple), a resolution, and
optionally a height. help(sl.to_frb) will show the arguments and an
example. Now the FRB can be queried like you would a data object, and
it gives back (N,N) arrays. Hope that helps, and let us know!
-Matt
PS Those are some gorgeous simulation results, by the way.
> _______________________________________________
> THanks in advance for any help.
> cheers
> kathy
>
>
> --
> Kathy DeGioia Eastwood, Ph.D.
> Professor of Physics and Astronomy
> Northern Arizona University
> Flagstaff, AZ 86011-6010
> Ph: 928-523-7159 FX: 928-523-1371
> Kathy.Eastwood@nau.edu
> deliveries: 602 S. Humphreys St., Bldg 19 Rm 209
>
> yt-users mailing list
> yt-users@lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>