Hello All,
I have a question about the Projection plot function in yt. I have a script that plots the smallest mass darkmatter particles of a simulation in all 3 of the 2-d coordinate projections, and overplots the halos found by a halo finder. This script works, and currently plots the colorbar based on the mass in a given 2-d bin as done in some of the basic yt plots included in the website. I am wondering if it is possible to have the color scheme of the particles be based on the squared mass or squared density of the particles in any given 2-d bin, so that the higher density regions are highlighted compared to the background lower density regions. I have included the plotting part of my script below, in case it is helpful.
I hope everyone is having a great New Year!
ds = yt.load(VELA_snaps[position[0]])
domain_width = float(ds.domain_width.in_units('Mpc/h')[0])
ad = ds.all_data()
masses = yt.np.unique(ad[('darkmatter', 'particle_mass')])
#filter out the darkmatter0 particles
def mass_filter(pfilter, data):
filter = data[(pfilter.filtered_type, 'particle_mass')] == masses[0]
return filter
yt.add_particle_filter('darkmatter0', function=mass_filter, filtered_type='darkmatter', requires=['particle_mass'])
ds.add_particle_filter('darkmatter0')
scale = float(ds.scale_factor)
fig = plt.figure()
grid = AxesGrid(fig, (0.075,0.075,10,5),
nrows_ncols = (3, 1),
axes_pad = 1.0,
label_mode = "L",
share_all = False,
cbar_location="right",
cbar_mode="each",
cbar_size="3%",
cbar_pad="0%")
zoom = 10
x0 = float(consistent.halo_data_sorted[index][0][17]) * scale / domain_width
y0 = float(consistent.halo_data_sorted[index][0][18]) * scale / domain_width
z0 = float(consistent.halo_data_sorted[index][0][19]) * scale / domain_width
center = [x0, y0, z0]
a = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_x'), ('darkmatter0', 'particle_position_y'),\
('darkmatter0', 'particle_mass'), center=center)
a.set_unit(('darkmatter0','particle_mass'), 'Msun')
a.zoom(zoom)
b = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_y'), ('darkmatter0', 'particle_position_z'),\
('darkmatter0', 'particle_mass'), center=center)
b.set_unit(('darkmatter0','particle_mass'), 'Msun')
b.zoom(zoom)
c = yt.ParticlePlot(ds, ('darkmatter0', 'particle_position_z'), ('darkmatter0', 'particle_position_x'),\
('darkmatter0', 'particle_mass'), center=center)
c.set_unit(('darkmatter0','particle_mass'), 'Msun')
c.zoom(zoom)
for halos in consistent.halo_data_sorted[index]:
x = float(halos[17]) * scale / domain_width
y = float(halos[18]) * scale / domain_width
z = float(halos[19]) * scale / domain_width
r = float(halos[11]) * scale / .7
center = [x, y, z]
a.annotate_sphere(center, radius=(r, 'kpc'), circle_args={'color':'red'})
b.annotate_sphere(center, radius=(r, 'kpc'), circle_args={'color':'red'})
c.annotate_sphere(center, radius=(r, 'kpc'), circle_args={'color':'red'})
index = 0
for letter in [a,b,c]:
plot = letter.plots[('darkmatter0', 'particle_mass')]
plot.figure = fig
plot.axes = grid[index].axes
plot.cax = grid.cbar_axes[index]
letter._setup_plots()
index = index + 1
plt.savefig('{}/CatalogProjectionYT_VELA{}_Scale{}.png'.format(out_dir, VELA_number, str(scale)[2:5]), bbox_inches='tight')
plt.close()