[yt-users] Why the two figures have different resolutions?
bazhaoyu_sjtu
hudan_bazhaoyu at sjtu.edu.cn
Tue May 16 04:38:15 PDT 2017
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'
-------------------------------------------------------------------------------------------------
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.
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/
> <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/
> <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
> <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/20170516/0a6b2d10/attachment.html>
More information about the yt-users
mailing list