[yt-users] Derivative Error

Matthew Turk matthewturk at gmail.com
Thu Jun 14 10:57:44 PDT 2012


Hi Nathan,

On Thu, Jun 14, 2012 at 1:55 PM, Nathan Butcher <butchernate at gmail.com> wrote:
> Hello,
>
> The images are the same as before. I will try to create a simpler test case
> to check this field and see if it behaves properly. Thank you for all of the
> help.

Okay, I figured out what is going on.

Without spatial validation, this sequence:

new_field = na.zeros(data['PotentialField'].shape)
new_field[1:-1] = data["PotentialField"][sl_right]/ds
new_field[1:-1] -= data["PotentialField"][sl_left]/ds

is operating on 1D, mostly unsorted arrays.  The points next to each
other are probably not in x-order, so this doesn't do much.  When you
do validate spatial, it oeprates on a grid-by-grid basis, and adjacent
points are adjacent spatially.

So this is okay, and the correct result is the one with the
ValidateSpatial call.

-Matt

>
> Nathan
>
>
> On Thu, Jun 14, 2012 at 1:44 PM, Matthew Turk <matthewturk at gmail.com> wrote:
>>
>> Hi Nathan,
>>
>> How are you centering the slice?  This looks somewhat like a
>> difference in the centering.  Can you try something like:
>>
>> pc = PlotCollection(pf, 'c')
>> pc.add_slice("GravGradient", "x")
>> pc.save()
>>
>> for both the old and new, and see if they look similar?
>>
>> -Matt
>>
>> On Thu, Jun 14, 2012 at 1:41 PM, Nathan Butcher <butchernate at gmail.com>
>> wrote:
>> > The colorbar scaling is similar, and the values have changed. It could
>> > be a
>> > large shift. It is hard for me to tell from the plot. I have attached
>> > the
>> > updated plot.
>> >
>> > Nathan
>> >
>> >
>> > On Thu, Jun 14, 2012 at 1:32 PM, Matthew Turk <matthewturk at gmail.com>
>> > wrote:
>> >>
>> >> On Thu, Jun 14, 2012 at 1:31 PM, Nathan Butcher <butchernate at gmail.com>
>> >> wrote:
>> >> > Hello Matt,
>> >> >
>> >> > Thanks, that seems to have done fixed the issue. I am seeing that the
>> >> > graph
>> >> > looks very different now compared to before. Would forgetting the
>> >> > extra
>> >> > zone
>> >> > change the appearance of the overall plot beyond edge effects?
>> >>
>> >> It should shift the derivative considerably, but the only other
>> >> differences should be at the edges.  Are the actual values different,
>> >> or is the colorbar scaling differently now?
>> >>
>> >> >
>> >> > Thank you,
>> >> > Nathan Butcher
>> >> >
>> >> >
>> >> > On Thu, Jun 14, 2012 at 1:21 PM, Matthew Turk <matthewturk at gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> Hi Nathan,
>> >> >>
>> >> >> Yup, I agree with your assessment -- there's an edge effect.  You
>> >> >> need
>> >> >> one more thing to get the derivative field working; you need to tell
>> >> >> yt to give you an extra zone in each direction.  You can do that by
>> >> >> changing your decorator for the derived field to:
>> >> >>
>> >> >> @derived_field(name = "GravGradientX", validators =
>> >> >> [ValidateSpatial(1)])
>> >> >>
>> >> >> I don't believe you need any additional changes inside the source
>> >> >> code.  Let us know if that fixes it!
>> >> >>
>> >> >> -Matt
>> >> >>
>> >> >> On Thu, Jun 14, 2012 at 1:14 PM, Nathan Butcher
>> >> >> <butchernate at gmail.com>
>> >> >> wrote:
>> >> >> > Hello,
>> >> >> >
>> >> >> > Using an Enzo dataset, I have written a function to find the
>> >> >> > derivative
>> >> >> > in
>> >> >> > the x-direction of a field. When I try to plot the derivative, I
>> >> >> > see
>> >> >> > lines
>> >> >> > that throughout the plot that I'm guessing are due to the edges of
>> >> >> > cells.
>> >> >> > The attached plot is a slice of the x-direction derivative of the
>> >> >> > PotentialField viewed down the x-axis, but this error appears in
>> >> >> > plots
>> >> >> > for
>> >> >> > density and pressure as well. I am new to using yt, and I am not
>> >> >> > sure
>> >> >> > what
>> >> >> > is causing this.
>> >> >> >
>> >> >> > Thank you,
>> >> >> > Nathan Butcher
>> >> >> >
>> >> >> > _______________________________________________
>> >> >> > 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
>> >
>> >
>> >
>> > _______________________________________________
>> > 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
>



More information about the yt-users mailing list