Hi, I have a question on ProfilePlot. I want to make profile plot of dark
matter density, taking gas density as a bin field, weighted by dark matter
mass in the cell.I could make the plot, but the plot looks strange (it
looks like chopped in small pieces). Also, I tried other plot changing
n_bins like 64,32,16,8,... but they still be "chopped", or sometimes there
were no line at all. For comparison, I made a plot weighted by cell_mass
(which I don't want), and this look OK. To my understanding, if and only if
there is at least 1 cell which fall into each bin, there should be some
nonzero value no matter what weight I use, so the range of density which
has nonzero dark matter density doesn't depend on the choice of weight
field. It seems there is a discrepancy between these two plots.
Could you tell me what's wrong with me?
I tried on yt example dataset, IsolatedGalaxy/galaxy0030/galaxy0030.
I'm working with yt-3.4.0.
this is my code:
from yt.data_objects.particle_filters import add_particle_filter
def stars(pfilter, data):
filter = data[(pfilter.filtered_type, "particle_type")] == 2
def DMparticles(pfilter, data):
filter = data[(pfilter.filtered_type, "particle_type")] == 1
add_particle_filter("stars", function=stars, filtered_type='io',
add_particle_filter("DMparticles", function=DMparticles, filtered_type='io',
def only_DM(field, data):
def DM_in_cell_mass(field, data):
ds_all.add_field(("gas", "only_DM_Density"), units="g/cm**3",
ds_all.add_field(("gas", "DM_cell_mass"), units="g",
sp = ds_all.sphere([0.5, 0.5, 0.5], (10, "kpc"))
lineplot_gas_DM_density_128 = yt.ProfilePlot(sp, "density", [
"only_DM_Density"], weight_field="DM_cell_mass", n_bins=128)
lineplot_gas_DM_density_gasweighted_128 = yt.ProfilePlot(sp, "density", [
"only_DM_Density"], weight_field="cell_mass", n_bins=128)