[yt-users] Output Resolution

Matthew Turk matthewturk at gmail.com
Wed Mar 25 17:30:34 PDT 2009


Hi Dave,

The AMRSlice/AMRProj object contains flattened arrays of the entire
domain, (px, py, pdx, pdy, z_0 ... z_n) where px, py are in the image
plane.  z_0 ... z_n are all the fields associated with them.  Note
that this is a collection of arrays in a dict, not a single
concatenated array.

The size of the buffer is governed by the size of the 'bounding box'
of the image plot:

http://yt.enzotools.org/browser/trunk/yt/raven/PlotTypes.py#L271

and then it calls my Pixelize routine to turn (px, py, pdx, pdy, z_i)
into an NxM array of z'.  The number of pixels that it generates is
not always well-determined if you change the DPI; as it stands, with
100, it should generate roughly 800x800, but I am not sure if the
border causes an off-by-two (one for each edge) along each dimension.
Pixelize can try to anti-alias, which it does by default.

If you need more fine-grain control over the output buffer, you can
use the FixedResolutionBuffer object (this is only in trunk, which is
why it's not in the primary docs on the YT website, but it is in the
trunk documentation, which comes with yt.)  This object is defined
here:

http://yt.enzotools.org/browser/trunk/yt/raven/FixedResolution.py#L30

If you feed it a 2D data object (either a slice or projection; you
need ObliqueFRB for a cutting plane) as well as the bounds that you
want it span and the size of the buffer you want back, it will act as
a dict, pixelizing and returning arrays of whatever you request.  For
instance:

--
from yt.mods import *
pf = EnzoStaticOutput("data0001")
proj = pf.h.proj(0, "Density")

frb = raven.FixedResolutionBuffer(proj, (0.0, 1.0, 0.0, 1.0), (1024, 1024))
--

frb would now be a FixedResolutionBuffer running from 0..1 in both x
and y, and it knows it should be (1024, 1024) in size.  You can now
access:

frb["Density"]

and it returns an array that has been pixelized.

Hope that helps!

-Matt

On Wed, Mar 25, 2009 at 5:29 PM, David Collins
<dcollins at physics.ucsd.edu> wrote:
> I have a follow up question--
>
> What determines the size of the temporary 2dAMR object?  And what
> determines the size of the buffer that ultimately gets turned into the
> png (or, what's the mechanism and where is that conversion done)?
>
> d.
>
> On Wed, Mar 25, 2009 at 3:02 PM, Matthew Turk <matthewturk at gmail.com> wrote:
>> Hi Dave,
>>
>> YT doesn't do any modification of the DPI that matplotlib knows about.
>>  You can see what the default is with:
>>
>> import matplotlib
>> matplotlib.rcParams["savefig.dpi"]
>>
>> For me, it defaults to 100.  (The parameter figure.dpi controls
>> displayed, for instance in a PlotCollectionInteractive.)  If you
>> modify this parameter at the start of your script, or in your
>> matplotlibrc file, you can change the default dpi, which then affects
>> the size of the figure coming out of your save commands.   (There is
>> some rather old, but probably mostly relevant, documentation here:
>> http://www.scipy.org/Cookbook/Matplotlib/AdjustingImageSize and then a
>> bit more up to date discussion here:
>> http://matplotlib.sourceforge.net/faq/installing_faq.html?highlight=dpi#id1
>> )
>>
>> To change your DPI to another value on output, you can modify this parameter:
>>
>> import matplotlib
>> matplotlib.rcParams["savefig.dpi"] = 300
>>
>> for instance.
>>
>> Hope that helps!
>>
>> -Matt
>>
>> On Wed, Mar 25, 2009 at 2:52 PM, david collins <antpuncher at gmail.com> wrote:
>>> Hi there--
>>>
>>> What's the relationship between the resolution of a plot and the
>>> fig_size argument in add_projection?  Is there a dpi flag somewhere,
>>> or something so I can control the number of pixels in the output
>>> image?
>>>
>>> Thanks,
>>> d.
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>



More information about the yt-users mailing list