Hi, I was trying the following 2 methods... from yt.mods import * p = plots.get_slice("RedshiftOutput0002", "Density", 0) p.modify["grids"]() p.modify["contour"]("Density") p.save_image("plot1") from yt.mods import * pf = load("RedshiftOutput0002") pc = PlotCollection(pf) for ax in range(1): pc.add_slice("Density", ax).modify["grids"]() pc.save("plot2") I have the plots for them attached. My simulation box is 200 Mpc/h. I wanted to know what are the default span (length scales) for the 2 methods ? For plot 1, how can I control the spacing of contours ? And where is plot 1 centered at ? For plot 2, it is centered at the most dense point in the box. But how can I add density contours ? Also, how to control the spacing ? regards shankar KU Cosmology
Hi Shankar,
My simulation box is 200 Mpc/h. I wanted to know what are the default span (length scales) for the 2 methods ? For plot 1, how can I control the spacing of contours ? And where is plot 1 centered at ?
It took me a moment to track down what's happening. The default length scale is "unitary" -- which is the entire domain. However, the difference between the two plots is because plot collection-mediated plots default to being periodic, and this will reset . I have changed it so that the behavior between the two plot generation mechanisms is identical, in r1543. However, if you do not wish to upgrade, you can feed the argument "periodic=True" to the get_slice_plot call.
For plot 2, it is centered at the most dense point in the box. But how can I add density contours ? Also, how to control the spacing ?
You can add density contours the same way you did for the first mechanism -- through the modify["contours"] call. :) You can control the spacing a couple ways, as mentioned in the manual: http://yt.enzotools.org/doc/advanced/callbacks.html#available-callbacks through the ncont, clim, and take_log functions. If you look at the source code, you can see that ncont is fed directly to the matplotlib contour command -- so you can get greater control by feeding it, for instance, a list of density contours. Note that the mechanism for log-spaced contours is to log the data, not request log-spaced contours, so you will have to keep that in mind if you choose to request specific contour levels. -Matt
Thanks Matt. Also, I am not able to loop over method 1. I am using the stupid way as shown below. And method 2 is not showing the grids. from yt.mods import * # method1 p = plots.get_slice("RedshiftOutput0002", "Density", 0) p.modify["grids"]() p.modify["contour"]("Density") p.save_image("a") p = plots.get_slice("RedshiftOutput0002", "Density", 1) p.modify["grids"]() p.modify["contour"]("Density") p.save_image("b") p = plots.get_slice("RedshiftOutput0002", "Density", 2) p.modify["grids"]() p.modify["contour"]("Density") p.save_image("c") # method2 pf = load("RedshiftOutput0002") pc = PlotCollection(pf) for ax in range(3): pc.add_slice("Density", ax).modify["grids"]() pc.add_slice("Density", ax).modify["contour"]("Density") pc.save("plot2") shankar -----Original Message----- From: yt-users-bounces@lists.spacepope.org on behalf of Matthew Turk Sent: Tue 11/24/2009 10:44 AM To: Discussion of the yt analysis package Subject: Re: [yt-users] plotting questions Hi Shankar,
My simulation box is 200 Mpc/h. I wanted to know what are the default span (length scales) for the 2 methods ? For plot 1, how can I control the spacing of contours ? And where is plot 1 centered at ?
It took me a moment to track down what's happening. The default length scale is "unitary" -- which is the entire domain. However, the difference between the two plots is because plot collection-mediated plots default to being periodic, and this will reset . I have changed it so that the behavior between the two plot generation mechanisms is identical, in r1543. However, if you do not wish to upgrade, you can feed the argument "periodic=True" to the get_slice_plot call.
For plot 2, it is centered at the most dense point in the box. But how can I add density contours ? Also, how to control the spacing ?
You can add density contours the same way you did for the first mechanism -- through the modify["contours"] call. :) You can control the spacing a couple ways, as mentioned in the manual: http://yt.enzotools.org/doc/advanced/callbacks.html#available-callbacks through the ncont, clim, and take_log functions. If you look at the source code, you can see that ncont is fed directly to the matplotlib contour command -- so you can get greater control by feeding it, for instance, a list of density contours. Note that the mechanism for log-spaced contours is to log the data, not request log-spaced contours, so you will have to keep that in mind if you choose to request specific contour levels. -Matt _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Shankar,
Also, I am not able to loop over method 1. I am using the stupid way as shown below.
Sure you can loop! :) Here's a way to do it: for ax in range(3): p = plots.get_slice("RedshiftOutput0002", "Density", ax) p.modify["grids"]() p.modify["contours"]("Density") p.save_image("something_%s" % ax) That last line will make sure that your images have different names -- and that's actually what's going wrong with the second loop that you had below. (I'd like to note that having similar plots on different axes is why the Plot Collection is around -- so I'd suggest you stick to that, as it will make changing widths and whatnot easier.)
And method 2 is not showing the grids. for ax in range(3): pc.add_slice("Density", ax).modify["grids"]() pc.add_slice("Density", ax).modify["contour"]("Density") pc.save("plot2")
Ah! What's going on here is that the plot collection, at the end of the loop, has *six* plots: slice on x with grids slice on x with contours slice on y with grids slice on y with contours slice on z with grids slice on z with contours BUT, the callbacks aren't taken into account when creating image file names. So it just overwirtes the first slice with the second, the third with the fourth, and the fifth with the sixth. What you probably want to do is: for ax in range(3): p = pc.add_slice("Density", ax) p.modify["grids"]() p.modify["contour"]("Density") pc.save("plot2") This way you're modifying the same plot object with both grids and contours. Best of luck, Matt
Hi Matt, So I tried to plot the velocity vectors. But they cover only 1/4th of the Box. And what can I do about "unitary" ? pf = load("RedshiftOutput0002") pc = PlotCollection(pf) for ax in range(3): p = pc.add_slice("Density", ax) p.modify["grids"]() p.modify["contour"]("Density",ncont=4,take_log=True,clim=(1e-28,1e-30)) p.modify["velocity"](factor=16) p.modify["coord_axes"](unit="Mpc") pc.save("plot2") shankar -----Original Message----- From: yt-users-bounces@lists.spacepope.org on behalf of Matthew Turk Sent: Tue 11/24/2009 11:05 AM To: Discussion of the yt analysis package Subject: Re: [yt-users] plotting questions Hi Shankar,
Also, I am not able to loop over method 1. I am using the stupid way as shown below.
Sure you can loop! :) Here's a way to do it: for ax in range(3): p = plots.get_slice("RedshiftOutput0002", "Density", ax) p.modify["grids"]() p.modify["contours"]("Density") p.save_image("something_%s" % ax) That last line will make sure that your images have different names -- and that's actually what's going wrong with the second loop that you had below. (I'd like to note that having similar plots on different axes is why the Plot Collection is around -- so I'd suggest you stick to that, as it will make changing widths and whatnot easier.)
And method 2 is not showing the grids. for ax in range(3): pc.add_slice("Density", ax).modify["grids"]() pc.add_slice("Density", ax).modify["contour"]("Density") pc.save("plot2")
Ah! What's going on here is that the plot collection, at the end of the loop, has *six* plots: slice on x with grids slice on x with contours slice on y with grids slice on y with contours slice on z with grids slice on z with contours BUT, the callbacks aren't taken into account when creating image file names. So it just overwirtes the first slice with the second, the third with the fourth, and the fifth with the sixth. What you probably want to do is: for ax in range(3): p = pc.add_slice("Density", ax) p.modify["grids"]() p.modify["contour"]("Density") pc.save("plot2") This way you're modifying the same plot object with both grids and contours. Best of luck, Matt _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Shankar, -Matt On Tue, Nov 24, 2009 at 10:30 AM, Agarwal, Shankar <sagarwal@ku.edu> wrote:
Hi Matt,
So I tried to plot the velocity vectors. But they cover only 1/4th of the Box.
They cover the entire box, but they do not support periodicity. You're centered in the lower left quadrant, so they only cover the non-shifted regions. If you want the velocity vectors to cover the entire box, center at the center of the box -- then the entire region will be non-shifted.
And what can I do about "unitary" ?
Not sure I know what you mean -- you can use any units, but it defaults to the entire box. For instance. pc.set_width(100, "mpc") will set the viewing plane width to 100 proper Mpc (not over h.) -Matt
pf = load("RedshiftOutput0002") pc = PlotCollection(pf) for ax in range(3): p = pc.add_slice("Density", ax) p.modify["grids"]() p.modify["contour"]("Density",ncont=4,take_log=True,clim=(1e-28,1e-30)) p.modify["velocity"](factor=16) p.modify["coord_axes"](unit="Mpc") pc.save("plot2")
shankar
-----Original Message----- From: yt-users-bounces@lists.spacepope.org on behalf of Matthew Turk Sent: Tue 11/24/2009 11:05 AM To: Discussion of the yt analysis package Subject: Re: [yt-users] plotting questions
Hi Shankar,
Also, I am not able to loop over method 1. I am using the stupid way as shown below.
Sure you can loop! :) Here's a way to do it:
for ax in range(3): p = plots.get_slice("RedshiftOutput0002", "Density", ax) p.modify["grids"]() p.modify["contours"]("Density") p.save_image("something_%s" % ax)
That last line will make sure that your images have different names -- and that's actually what's going wrong with the second loop that you had below.
(I'd like to note that having similar plots on different axes is why the Plot Collection is around -- so I'd suggest you stick to that, as it will make changing widths and whatnot easier.)
And method 2 is not showing the grids. for ax in range(3): pc.add_slice("Density", ax).modify["grids"]() pc.add_slice("Density", ax).modify["contour"]("Density") pc.save("plot2")
Ah! What's going on here is that the plot collection, at the end of the loop, has *six* plots:
slice on x with grids slice on x with contours slice on y with grids slice on y with contours slice on z with grids slice on z with contours
BUT, the callbacks aren't taken into account when creating image file names. So it just overwirtes the first slice with the second, the third with the fourth, and the fifth with the sixth. What you probably want to do is:
for ax in range(3): p = pc.add_slice("Density", ax) p.modify["grids"]() p.modify["contour"]("Density") pc.save("plot2")
This way you're modifying the same plot object with both grids and contours.
Best of luck,
Matt _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (2)
-
Agarwal, Shankar
-
Matthew Turk