Hi, I am using the code yt.lagrangian_volume to trace the box that contains the dark matter particles at an early stage(higher redshift). But I was quite confused about the output. I am attaching the output file below. (1) I don't know what the values for the box in the new frame mean, i.e. what is the unit of these values? It seems to be the normalized scale because the values are about 1. But it does not seem to be normalized too because there are some values that are larger than 1. Is that due to the periodicity of the box? (2) The bounding box and box in the new frame seems to have the same size. The difference between the two box is just translation. But I was expecting that the box should be expanding/collapsing. (3) The COM (center of mass) in the output is within neither of the box. Does anyone know how to explain the box values in the output file? Thanks, Jingjing -- Jingjing Chen [ chenjj235@gmail.com ] Department of Astronomy Columbia University 550 West 120th Street New York, New York 10027 Cell Phone: +1(347)5746709
Hello all, I’m trying to generate some plot titles on my phase diagrams (RAMSES data)… But neither of the approaches works: # fractional=True keyword -- divide the profile data by the sum. ds = yt.load("/Users/earnric/RAMSES-Data/cooling/output_00012/info_00012.txt") ad = ds.all_data() plot = yt.PhasePlot(ad, "density", "temperature", "cell_mass", weight_field=None, fractional=True ) zStr = "Gas phase z = %.1f" % ds.current_redshift plot.set_zlim('cell_mass', 1e-9, 1e-1) plot.set_title("cell_mass", zStr) ## Approach 1 plot.plot_title=zStr ## Approach 2 plot.show() I can’t figure out (from the documentation) which is supposed to work! Both are listed here: http://yt-project.org/docs/3.0/reference/api/generated/yt.visualization.prof... http://yt-project.org/docs/3.0/reference/api/generated/yt.visualization.prof... Thx for the help... Cheers! Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu
Hi Rick, This looks like a bug to me, but I'm not 100% sure as I've never really used set_title in the past. As a workaround you may want to either: (i) use annotate_text calls, or (ii) work with the pyplot API directly, e.g. ax = plot['cell_mass'].axes will return the axes object which you can manipulate with standard matplotlib functions. You can even build the axes objects before making the PhasePlot if you want complete control. Both methods are demonstrated here: nbviewer.ipython.org/github/astrosmith/Notebooks/blob/master/set_title.ipynb Cheers, Aaron On 10/28/14, 4:39 PM, Rick Sarmento wrote:
Hello all,
I'm trying to generate some plot titles on my phase diagrams (RAMSES data)... But neither of the approaches works:
# fractional=True keyword -- divide the profile data by the sum. ds = yt.load("/Users/earnric/RAMSES-Data/cooling/output_00012/info_00012.txt") ad = ds.all_data() plot = yt.PhasePlot(ad, "density", "temperature", "cell_mass", weight_field=None, fractional=True ) zStr = "Gas phase z = %.1f" % ds.current_redshift plot.set_zlim('cell_mass', 1e-9, 1e-1) plot.set_title("cell_mass", zStr) ## Approach 1 plot.plot_title=zStr ## Approach 2 plot.show()
I can't figure out (from the documentation) which is supposed to work! Both are listed here:
http://yt-project.org/docs/3.0/reference/api/generated/yt.visualization.prof...
Thx for the help...
/Cheers!/ / / /Rick Sarmento/ SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu mailto:rsarment@asu.edu
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Aaron, thanks very much. Yea, using the axes “set_title” worked nicely. Thx for including the example! I’m new to python and matplotlib. Cheers! Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu
On Oct 28, 2014, at 4:53 PM, Aaron Smith
wrote: Hi Rick,
This looks like a bug to me, but I'm not 100% sure as I've never really used set_title in the past. As a workaround you may want to either: (i) use annotate_text calls, or (ii) work with the pyplot API directly, e.g. ax = plot['cell_mass'].axes will return the axes object which you can manipulate with standard matplotlib functions. You can even build the axes objects before making the PhasePlot if you want complete control.
Both methods are demonstrated here: nbviewer.ipython.org/github/astrosmith/Notebooks/blob/master/set_title.ipynb
Cheers, Aaron
On 10/28/14, 4:39 PM, Rick Sarmento wrote:
Hello all,
I’m trying to generate some plot titles on my phase diagrams (RAMSES data)… But neither of the approaches works:
# fractional=True keyword -- divide the profile data by the sum. ds = yt.load("/Users/earnric/RAMSES-Data/cooling/output_00012/info_00012.txt") ad = ds.all_data() plot = yt.PhasePlot(ad, "density", "temperature", "cell_mass", weight_field=None, fractional=True ) zStr = "Gas phase z = %.1f" % ds.current_redshift plot.set_zlim('cell_mass', 1e-9, 1e-1) plot.set_title("cell_mass", zStr) ## Approach 1 plot.plot_title=zStr ## Approach 2 plot.show()
I can’t figure out (from the documentation) which is supposed to work! Both are listed here:
http://yt-project.org/docs/3.0/reference/api/generated/yt.visualization.prof... http://yt-project.org/docs/3.0/reference/api/generated/yt.visualization.prof...
Thx for the help...
Cheers!
Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu mailto:rsarment@asu.edu
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org mailto:yt-users@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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
While I’m on the subject of plot title … I’m trying to put two plots in a grid, side-by-side… using different RAMSES data files. I need to have titles/annotations on these to distinguish which one has H2 cooling turned on and which has it off… I’ve tried several API calls… with the results below… Anyone know how to do this? Also, what if I wanted a 2x2 grid of plots? fns = ["/Users/earnric/RAMSES-Data/cooling/output_00008/info_00008.txt", "/Users/earnric/RAMSES-Data/noCool/output_00008/info_00008.txt"] fields = ["density","temperature"] fig = plt.figure() grid = AxesGrid(fig, (0.075,0.075,0.85,0.85), nrows_ncols = (1, 2), axes_pad = 0.05, label_mode = "L", share_all = True, cbar_location="right", cbar_mode="single", cbar_size="3%", cbar_pad="0%") fig.suptitle("Gas Temperature") for i, fn in enumerate(fns): # Load the data and create a single plot ds = yt.load(fn) # load data p = yt.ProjectionPlot(ds, 'z', 'temperature', weight_field="density") # Ensure the colorbar limits match for all plots p.set_zlim('temperature', 0.1, 1e4) # This forces the ProjectionPlot to redraw itself on the AxesGrid axes. plot = p.plots['temperature'] if i % 2 == 0: ptype = "Cooling " else: ptype = "No cooling " zStr = ptype + "z = %.1f" % ds.current_redshift #p.annotate_title(zStr) # Doesn't work... bug plot.figure = fig plot.axes = grid[i].axes ##plot['temperature'].axes.set_title(zStr, fontsize=14) # Error ##plot.axes.set_title(zStr, fontsize=14) # NOTHING, but doesn't error ##plot.annotate_text(-7.0,10.0, zStr, **{'fontsize':20}) # Error plot.cax = grid.cbar_axes[i] plot.axes.set_title(zStr) # Finally, this actually redraws the plot. p._setup_plots() p.show() Thx again. Cheers! Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu
Ah! Disregard… I found it after 45 min! fns = ["/Users/earnric/RAMSES-Data/cooling/output_00008/info_00008.txt", "/Users/earnric/RAMSES-Data/noCool/output_00008/info_00008.txt"] fields = ["density","temperature"] fig = plt.figure() grid = AxesGrid(fig, (0.075,0.075,0.85,0.85), nrows_ncols = (1, 2), axes_pad = 0.05, label_mode = "L", share_all = True, cbar_location="right", cbar_mode="single", cbar_size="3%", cbar_pad="0%") fig.suptitle("Gas Temperature") for i, fn in enumerate(fns): # Load the data and create a single plot ds = yt.load(fn) # load data p = yt.ProjectionPlot(ds, 'z', 'temperature', weight_field="density") # Ensure the colorbar limits match for all plots p.set_zlim('temperature', 0.1, 1e4) # This forces the ProjectionPlot to redraw itself on the AxesGrid axes. plot = p.plots['temperature'] if i % 2 == 0: ptype = "Cooling " else: ptype = "No cooling " zStr = ptype + "z = %.1f" % ds.current_redshift #p.annotate_title(zStr) # Doesn't work... bug plot.figure = fig plot.axes = grid[i].axes ##plot['temperature'].axes.set_title(zStr, fontsize=14) # Error ##plot.axes.set_title(zStr, fontsize=14) # NOTHING, but doesn't error ##plot.annotate_text(-7.0,10.0, zStr, **{'fontsize':20}) # Error p.annotate_title(zStr) plot.cax = grid.cbar_axes[i] plot.axes.set_title(zStr) # Finally, this actually redraws the plot. p._setup_plots() p.show() Cheers! Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu On October 28, 2014 at 9:09:25 PM, Rick Sarmento (rsarment@asu.edu) wrote: While I’m on the subject of plot title … I’m trying to put two plots in a grid, side-by-side… using different RAMSES data files. I need to have titles/annotations on these to distinguish which one has H2 cooling turned on and which has it off… I’ve tried several API calls… with the results below… Anyone know how to do this? Also, what if I wanted a 2x2 grid of plots? fns = ["/Users/earnric/RAMSES-Data/cooling/output_00008/info_00008.txt", "/Users/earnric/RAMSES-Data/noCool/output_00008/info_00008.txt"] fields = ["density","temperature"] fig = plt.figure() grid = AxesGrid(fig, (0.075,0.075,0.85,0.85), nrows_ncols = (1, 2), axes_pad = 0.05, label_mode = "L", share_all = True, cbar_location="right", cbar_mode="single", cbar_size="3%", cbar_pad="0%") fig.suptitle("Gas Temperature") for i, fn in enumerate(fns): # Load the data and create a single plot ds = yt.load(fn) # load data p = yt.ProjectionPlot(ds, 'z', 'temperature', weight_field="density") # Ensure the colorbar limits match for all plots p.set_zlim('temperature', 0.1, 1e4) # This forces the ProjectionPlot to redraw itself on the AxesGrid axes. plot = p.plots['temperature'] if i % 2 == 0: ptype = "Cooling " else: ptype = "No cooling " zStr = ptype + "z = %.1f" % ds.current_redshift #p.annotate_title(zStr) # Doesn't work... bug plot.figure = fig plot.axes = grid[i].axes ##plot['temperature'].axes.set_title(zStr, fontsize=14) # Error ##plot.axes.set_title(zStr, fontsize=14) # NOTHING, but doesn't error ##plot.annotate_text(-7.0,10.0, zStr, **{'fontsize':20}) # Error plot.cax = grid.cbar_axes[i] plot.axes.set_title(zStr) # Finally, this actually redraws the plot. p._setup_plots() p.show() Thx again. Cheers! Rick Sarmento SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu
There are several examples starting here in the cookbook:
http://yt-project.org/doc/cookbook/complex_plots.html#multipanel-with-axes-l...
On Tue, Oct 28, 2014 at 9:09 PM, Rick Sarmento
While I’m on the subject of plot title … I’m trying to put two plots in a grid, side-by-side… using different RAMSES data files. I need to have titles/annotations on these to distinguish which one has H2 cooling turned on and which has it off… I’ve tried several API calls… with the results below…
Anyone know how to do this? Also, what if I wanted a 2x2 grid of plots?
*fns = ["/Users/earnric/RAMSES-Data/cooling/output_00008/info_00008.txt",* * "/Users/earnric/RAMSES-Data/noCool/output_00008/info_00008.txt"]*
*fields = ["density","temperature"]*
*fig = plt.figure()* *grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),* * nrows_ncols = (1, 2),* * axes_pad = 0.05,* * label_mode = "L",* * share_all = True,* * cbar_location="right",* * cbar_mode="single",* * cbar_size="3%",* * cbar_pad="0%")* *fig.suptitle("Gas Temperature")*
*for i, fn in enumerate(fns):* * # Load the data and create a single plot* * ds = yt.load(fn) # load data* * p = yt.ProjectionPlot(ds, 'z', 'temperature', weight_field="density")*
* # Ensure the colorbar limits match for all plots* * p.set_zlim('temperature', 0.1, 1e4)*
* # This forces the ProjectionPlot to redraw itself on the AxesGrid axes.* * plot = p.plots['temperature']* * if i % 2 == 0:* * ptype = "Cooling "* * else:* * ptype = "No cooling "* * zStr = ptype + "z = %.1f" % ds.current_redshift * * #p.annotate_title(zStr) # Doesn't work... bug* * plot.figure = fig* * plot.axes = grid[i].axes* * ##plot['temperature'].axes.set_title(zStr, fontsize=14) # Error* * ##plot.axes.set_title(zStr, fontsize=14) # NOTHING, but doesn't error* * ##plot.annotate_text(-7.0,10.0, zStr, **{'fontsize':20}) # Error* * plot.cax = grid.cbar_axes[i]* * plot.axes.set_title(zStr)*
* # Finally, this actually redraws the plot.* * p._setup_plots()* *p.show()*
Thx again.
*Cheers!*
*Rick Sarmento* SESE Astronomy/Astrophysics Grad Student rsarment@asu.edu
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (4)
-
Aaron Smith
-
Chen Jingjing
-
Nathan Goldbaum
-
Rick Sarmento