
Hi guys, one more thing. I want to calculate the radiation pressure force, and when there is some then plot it with a log scale. However if I set: def _ConvertAccel(data): return data.convert("Length") / (data.convert("Time"))**2.0 def _RadiationAccelerationMagnitude(field, data): return ( (data["RadAccel1"])**2.0 + \ (data["RadAccel2"])**2.0 + \ (data["RadAccel3"])**2.0 )**(1.0/2.0) add_field("RadiationAccelerationMagnitude", function=_RadiationAccelerationMagnitude, *take_log=True*,convert_function=_ConvertAccel, units=r"\rm{cm}/\rm{s}^{2}") def _RadiationForceMagnitude(field, data): return ( data["RadiationAccelerationMagnitude"] * data["Density"] * data["CellVolume"]) add_field("RadiationForceMagnitude", function=_RadiationForceMagnitude, * take_log=True*, units=r"\rm{dynes}") before the stars switch on when the radiation acceleration baryon fields are all 0.0 everywhere I get the following error: Traceback (most recent call last): File "MultiPlotProj.py", line 65, in <module> s = pc.add_projection("RadiationForceMagnitude", ax, weight_field="Density", figure=fig, axes=axes[0][3], use_colorbar=False) File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_collection.py", line 742, in add_projection size=fig_size, periodic=periodic)) File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 310, in __init__ self.__init_temp_image(use_colorbar) File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 347, in __init_temp_image self.set_width(1,'unitary') File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 436, in set_width self._refresh_display_width() File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 454, in _refresh_display_width self._redraw_image() File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 384, in _redraw_image newmin = na.nanmin(buff[bI]) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1494, in nanmin return _nanop(np.min, np.inf, a, axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1355, in _nanop res = op(y, axis=axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/core/fromnumeric.py", line 1829, in amin return amin(axis, out) ValueError: zero-size array to ufunc.reduce without identity Is there a way to set it so I get a log scale when plotting projections that does not break when the fields are all zero? Many thanks, Libby -- Elizabeth Harper-Clark MA MSci PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT Sciences and Engineering Coordinator, Teaching Assistants' Training Program, UofT www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark> h-clark@cita.utoronto.ca Astronomy office phone: +1-416-978-5759

Hi Libby, I guess I don't really know what kind of behavior you'd like? If yous et the zlim manually, it should still work; what should it be set to, on a log scale, if everything is zero? -Matt On Mon, Feb 28, 2011 at 11:02 AM, Elizabeth Harper-Clark <h-clark@astro.utoronto.ca> wrote:

Hi Libby, Matt, Britton and I have worked on some 2x2 (and tentative NxN) plotting mechanisms of fixed resolution buffers. Let me try to package it up and post it somewhere. I should be able to do so fairly quickly once I'm done with a few other things this morning. Sam On Mon, Feb 28, 2011 at 10:14 AM, Matthew Turk <matthewturk@gmail.com>wrote:

