<div dir="ltr">Dear Nathan,<div><br></div><div>Thank you for your quick modification, and the detailed instruction! I will try reinstallation.</div><div><br></div><div>Thanks,</div><div>Y.T.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-10-18 17:43 GMT-04:00 Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>This is a bug. Thank you for the excellent report that allowed me to reproduce exactly what you're seeing and figure out what's going wrong. <br></div><div><br></div><div>The issue was that you were passing a weight field that had zeros in the first entry. This triggered a corner case in the low-level C code that calculates the ND histogram the profile object uses under the hood, introducing NaNs into the calculation. The NaNs caused the holes you saw in the final plot. The fix is to catch the case when the weight field is zero and ignore those field values.</div><div><br></div><div>I've issued a pull request with a fix for your issue:</div><div><br></div><div><a href="https://github.com/yt-project/yt/pull/1590" target="_blank">https://github.com/yt-project/<wbr>yt/pull/1590</a><br></div><div><br></div><div>To get the fix, you are going to need to build yt from source and then check out my pull request locally. Here are some instructions on how to do that:</div><div><br></div><div>1. Uninstall your current yt installation. If you use conda, use "conda uninstall yt". If you use pip, use "pip uninstall yt".</div><div>2. Navigate to a place on your hard disk where you put software and clone the yt git repository: "git clone <a href="https://github.com/yt-project/yt" target="_blank">https://github.com/yt-project/<wbr>yt</a>"</div><div>3. Go into the yt repo, "cd yt"</div><div>4. Fetch my pull request and then check it out: "git fetch origin pull/1590/head:profile-zero-<wbr>weight", "git checkout profile-zero-weight".</div><div>5. Build yt from source, "pip install -e ."</div><div><br></div><div>You may need to install cython before building yt if you don't already have it installed.</div><div><br></div><div>Hope that helps and thanks again for the detailed report!</div><div><br></div><div>-Nathan<br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Oct 18, 2017 at 1:59 PM, tyuta <span dir="ltr"><<a href="mailto:y0u1t1a5.t@gmail.com" target="_blank">y0u1t1a5.t@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Dear yt-users,<div><br></div><div>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.</div><div><br></div><div>Could you tell me what's wrong with me?</div><div>I tried on yt example dataset, <span style="color:rgb(197,156,156);font-family:Menlo;font-size:11px">IsolatedGalaxy/galaxy<wbr>0030/galaxy0030</span>.</div><div>I'm working with yt-3.4.0.</div><div><br></div><div>this is my code:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(208,59,255)"><span style="font-variant-ligatures:no-common-ligatures">import</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> yt</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">from</span><span style="font-variant-ligatures:no-common-ligatures"> yt.data_objects.particle_filte<wbr>rs </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">import</span><span style="font-variant-ligatures:no-common-ligatures"> add_particle_filter</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">def</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(94,52,255)">stars</span><span style="font-variant-ligatures:no-common-ligatures">(pfilter, data):</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(239,118,238)">filter</span><span style="font-variant-ligatures:no-common-ligatures"> = data[(pfilter.filtered_type, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"particle_type"</span><span style="font-variant-ligatures:no-common-ligatures">)] == 2</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(208,59,255)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures">return</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(239,118,238)">filter</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">def</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(94,52,255)">DMparticles</span><span style="font-variant-ligatures:no-common-ligatures">(pfilter, data):</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(239,118,238)">filter</span><span style="font-variant-ligatures:no-common-ligatures"> = data[(pfilter.filtered_type, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"particle_type"</span><span style="font-variant-ligatures:no-common-ligatures">)] == 1</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(208,59,255)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures">return</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(239,118,238)">filter</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">add_particle_filter(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"stars"</span><span style="font-variant-ligatures:no-common-ligatures">, function=stars, filtered_type=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">'io'</span><span style="font-variant-ligatures:no-common-ligatures">,</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">                  requires=[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"particle_type"</span><span style="font-variant-ligatures:no-common-ligatures">])</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">add_particle_filter(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"DMparticl<wbr>es"</span><span style="font-variant-ligatures:no-common-ligatures">, function=DMparticles, filtered_type=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">'io'</span><span style="font-variant-ligatures:no-common-ligatures">,</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">                   requires=[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"particle_type"</span><span style="font-variant-ligatures:no-common-ligatures">])</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">def</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(94,52,255)">only_DM</span><span style="font-variant-ligatures:no-common-ligatures">(field, data):</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(197,156,156)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">return</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> data[</span><span style="font-variant-ligatures:no-common-ligatures">'deposit'</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">,</span><span style="font-variant-ligatures:no-common-ligatures">'DMparticles_de<wbr>nsity'</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">]</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">def</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(94,52,255)">DM_in_cell_mass</span><span style="font-variant-ligatures:no-common-ligatures">(field, data):</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(197,156,156)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">return</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> (data[</span><span style="font-variant-ligatures:no-common-ligatures">'only_DM_Density'</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">]*data[</span><span style="font-variant-ligatures:no-common-ligatures"><wbr>'cell_volume'</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">])</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(197,156,156)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(199,156,36)">ds_all</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">=yt.load(</span><span style="font-variant-ligatures:no-common-ligatures">"~/IsolatedGala<wbr>xy/galaxy0030/galaxy0030"</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">ds_all.add_particle_filter(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">'st<wbr>ars'</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">ds_all.add_particle_filter(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">'DM<wbr>particles'</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">ds_all.add_field((</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"gas"</span><span style="font-variant-ligatures:no-common-ligatures">, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"only_DM_Density"</span><span style="font-variant-ligatures:no-common-ligatures">), units=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"g/cm**3"</span><span style="font-variant-ligatures:no-common-ligatures">, function=only_DM)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">ds_all.add_field((</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"gas"</span><span style="font-variant-ligatures:no-common-ligatures">, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"DM_cell_mass"</span><span style="font-variant-ligatures:no-common-ligatures">), units=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"g"</span><span style="font-variant-ligatures:no-common-ligatures">, function=DM_in_cell_mass)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(199,156,36)">sp</span><span style="font-variant-ligatures:no-common-ligatures"> = ds_all.sphere([0.5, 0.5, 0.5], (10, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"kpc"</span><span style="font-variant-ligatures:no-common-ligatures">))</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(199,156,36)">lineplot_gas_DM_density_128</span><span style="font-variant-ligatures:no-common-ligatures"> = yt.ProfilePlot(sp, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"density"</span><span style="font-variant-ligatures:no-common-ligatures">, [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"only_DM_Density"</span><span style="font-variant-ligatures:no-common-ligatures">], weight_field=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"DM_cell_mass"</span><span style="font-variant-ligatures:no-common-ligatures">, n_bins=128)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(199,156,36)">lineplot_gas_DM_density_gaswei<wbr>ghted_128</span><span style="font-variant-ligatures:no-common-ligatures"> = yt.ProfilePlot(sp, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"density"</span><span style="font-variant-ligatures:no-common-ligatures">, [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"only_DM_Density"</span><span style="font-variant-ligatures:no-common-ligatures">], weight_field=</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"cell_mass"</span><span style="font-variant-ligatures:no-common-ligatures">, n_bins=128)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">lineplot_gas_DM_density_gaswei<wbr>ghted_128.save(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"128_gasweighte<wbr>d"</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">lineplot_gas_DM_density_128.sa<wbr>ve(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(197,156,156)">"128_DMweighted"</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p></div><div><br></div><div>Sincerely,</div><div>Y.T.</div></div>
<br></div></div>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-users-<wbr>spacepope.org</a><br>
<br></blockquote></div><br></div>