[yt-users] Why the two figures have different resolutions?
bazhaoyu_sjtu
hudan_bazhaoyu at sjtu.edu.cn
Wed May 17 22:54:32 PDT 2017
Hi Nathan,
I'm so sorry that I haven't expressed clearly.
I learned your code, and replotted two images. The complete script:
http://paste.yt-project.org/show/7146/
where the 'surface brightness' is a derived field by myself.
And my data 'snap_206.hdf5': http://use.yt/upload/c7c0d617
Here's the two images:
regular projection: https://1drv.ms/i/s!Aq__4QGcEmxvh06ErW9t_0BK-LQR
off-axis projection: https://1drv.ms/i/s!Aq__4QGcEmxvh09ajn0UdatFjIil
The off-axis one is still blockier. So How can I fix it? I want to have
same resolution of two figures.
Thanks for you help!
Regards,
Dan
On 05/16/2017 08:39 PM, Nathan Goldbaum wrote:
>
> On Tue, May 16, 2017 at 6:38 AM bazhaoyu_sjtu
> <hudan_bazhaoyu at sjtu.edu.cn <mailto:hudan_bazhaoyu at sjtu.edu.cn>> wrote:
>
> Hi Nathan,
>
> Thank you for your prompt reply!
>
> I also have two questions:
>
> 1. When I tried your new script, the bug are presented below:
> -------------------------------------------------------------------------------------------------
> pz.set_size_inches(10)
> AttributeError: 'ProjectionPlot' object has no attribute
> 'set_size_inches'
>
>
> Oops, that should have been pz.set_figure_size(10). I thought I fixed
> that it I guess I forgot to update the email. Sorry for the confusion.
>
>
> -------------------------------------------------------------------------------------------------
>
> 2. For your two images, I also found that figure's resolution of
> the 'off-axis projection' is worse than the 'regular projection',
> for example, the 'off-axis projection' figure has more obvious
> grid point.
> Is there any difference between two projection ways? Because I
> supposed it should be same.
>
>
> They are generated using very different algorithms. The axis-aligned
> projection is calculated based on an adaptive quadtree while the
> off-axis projection is calculated using a ray-casting volume renderer.
>
> I agree with you that in principle they should come out with
> identical-looking results for the script you provided. It's possible
> that you're data is exposing a corner case that somehow makes the
> off-axis projection appear blockier. It's hard to say without more
> info. Please see the last paragraph of my last message about this, if
> you share an example dataset that triggers this behavior or share the
> images you are seeing it will make it easier to speak intelligently
> about what you are seeing.
>
>
>
> Thank you again!
>
> Regards,
> Dan
>
>
>
>
>
>
> On 05/15/2017 09:56 PM, Nathan Goldbaum wrote:
>> Hi Dan,
>>
>> I adapted your script to use a public dataset from
>> yt-project.org/data <http://yt-project.org/data>. I also don't
>> have a definition for a surface_brightness field in my copy of
>> yt, so I guess you defined that elsewhere? I used 'density'.
>> Here's the script I ended up coming up with:
>>
>> http://paste.yt-project.org/show/7142/
>>
>> (note that you can upload scripts with the "yt pastebin" command
>> line tool, e.g. "yt pastebin my_script.py")
>>
>> And indeed, in that case I get two images that aren't the desired
>> high resolution you're looking for (although both images have the
>> same resolution). The issue is that yt is saving the figure to
>> disk through matplotlib. To control the image size in pixels
>> through matplotlib you need to know the figure size in inches and
>> the dpi (e.g. the number of pixels per inch of figure). Here's a
>> revised version of the script above which saves to disk two
>> images with the desired 3200x3200 resolution:
>>
>> http://paste.yt-project.org/show/7145/
>>
>> It also hides the axes and colorbar, since that makes it easier
>> to guess ahead of time what the final image resolution will be.
>> Here are the two images:
>>
>> regular projection: http://i.imgur.com/ialfYC4.png
>> off-axis projection: http://i.imgur.com/PcvPZ9f.png
>>
>> You can share images you make using yt using the "yt
>> upload_image" command, which will upload an image stored locally
>> to imgur. We usually suggest using that to share images or
>> alternatively something like a Jupyter notebook on
>> gist.github.com <http://gist.github.com> to avoid clogging
>> people's e-mail with high resolution images.
>>
>> Finally, if you don't want to mess with matplotlib and just want
>> the underlying images, you can get those via the frb attribute of
>> the plot object. Something like:
>>
>> plot = yt.ProjectionPlot(ds, 'z', ('gas', 'density'))
>> plot.set_buff_size((3200, 3200))
>>
>> # image will be a 3200x3200 numpy array
>> image = plot.frb['gas', 'density']
>>
>> I hope that helps clear things up. If you are still having issues
>> it would help if you could share the exact yt version you are
>> using as well as a runnable test script that demonstrates the
>> issue. If you can't trigger the issue using one of the public SPH
>> datasets on yt-project.org/data <http://yt-project.org/data>, you
>> can share one of your datasets using the yt curldrop:
>> https://docs.hub.yt/services.html#curldrop
>>
>> -Nathan
>>
>> On Mon, May 15, 2017 at 4:40 AM, bazhaoyu_sjtu
>> <hudan_bazhaoyu at sjtu.edu.cn <mailto:hudan_bazhaoyu at sjtu.edu.cn>>
>> wrote:
>>
>> Hi yt-users:
>>
>> I want to ask you a question about the figures' resolution, I
>> handled Gadget file -- hdf5.
>>
>> I used the 'ProjectionPlot' to plot the surface brightness
>> map which is integrated along the 'z' axis, please see the
>> figure 1; And I plot another surface brightness map by
>> 'OffAxisProjectionPlot' with the normal_vector is [0, 0, 1],
>> please see the figure 2.
>>
>> # I can't upload attachments ??? #
>>
>> Comparing two figures, we can find the structures of them is
>> same, but the resolution is different! The
>> 'OffAxisProjectionPlot' is obviously worse than
>> 'ProjectionPlot', I don't know why!
>>
>> Below are the process I created two figures:
>>
>> ======================================================================
>> import yt
>> import numpy as np
>> import yt.units as units
>> import pylab
>>
>> fname = "snap_206.hdf5"
>> unit_base = {'UnitLength_in_cm' : 3.08568e+21,
>> 'UnitMass_in_g' : 1.989e+43,
>> 'UnitVelocity_in_cm_per_s' : 100000}
>> bbox_lim = 1e5 # kpc
>> bbox = [[-bbox_lim,bbox_lim],
>> [-bbox_lim,bbox_lim],
>> [-bbox_lim,bbox_lim]]
>> ds = yt.load(fname,unit_base=unit_base,bounding_box=bbox)
>> ds.index
>> ad= ds.all_data()
>>
>>
>> ## For 'ProjectionPlot' ##
>> pz = yt.ProjectionPlot(ds, 'z', ('gas',
>> 'surface_brightness'), 'max', width=(0.4,'Mpc'))
>>
>>
>> ## For 'OffAxisProjectionPlot' ##
>> L = [0,0,1]
>> north_vector = [0,1,0]
>> pz = yt.OffAxisProjectionPlot(ds, L, ('gas',
>> 'surface_brightness'), 'max', north_vector = north_vector,
>> width=(0.4,'Mpc'))
>>
>>
>> pz.set_buff_size((3200,3200))
>> pz.save()
>> =========================================================================
>>
>> What can i do to fix this difference of resolution between
>> two plot ways?
>> Thanks a lot!
>>
>> Regards,
>> Dan
>>
>>
>> ==================================
>> Department of Physics, Shanghai Jiao Tong University
>> 800 Dongchuan Road, Minhang, Shanghai 200240, PRC
>> E-mail : hudan_bazhaoyu at 163.com <mailto:hudan_bazhaoyu at 163.com>
>> hudan_bazhaoyu at sjtu.edu.cn <mailto:hudan_bazhaoyu at sjtu.edu.cn>
>> ==================================
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> <mailto: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 <mailto: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 <mailto: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/20170518/a4ce870c/attachment-0001.htm>
More information about the yt-users
mailing list