Hi Matt, I tried removing take_log from the add_field and get the same error. With take_log = False, it runs happily but always gives me a linear colour bar scale. I tried: q = pc.add_projection("RadiationForceMagnitude", ax, weight_field="Density", figure=fig, axes=axes[0][1], use_colorbar=False) q.set_cmap("binary") q.set_log_field(True) q.set_zlim(rp_min, rp_max) but get: Traceback (most recent call last): File "MultiRadPressure.py", line 78, in <module> p._redraw_image() File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 384, in _redraw_image newmin = na.nanmin(buff[bI]) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1494, in nanmin return _nanop(np.min, np.inf, a, axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1355, in _nanop res = op(y, axis=axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/core/fromnumeric.py", line 1829, in amin return amin(axis, out) ValueError: zero-size array to ufunc.reduce without identity whenever the RadAccel fields are all zero. Is there another way? Libby Script: from yt.mods import * # set up our namespace import matplotlib.colorbar as cb import os orient = 'horizontal' frame_template = "aaSN/%s/RPmultiplotproj_%02ipc_%01i_%04i.eps" ss = float(sys.argv[2]) rho_min = 1.e-25 rho_max = 1.e-20 temp_min = 1 temp_max = 10000 HII_min = 1.e-5 HII_max = 1.0 rp_min = 1e24 rp_max = 5e27 name = sys.argv[1] firststar = 0 def _ConvertAccel(data): return data.convert("Length") / (data.convert("Time"))**2.0 def _RadiationAccelerationMagnitude(field, data): return ( (data["RadAccel1"])**2.0 + \ (data["RadAccel2"])**2.0 + \ (data["RadAccel3"])**2.0 )**(1.0/2.0) add_field("RadiationAccelerationMagnitude", function=_RadiationAccelerationMagnitude, take_log=False,convert_function=_ConvertAccel, units=r"\rm{cm}/\rm{s}^{2}") def _RadiationForceMagnitude(field, data): return ( data["RadiationAccelerationMagnitude"] * data["Density"] * data["CellVolume"]) add_field("RadiationForceMagnitude", function=_RadiationForceMagnitude, take_log=False, units=r"\rm{dynes}") for n in range(212,400,1): pf = load("SciNet/%s/DD%04i/data%04i" % (name,n, n)) # load data #pf = load("WOCOUT/%s/DD%04i/data%04i" % (sys.argv[-1],n, n)) # load data if pf is None: continue if na.any(pf.h.grid_particle_count): v1, c1 = pf.h.find_max("RadAccel1") v2, c2 = pf.h.find_max("RadAccel2") v3, c3 = pf.h.find_max("RadAccel3") v4, c4 = pf.h.find_max("RadiationForceMagnitude") for ax in range (0,1): ## if os.path.exists(frame_template % (name,ss,ax,n)) is True: ## print "file exists" ## continue xc = 0.5 yc = 0.5 zc = 0.5 print "Dump:", n, "axis:", ax fig, axes, colorbars = get_multi_plot( 2, 1, colorbar=orient, bw = 6) pc = PlotCollection(pf, center=(xc, yc, zc)) p = pc.add_projection("Density", ax, weight_field="Density", figure = fig, axes = axes[0][0], use_colorbar=False) p.set_cmap("bds_highcontrast") p.set_zlim(rho_min, rho_max) #p.modify["velocity"]() # only for close in ones q = pc.add_projection("RadiationForceMagnitude", ax, weight_field="Density", figure=fig, axes=axes[0][1], use_colorbar=False) q.set_log_field(True) q.set_zlim(rp_min, rp_max) q.set_cmap("binary") sp = pf.h.all_data() if na.any(pf.h.grid_particle_count): p.modify["particles"](2.0, p_size=1.0, col='k', minimum_mass= 6.e0) q.modify["particles"](2.0, p_size=1.0, col='k', minimum_mass= 6.e0) print " XXXXX Particles present XXXXX" Timemyr = pf["InitialTime"]*pf["years"]/1.e6 - firststar*.1 TotalRP = sp["RadiationForceMagnitude"].sum() p.modify["text"]((0.051,0.949),"Time = %5.1f Myr" % (Timemyr), text_args = {'color':'k'}) p.modify["text"]((0.05,0.95),"Time = %5.1f Myr" % (Timemyr), text_args = {'color':'w'}) q.modify["text"]((0.051,0.949),"Total RP =%.4g " % (TotalRP),text_args = {'color':'k'}) q.modify["text"]((0.05,0.95),"Total RP =%.4g " % (TotalRP),text_args = {'color':'w'}) for p, cax in zip(pc.plots, colorbars): p._redraw_image() cbar = cb.Colorbar(cax, p.image, orientation=orient) p.colorbar = cbar p._autoset_label() fig.savefig(frame_template % (name,ss,ax,n), format="eps")

Hi Libby, I guess I don't really know what kind of behavior you'd like? If yous et the zlim manually, it should still work; what should it be set to, on a log scale, if everything is zero? -Matt On Mon, Feb 28, 2011 at 11:02 AM, Elizabeth Harper-Clark <h-clark@astro.utoronto.ca> wrote:

Hi Libby, Matt, Britton and I have worked on some 2x2 (and tentative NxN) plotting mechanisms of fixed resolution buffers. Let me try to package it up and post it somewhere. I should be able to do so fairly quickly once I'm done with a few other things this morning. Sam On Mon, Feb 28, 2011 at 10:14 AM, Matthew Turk <matthewturk@gmail.com>wrote:

Hi Matt, I tried removing take_log from the add_field and get the same error. With take_log = False, it runs happily but always gives me a linear colour bar scale. I tried: q = pc.add_projection("RadiationForceMagnitude", ax, weight_field="Density", figure=fig, axes=axes[0][1], use_colorbar=False) q.set_cmap("binary") q.set_log_field(True) q.set_zlim(rp_min, rp_max) but get: Traceback (most recent call last): File "MultiRadPressure.py", line 78, in <module> p._redraw_image() File "/home/h-clark/YT/src/yt-hg/yt/visualization/plot_types.py", line 384, in _redraw_image newmin = na.nanmin(buff[bI]) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1494, in nanmin return _nanop(np.min, np.inf, a, axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/lib/function_base.py", line 1355, in _nanop res = op(y, axis=axis) File "/home/h-clark/YT/lib/python2.6/site-packages/numpy/core/fromnumeric.py", line 1829, in amin return amin(axis, out) ValueError: zero-size array to ufunc.reduce without identity whenever the RadAccel fields are all zero. Is there another way? Libby Script: from yt.mods import * # set up our namespace import matplotlib.colorbar as cb import os orient = 'horizontal' frame_template = "aaSN/%s/RPmultiplotproj_%02ipc_%01i_%04i.eps" ss = float(sys.argv[2]) rho_min = 1.e-25 rho_max = 1.e-20 temp_min = 1 temp_max = 10000 HII_min = 1.e-5 HII_max = 1.0 rp_min = 1e24 rp_max = 5e27 name = sys.argv[1] firststar = 0 def _ConvertAccel(data): return data.convert("Length") / (data.convert("Time"))**2.0 def _RadiationAccelerationMagnitude(field, data): return ( (data["RadAccel1"])**2.0 + \ (data["RadAccel2"])**2.0 + \ (data["RadAccel3"])**2.0 )**(1.0/2.0) add_field("RadiationAccelerationMagnitude", function=_RadiationAccelerationMagnitude, take_log=False,convert_function=_ConvertAccel, units=r"\rm{cm}/\rm{s}^{2}") def _RadiationForceMagnitude(field, data): return ( data["RadiationAccelerationMagnitude"] * data["Density"] * data["CellVolume"]) add_field("RadiationForceMagnitude", function=_RadiationForceMagnitude, take_log=False, units=r"\rm{dynes}") for n in range(212,400,1): pf = load("SciNet/%s/DD%04i/data%04i" % (name,n, n)) # load data #pf = load("WOCOUT/%s/DD%04i/data%04i" % (sys.argv[-1],n, n)) # load data if pf is None: continue if na.any(pf.h.grid_particle_count): v1, c1 = pf.h.find_max("RadAccel1") v2, c2 = pf.h.find_max("RadAccel2") v3, c3 = pf.h.find_max("RadAccel3") v4, c4 = pf.h.find_max("RadiationForceMagnitude") for ax in range (0,1): ## if os.path.exists(frame_template % (name,ss,ax,n)) is True: ## print "file exists" ## continue xc = 0.5 yc = 0.5 zc = 0.5 print "Dump:", n, "axis:", ax fig, axes, colorbars = get_multi_plot( 2, 1, colorbar=orient, bw = 6) pc = PlotCollection(pf, center=(xc, yc, zc)) p = pc.add_projection("Density", ax, weight_field="Density", figure = fig, axes = axes[0][0], use_colorbar=False) p.set_cmap("bds_highcontrast") p.set_zlim(rho_min, rho_max) #p.modify["velocity"]() # only for close in ones q = pc.add_projection("RadiationForceMagnitude", ax, weight_field="Density", figure=fig, axes=axes[0][1], use_colorbar=False) q.set_log_field(True) q.set_zlim(rp_min, rp_max) q.set_cmap("binary") sp = pf.h.all_data() if na.any(pf.h.grid_particle_count): p.modify["particles"](2.0, p_size=1.0, col='k', minimum_mass= 6.e0) q.modify["particles"](2.0, p_size=1.0, col='k', minimum_mass= 6.e0) print " XXXXX Particles present XXXXX" Timemyr = pf["InitialTime"]*pf["years"]/1.e6 - firststar*.1 TotalRP = sp["RadiationForceMagnitude"].sum() p.modify["text"]((0.051,0.949),"Time = %5.1f Myr" % (Timemyr), text_args = {'color':'k'}) p.modify["text"]((0.05,0.95),"Time = %5.1f Myr" % (Timemyr), text_args = {'color':'w'}) q.modify["text"]((0.051,0.949),"Total RP =%.4g " % (TotalRP),text_args = {'color':'k'}) q.modify["text"]((0.05,0.95),"Total RP =%.4g " % (TotalRP),text_args = {'color':'w'}) for p, cax in zip(pc.plots, colorbars): p._redraw_image() cbar = cb.Colorbar(cax, p.image, orientation=orient) p.colorbar = cbar p._autoset_label() fig.savefig(frame_template % (name,ss,ax,n), format="eps")
participants (4)
-
Elizabeth Harper-Clark
-
Elizabeth Harper-Clark
-
Matthew Turk
-
Sam Skillman