Annotating BH particles on SlicePlots
Hi all, I'm trying to annotate BH particles on top of a regular yt SlicePlot. I'm loading from an Enzo dataset and using yt version 3.3.1, the plot field and width in parsecs are given as command line arguments (I tried using density and 3.0). Here is the script I'm working with: import yt import sys from yt.units import pc, Msun, Myr import numpy as np yt.enable_parallelism() #get command line inputs, syntax is [field] [size] field = sys.argv[1] try : size = float(sys.argv[2]) except (TypeError, IndexError): print("Error, argument syntax is 'plot.py [field] [size]'") quit(0) ds = yt.load("DD0121/output_0121") time = '{:.3f}'.format(round(ds.current_time.in_units('Myr') - 194.608*Myr, 4)) val, loc = ds.find_max('density') plt = yt.SlicePlot(ds, 'z', field, center= loc, width= (size, 'pc')) plt.set_zlim(field, 1e-21, 1e-12) plt.annotate_particles(ds, size*pc, ptype= 8) #produces 1st error #plt.annotate_particles(ds, size*pc, p_size= 2.0, col= 'k', marker= 'o', stride= 1, ptype= 8, minimum_mass= None, alpha= 1.0) #produces 2nd error plt.annotate_text((0.05, 0.05), 't=' + time + 'Myr', coord_system= 'axis') plt.save("test.png") The script seems to run ok until attempting to save the plot, when I get the following error: Traceback (most recent call last): File "plot_yt.py", line 35, in <module> plt.save("test.png") File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_container.py", line 78, in newfunc args[0]._setup_plots() File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 949, in _setup_plots self.run_callbacks() File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 1005, in run_callbacks sys.exc_info()[2]) File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 999, in run_callbacks callback(cbw) File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 53, in _check_geometry return func(self, plot) File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 1575, in __call__ reg = self._get_region((x0,x1), (y0,y1), plot.data.axis, data) File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_modifications.py", line 1639, in _get_region LE[zax] = data.center[zax].ndarray_view() - self.width*0.5 yt.utilities.exceptions.YTPlotCallbackError: annotate_particles callback failed with the following error: unsupported operand type(s) for *: 'EnzoDataset' and 'float' I've tried adding all the keyword arguments and their parameters to the annotate_particles call (switching the commented line on my script), but this produces: Traceback (most recent call last): File "plot_yt.py", line 35, in <module> plt.save("test.png") File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_container.py", line 78, in newfunc args[0]._setup_plots() File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 949, in _setup_plots self.run_callbacks() File "/opt/apps/yt/3.3.1/yt-conda/lib/python2.7/site-packages/yt/visualization/plot_window.py", line 997, in run_callbacks callback = CallbackMaker(*args[1:], **kwargs) TypeError: __init__() got multiple values for keyword argument 'p_size' Any help on getting this to work would be vastly appreciated. I was also wondering whether it was possible to use the annotate_particles callback on OffAxisSlicePlots and OffAxisProjectionPlots, I've tried both and neither seems to support this functionality. Many thanks, Sam Patrick
participants (2)
-
Nathan Goldbaum
-
Sam Patrick