<div dir="ltr">I agree with Matt. You can make a derived field that is the mass of the species field and simply make profiles of the total mass in that field and the total gas mass.  You can also make a derived field that is the ratio of the density of that field to the total gas density and then profile that with some weight field.  That will give you another measurement that is different, but no less valid.  The important thing is to understand statistically what is being calculated and make sure that you are comparing apples to apples.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 31, 2014 at 8:26 AM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@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 class="im">On Fri, Jan 31, 2014 at 2:58 AM, <a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a> <<a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a>> wrote:<br>

> Hi Britton and Matt,<br>
> thanks very much for the clarification... the mathematics is clear but my<br>
> question is the following:<br>
><br>
> If I have a new species which is not defined in YT as _Fraction and I would<br>
> like to plot the mass fraction, how can I avoid such problems with the<br>
> average quantities and binning?<br>
> Which is the right procedure starting from the mass density obtained from<br>
> enzo (species_Density)?<br>
<br>
</div>Create a new derived field:<br>
<br>
<a href="http://yt-project.org/docs/2.6/analyzing/creating_derived_fields.html" target="_blank">http://yt-project.org/docs/2.6/analyzing/creating_derived_fields.html</a><br>
<br>
-Matt<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> Thanks in advance<br>
> Stefano<br>
><br>
> Il giorno 27/gen/14, alle ore 18:34, Britton Smith ha scritto:<br>
><br>
> The reason the answers are getting closer together when you add more bins is<br>
> that you are decreasing the number of points in each bin, and as you do that<br>
> the difference between<br>
> mean(f * g) and mean(f) * mean(g) will get smaller, though it will not be<br>
> identical until you have exactly one cell in each bin.<br>
><br>
><br>
> On Mon, Jan 27, 2014 at 5:29 PM, Stefano Bovino <<a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a>> wrote:<br>
>><br>
>> Ah ok,<br>
>> it seems that increasing a lot the number of bins the two approaches are<br>
>> matching better... is there any reason for that?<br>
>><br>
>> A second question: how it works for the electrons? In enzo the electrons<br>
>> are usually initialized considering a factor of mp/me, YT takes into account<br>
>> this rescaling?<br>
>><br>
>> Thanks again<br>
>> Stefano<br>
>><br>
>><br>
>> On Mon, Jan 27, 2014 at 6:24 PM, Stefano Bovino <<a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> ah... I'm binning, it also depends on the number of bins I'm using, but<br>
>>> the discrepancy (slight) is still there):<br>
>>><br>
>>> prof3 = BinnedProfile1D(sph3, 64, "Radiuspc", 1.0e-6, 1.0e6)<br>
>>><br>
>>> In my initial setup I'm using a box of 300 pc.<br>
>>><br>
>>> Stefano<br>
>>><br>
>>><br>
>>> On Mon, Jan 27, 2014 at 6:20 PM, Stefano Bovino <<a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Hi Matt,<br>
>>>> thanks for the quick reply.<br>
>>>> I'm using simple data from the enzo Collapse Test (27).<br>
>>>> It seems is mainly related to the size of the sphere I'm taking... but I<br>
>>>> don't know.<br>
>>>><br>
>>>> Here following a piece of my script:<br>
>>>><br>
>>>>  pf3=load("DD0003/DD0003")<br>
>>>> c3= pf3.h.find_max("Density")[1]<br>
>>>> sph3 = pf3.h.sphere(c3, (100, 'pc'))<br>
>>>> prof3.add_fields("H2I_Density")<br>
>>>> prof3.add_fields("H2I_Fraction")<br>
>>>> prof3.add_fields("Radius")<br>
>>>><br>
>>>> ...<br>
>>>> ...<br>
>>>><br>
>>>> d_ax2.loglog(prof3['Radius'], prof3['H2I_Density']/prof3['Density'],<br>
>>>>             lw=1.5, linestyle='--', color='r')<br>
>>>> d_ax2.loglog(prof3['Radius'], prof3['H2I_Fraction'],<br>
>>>>             lw=1.5, linestyle=':', color='y')<br>
>>>><br>
>>>> Thanks in advance<br>
>>>> Stefano<br>
>>>><br>
>>>><br>
>>>> On Mon, Jan 27, 2014 at 6:11 PM, Matthew Turk <<a href="mailto:matthewturk@gmail.com">matthewturk@gmail.com</a>><br>
>>>> wrote:<br>
>>>>><br>
>>>>> On Mon, Jan 27, 2014 at 12:14 PM, <a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a><br>
>>>>> <<a href="mailto:poetaste@gmail.com">poetaste@gmail.com</a>> wrote:<br>
>>>>> > Hi Guys,<br>
>>>>> > I did a simple test with enzo and I tried to plot a radial profile of<br>
>>>>> > the<br>
>>>>> > chemical species fractions with YT.<br>
>>>>> ><br>
>>>>> > The problem is that if I use the YT function which intrinsically plot<br>
>>>>> > the<br>
>>>>> > fraction for a species, let's say H2I_Fraction (as usual), and<br>
>>>>> > compare this<br>
>>>>> > with a direct evaluation of the mass fraction:<br>
>>>>> ><br>
>>>>> > data['H2I_Density']/data['Density']<br>
>>>>> ><br>
>>>>> > I obtain some slightly different results, mostly at large radii.<br>
>>>>> ><br>
>>>>> > Anyone might explain this discrepancy!? This happens with all the<br>
>>>>> > species.<br>
>>>>><br>
>>>>> Without knowing what "data" here is, or how you generated it, it's<br>
>>>>> tough to say.<br>
>>>>><br>
>>>>> -Matt<br>
>>>>><br>
>>>>> ><br>
>>>>> > Thank you in advance<br>
>>>>> > Stefano_______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
>>>>> _______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
>>>><br>
>>>><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
>><br>
><br>
> _______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
><br>
><br>
> _______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
_______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</div></div></blockquote></div><br></div>