thank you both for the help!
Make a derived fields seems to me the right direction!

Cheers,
Stefano

Il giorno 31/gen/14, alle ore 15:54, Britton Smith ha scritto:

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.


On Fri, Jan 31, 2014 at 8:26 AM, Matthew Turk <matthewturk@gmail.com> wrote:
On Fri, Jan 31, 2014 at 2:58 AM, poetaste@gmail.com <poetaste@gmail.com> wrote:
> Hi Britton and Matt,
> thanks very much for the clarification... the mathematics is clear but my
> question is the following:
>
> If I have a new species which is not defined in YT as _Fraction and I would
> like to plot the mass fraction, how can I avoid such problems with the
> average quantities and binning?
> Which is the right procedure starting from the mass density obtained from
> enzo (species_Density)?

Create a new derived field:

http://yt-project.org/docs/2.6/analyzing/creating_derived_fields.html

-Matt

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

_______________________________________________
yt-users mailing list
yt-users@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org