<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 27, 2016 at 12:14 PM, 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 Mon, Jun 27, 2016 at 11:59 AM, Hansheng Chen <span dir="ltr"><<a href="mailto:jasonhs1221@gmail.com" target="_blank">jasonhs1221@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">Hello yt users, <div><br></div><div>I have a question about projection. I used ds.proj() and to_frb() to get an image array of the projected 'Electron_Density' of an entire dataset. I multiplied the mean of projected 'Electron_Density' by the entire area of x-y plane and got a sum of total mass of electrons. Then, I used ds.all_data() and mean() to get the mean of 'Electron_Density' in 3-dimensional. I multiplied the mean by the volume of the entire box of the dataset and got another sum of total mass of electrons. However, this sum did not match the sum I got from the projected 'Electron_Density' previously. Here are the codes I used:</div><div><br></div><div><div>import yt</div><div>import numpy as np</div><div>ds = yt.load("redshift0100/redshift0100")</div><div>print("Redshift =", ds.current_redshift)</div></div><div><br></div><div>p = yt.ProjectionPlot(ds, 2, 'Electron_Density')<br></div><div><div>density_image = p.frb['Electron_Density']</div><div>ed = density_image['Electron_Density'].convert_to_cgs()</div></div></div></blockquote><div><br></div></span><div>Are you sure this code would run? I'm pretty sure this line would produce an IndexError, since you can't use a string to index into an array.</div><span class=""><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"><div dir="ltr"><div>ed_ndarr = ed.to_ndarray()<br></div><div>sum1 = ed_ndarr.mean() * ((105.82 * 3.085677581e+24)**2)<br></div><div>print(sum1)</div><div><br></div><div>dd = ds.all_data()<br></div><div>ed_3d = dd['Electron_Density'].convert_to_cgs()<br></div><div>sum2 = ed_3d.mean() * ((105.82 * 3.085677581e+24)**3)</div><div>print(sum2)</div></div></blockquote><div><br></div></span><div>You're not comparing apples and oranges here. </div></div></div></div></blockquote><div><br></div><div>Oops, meant to say "you're comparing apples and oranges here"</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>In particular, in this section, you've found the mean density of cells in your simulation. If you have an AMR simulation, each cell is not necessarily the same size, so they do not contribute equally if you want to find the true, volume or mass-weighted mean density in your simulation.</div><div><br></div><div>It would be a closer comparison to use a covering grid, or you could ask for a volume-weighted mean:</div><div><br></div><div><div>In [18]: dd.quantities.weighted_average_quantity('El_density', weight='cell_volume</div><div> ...: ')</div><div>Out[18]: 5.54459040433e-34 g/cm**3</div></div><div><br></div><div>This script makes use of a public test dataset from <a href="http://yt-project.org/data" target="_blank">yt-project.org/data</a> and illustrates the point I'm making:</div><div><br></div><div><a href="https://bpaste.net/show/2eab176d8128" target="_blank">https://bpaste.net/show/2eab176d8128</a><br></div><div><br></div><div>On my machine, both operations print out the same result to machine precision.</div><div><br></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><br></div><div>(105.82 * 3.085677581e+24) is the width of entire box in cm. I think sum1 and sum2 should be close to each other, but the result was that the two values did not match with each other. Is there any problem in the codes I used to get the values of sum1 and sum2? Could some one give me some help?</div><div><br></div><div>Thank you very much!</div><div><br></div><div>Sincerely,</div><div>Hansheng</div><div><br></div></div>
<br></span>_______________________________________________<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/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div></div>