[yt-users] Projection disagrees with original data.

Hansheng Chen jasonhs1221 at gmail.com
Mon Jun 27 10:49:08 PDT 2016


Hello Nathan,

I checked the code, and it is not correct, as what you said. It should be: ed
= density_image.convert_to_cgs() instead of  ed = density_image['Electron_
Density'].convert_to_cgs().

I used the dd.quantities.weighted_average_quantity('Electron_Density',
weight='cell_volume'), and I got a sum close to the sum I got from the
projection.

Thank you for your help!

Best,
Hansheng



2016-06-27 13:18 GMT-04:00 Nathan Goldbaum <nathan12343 at gmail.com>:

>
>
> On Mon, Jun 27, 2016 at 12:14 PM, Nathan Goldbaum <nathan12343 at gmail.com>
> wrote:
>
>>
>>
>> On Mon, Jun 27, 2016 at 11:59 AM, Hansheng Chen <jasonhs1221 at gmail.com>
>> wrote:
>>
>>> Hello yt users,
>>>
>>> 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:
>>>
>>> import yt
>>> import numpy as np
>>> ds = yt.load("redshift0100/redshift0100")
>>> print("Redshift =", ds.current_redshift)
>>>
>>> p = yt.ProjectionPlot(ds, 2, 'Electron_Density')
>>> density_image = p.frb['Electron_Density']
>>> ed = density_image['Electron_Density'].convert_to_cgs()
>>>
>>
>> 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.
>>
>>
>>> ed_ndarr = ed.to_ndarray()
>>> sum1 = ed_ndarr.mean() * ((105.82 * 3.085677581e+24)**2)
>>> print(sum1)
>>>
>>> dd = ds.all_data()
>>> ed_3d = dd['Electron_Density'].convert_to_cgs()
>>> sum2 = ed_3d.mean() * ((105.82 * 3.085677581e+24)**3)
>>> print(sum2)
>>>
>>
>> You're not comparing apples and oranges here.
>>
>
> Oops, meant to say "you're comparing apples and oranges here"
>
>
>> 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.
>>
>> It would be a closer comparison to use a covering grid, or you could ask
>> for a volume-weighted mean:
>>
>> In [18]: dd.quantities.weighted_average_quantity('El_density',
>> weight='cell_volume
>>     ...: ')
>> Out[18]: 5.54459040433e-34 g/cm**3
>>
>> This script makes use of a public test dataset from yt-project.org/data
>> and illustrates the point I'm making:
>>
>> https://bpaste.net/show/2eab176d8128
>>
>> On my machine, both operations print out the same result to machine
>> precision.
>>
>>
>>> (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?
>>>
>>> Thank you very much!
>>>
>>> Sincerely,
>>> Hansheng
>>>
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>>
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160627/542c6b2a/attachment.html>


More information about the yt-users mailing list