<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 10:41 AM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Aug 12, 2016 at 3:33 AM, Thor Andreas Seiff Ellewsen <span dir="ltr"><<a href="mailto:tellewsen@gmail.com" target="_blank">tellewsen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everyone.<div><br></div><div>I'm fairly new to yt and I'm having some problems.</div><div>I'm trying to plot radial density profiles for some halos in a RAMSES simulation with periodic boundary conditions.</div><div>The problem arises when dealing with a halo close to the edge.</div><div><br></div><div>The relevant part of the code looks like this:</div><div><div>ds = yt.load(datapath)</div><div>cen = halos[0] # numpy array [x,y,z] in code units</div><div>rad = haloradius[0] # float in code units</div><div>sph = ds.sphere(cen, (10.*rad, 'Mpc/h')) </div><div>plot = yt.ProfilePlot(sph, "radius", 'particle_mass')</div></div></div></blockquote><div><br></div></span><div>The issue is actually that you're comparing a mesh field, "radius" with a particle field "particle_mass". Mesh fields are defined on the ramses AMR mesh and particle fields are defined at the particle locations. The indexing error comes from the fact that there there are different number of particles and mesh cells. More information about this distinction here:</div><div><br></div><div><a href="http://yt-project.org/doc/analyzing/fields.html" target="_blank">http://yt-project.org/doc/<wbr>analyzing/fields.html</a><br></div><div><br></div><div>In addition, ProfilePlot is supposed to only be used for fields defined on the AMR mesh, for particle fields you should use ParticlePlot. <br></div><div><br></div><div>I thought that we had resolved the issue with providing a nice error message when trying to create a plot mixing mesh and particle fields, but I guess we missed ProfilePlot. I will take a closer look at this and hopefully add a better error message so future newcomers don't get confused. I've filed an issue about this here: <a href="https://bitbucket.org/yt_analysis/yt/issues/1261" target="_blank">https://bitbucket.org/<wbr>yt_analysis/yt/issues/1261</a></div><div><br></div><div>You *could* use ParticlePlot instead of ProfilePlot to plot the average of the particle masses as a function of radius - although that's not really what you want if I understand you correctly.</div><div><br></div><div>To get a profile of the particle density as a function of radius, you really want to do:</div><div><br></div><div>plot = yt.ProfilePlot(sph, "radius", ("deposit", "io_cic"), weight_field=None)</div></div></div></div></blockquote><div><br></div><div>Oops, sorry. You probably don't want to use weight_field=None - since you want the average particle density, not the total :)</div><div><br></div><div>The default weight field is ('gas', 'cell_mass'), which might or might not be what you want. I think 'cell_volume' might be a good choice for this. If you're running a unigrid simulation the weighting shouldn't matter too much, but it does matter a lot for AMR.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>This uses a deposit field (described here <a href="http://yt-project.org/doc/analyzing/fields.html#deposited-particle-fields" target="_blank">http://yt-project.org/<wbr>doc/analyzing/fields.html#<wbr>deposited-particle-fields</a>). This particle field is the deposited particle density - the particle masses are deposited onto the AMR mesh using the cloud in cell algorithm. This doesn't make a distinction between dark matter particles and stars, so if you're not running a dark-matter only simulation you'll need to use a particle filter to create a dark matter particle type:</div><div><br></div><div><a href="http://yt-project.org/doc/analyzing/filtering.html#filtering-particle-fields" target="_blank">http://yt-project.org/doc/<wbr>analyzing/filtering.html#<wbr>filtering-particle-fields</a><br></div><div><br></div><div>and then use the deposited particle field for the new particle type (e.g. ('deposit', 'dark_matter_cic')) to create a dark matter density profile.</div><div><br></div><div>Hope that's helpful, please let us know if you have any additional questions.</div><div><br></div><div>-Nathan</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class=""><div dir="ltr"><div><div><br></div><div>This returns</div><div>IndexError: index 3665 is out of bounds for axis 1 with size 3665</div></div><div><br></div><div>If I understand this correctly the problem is in the sphere object. </div><div>It works fine if I keep the sphere inside the edge of the simulation.</div><div><br></div><div>Is there a way to deal with this problem?</div><div><br></div><div>PS: I know particle_mass is not the density of the dark matter, but I haven't found a field for that, so this will have to do until I find one or learn how to make one myself.</div><div><br></div><div>Best,</div><div>Andreas Ellewsen</div></div>
<br></span>______________________________<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></div>
</blockquote></div><br></div></div>