[yt-users] Problem about using yt to visualize simulation data

Nathan Goldbaum nathan12343 at gmail.com
Wed Feb 1 07:55:13 PST 2017


If I had to guess, what's happening is that the underlying profile object
(which you can think of as a 1D histogram) is poorly sampled at small
radii, such that some of the histogram bins are empty.

The weirdness you're seeing at small radii is the histogram jumping from
valid values near 4e9K to zero for empty histogram bins.

For a ProfilePlot you can take a look at the underlying histogram bins and
values using a script like this:

http://paste.yt-project.org/show/7008/

The output of running this script is here:

http://paste.yt-project.org/show/7009/

And the ProfilePlot image it generates is here:

http://i.imgur.com/lXILSyW.png

Note that this uses a public test dataset from yt-project.org/data that you
can download yourself if you want to run the script.

As you can see, at small radii this plot exhibits similar behavior to your
plot. And if you look at the output of running the script, you'll see that
indeed many of the bins at small radii (see the output of
print(prof['temperature']) in my script) have values of zero. These are
empty bins.

This is a purposeful design decision and is technically correct although
possibly confusing. In principle we could fix this by choosing more
"natural" uneven bin widths, but right now that has not yet been
implemented. Switching between linear and logarithmically spaced bins also
sometimes helps. And, as you've done, using manually chosen limits for the
bins can also help by not creating any bins that will sample regions of
parameter space that are poorly sampled.

Hope that helps you to understand what's going on.

-Nathan

On Tue, Jan 31, 2017 at 4:39 PM, Mu-Hung Chang <mu-hung.chang at stonybrook.edu
> wrote:

> Hi, sorry I forgot to attach the figures. Here is it.
>
> On Tue, Jan 31, 2017 at 5:32 PM, Mu-Hung Chang <
> mu-hung.chang at stonybrook.edu> wrote:
>
>> Hi, I've encountered a problem when I tried to use yt to visualize simple
>> 1D detonation simulation data generated by Castro. The figure I expected to
>> get is a simple step function just as attachment
>> "1d_detonation_expected.png". However, if I don't set a customized axis
>> limit by hand, it will produce something weird at the origin, which can be
>> seen in the attachment "1d_detonation_weird.png". Following is my simple
>> script to make plots. I wonder where I did wrong thus make this happened.
>> Thank you for answering.
>>
>> import sys
>>
>> import yt
>>
>> import yt.units as u
>>
>>
>> def doit(plotfile):
>>
>>     ds = yt.load(plotfile)
>>
>>     ds.periodicity = (False, False, False)
>>
>>     ad = ds.all_data()
>>
>>     plot = yt.ProfilePlot(ad, "x", "temperature")
>>
>>     plot.set_unit("temperature", "K")
>>
>>     plot.set_unit("x", "m")
>>
>>     plot.set_log('x', False)
>>
>>     plot.set_xlim(1e-20, 450.0)
>>
>>     pid = plotfile.split("plt")[1]
>>
>>     plot.save("1d_detonation_{}.png".format(pid))
>>
>>
>> if __name__ == "__main__":
>>
>>
>>     # Choose a field
>>
>>
>>
>>     plotfile = ""
>>
>>     try:
>>
>>         plotfile = sys.argv[1]
>>
>>     except:
>>
>>         sys.exit("ERROR: no plotfile specified")
>>
>>     for plt in sys.argv[1:]:
>>
>>         plotfile = plt
>>
>>         doit(plotfile)
>>
>> Best,
>> Mu-Hung
>>
>
>
> _______________________________________________
> 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/20170201/5bc65bca/attachment-0001.htm>


More information about the yt-users mailing list