[yt-users] plotting average quantaties

Britton Smith brittonsmith at gmail.com
Tue Oct 22 22:56:37 PDT 2013


Hi John,

It sounds like what you want to do is make a projection in the y axis.  I
am not sure whether yt supports projections in 2D datasets, but if it does,
the projection object will contain the projected data at every unique x
coordinate.  Since you're looking for average values, you would make a
weighted projection.  You can try:
pf = load(...)
proj = pf.h.proj(1, field, weight_field=something)
Then, you can get that data by doing:
proj[field]
and
proj['x']

Britton


On Wed, Oct 23, 2013 at 1:46 AM, John Forbes <jcforbes at ucsc.edu> wrote:

> One issue I've run into in the past is that binning by 'x' with
> BinnedProfile1D may not produce exactly what one would like. In particular,
> if your data has non-uniform cell sizes, then in the derefined regions the
> 1D profile will have peaks at the positions of cell centers. For instance
> if my coarsest grid extends from x=0 to x=4 with 8 cells, and much of my
> grid is not refined, my 1D profile will have features at x=0.25, 0.75, etc.
> I'm not sure if any built-in yt functionality which gets around this issue
> (if you run into it). Maybe you could create a FixedResolutionBuffer and do
> whatever sum you want manually over one dimension of the corresponding
> numpy array?
>
> Good luck,
> John
>
>
> On Tue, Oct 22, 2013 at 5:45 AM, j s oishi <jsoishi at gmail.com> wrote:
>
>> I think Sasha may want a simpler, unweighted average. You can do this by
>> setting the weight field to Ones. If you set the weight to None, you'll get
>> a sum across x.
>>
>> You'll probably want to set n_bins to the number of x cells to get what
>> you are looking for.
>>
>> Hope this is helpful,
>>
>> Jeff
>> On Oct 22, 2013 8:25 AM, "Matthew Turk" <matthewturk at gmail.com> wrote:
>>
>>> Hi Sasha,
>>>
>>> I'm not sure I understand what you're looking for.  The functionality to
>>> take averages of one field wrt another field might work for what you're
>>> looking for, using the BinnedProfile1D object.  If so, you could bin by the
>>> "x" field and then take a weighted average of Density.  This might look
>>> something like this:
>>>
>>> dd = pf.h.all_data()
>>> prof = BinnedProfile1D(dd, n_bins, "x", pf.domain_left_edge[0],
>>> pf.domain_right_edge[0], log_space = False)
>>> prof.add_fields(["Density"], weight="CellMassMsun")
>>>
>>> Does that help?
>>>
>>> Best,
>>>
>>> Matt
>>>
>>>
>>> On Mon, Oct 21, 2013 at 11:29 PM, Alexander Philippov <
>>> philippo at astro.princeton.edu> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I would like to plot 1D profile of quantity (say, density) averaged
>>>> over 1 axis
>>>> (say, x) from two-dimensional data. Is there any cheap way to do it?
>>>>
>>>> Thanks in advance,
>>>> Sasha
>>>> _______________________________________________
>>>> 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
>>>
>>>
>> _______________________________________________
>> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20131023/1dc3cdab/attachment.html>


More information about the yt-users mailing list