
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.
Thank you in advance Stefano

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

It's tough to say since I don't know exactly how you've done these measurements, but my guess is that it has to due with how the profiles (assuming you have made profiles) are calculated. Can you please provide us with the actual calculations you're doing that are discrepant?
On Mon, Jan 27, 2014 at 5: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

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

On Mon, Jan 27, 2014 at 12: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")
By default, these will be unweighted values. So it's summing them up in the bins. I don't know how prof3 is defined, but the "binning" field is specified in its constructor. You probably don't want to do either weighted or unweighted radius field addition. The yt method paper and the yt docs go into some detail about the way that profiles function, including averaging, binning fields, and so on.
Hope that helps,
Matt
... ...
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

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.comwrote:
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

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.comwrote:
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.comwrote:
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

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.comwrote:
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.comwrote:
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.comwrote:
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

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)?
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

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

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

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
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

Hi,
I'm trying to read data from a RAMSES output using a ray (c.f. http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#line...) - I basically call:
import yt.mods pf = yt.mods.load("output_00007/info_00007.txt") ray = pf.h.ray((0.5,0.5,0.5),(0,0,0)) ray["Density"] # <-- throws exception here
It works fine up until when I try to query the density, whereupon it throws a KeyError (ray.keys() is also empty). It seems to find all the fields fine when creating the ray object. Error log at the bottom of the e-mail.
I'm pretty sure I'm using the latest version of YT from the yt-3.0 branch of the yt repository, but if I'm the only one getting this error I can double-check.
Anyone have any ideas? Failing that, if there's a better way to sample data along a line in YT, let me know.
Thanks!
Sam
--- In [5]: print ray["Density"] --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-5-dbeb4caf2ed1> in <module>() ----> 1 print ray["Density"]
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in __getitem__(self, key) 189 return self.field_data[f] 190 else: --> 191 self.get_data(f) 192 # Note that this is less succinct so that we can account for the case 193 # when there are, for example, no elements in the object.
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in get_data(self, fields) 573 # need to be generated. 574 read_fluids, gen_fluids = self.hierarchy._read_fluid_fields( --> 575 fluids, self, self._current_chunk) 576 self.field_data.update(read_fluids) 577
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/geometry/geometry_handler.pyc in _read_fluid_fields(self, fields, dobj, chunk) 533 selector, 534 fields_to_read, --> 535 chunk_size) 536 for field in fields_to_read: 537 ftype, fname = field
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/frontends/ramses/io.pyc in _read_fluid_selection(self, chunks, selector, fields, size) 47 d = {} 48 for field in fields: ---> 49 d[field] = np.concatenate(tr.pop(field)) 50 return d 51
KeyError: ('gas', 'Density') ---

Hi Sam,
Looks like rays weren't implemented for octrees. I've issued a PR to implement them here:
https://bitbucket.org/yt_analysis/yt/pull-request/697/enable-rays-to-be-trac...
Once fido reports that the unit tests are all still correct, I will accept it. I've verified it with this:
http://paste.yt-project.org/show/4264/
-Matt
On Fri, Jan 31, 2014 at 11:54 AM, Sam Geen samgeen@astro.ox.ac.uk wrote:
Hi,
I'm trying to read data from a RAMSES output using a ray (c.f. http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#line...)
- I basically call:
import yt.mods pf = yt.mods.load("output_00007/info_00007.txt") ray = pf.h.ray((0.5,0.5,0.5),(0,0,0)) ray["Density"] # <-- throws exception here
It works fine up until when I try to query the density, whereupon it throws a KeyError (ray.keys() is also empty). It seems to find all the fields fine when creating the ray object. Error log at the bottom of the e-mail.
I'm pretty sure I'm using the latest version of YT from the yt-3.0 branch of the yt repository, but if I'm the only one getting this error I can double-check.
Anyone have any ideas? Failing that, if there's a better way to sample data along a line in YT, let me know.
Thanks!
Sam
In [5]: print ray["Density"]
KeyError Traceback (most recent call last) <ipython-input-5-dbeb4caf2ed1> in <module>() ----> 1 print ray["Density"]
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in __getitem__(self, key) 189 return self.field_data[f] 190 else: --> 191 self.get_data(f) 192 # Note that this is less succinct so that we can account for the case 193 # when there are, for example, no elements in the object.
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in get_data(self, fields) 573 # need to be generated. 574 read_fluids, gen_fluids = self.hierarchy._read_fluid_fields( --> 575 fluids, self, self._current_chunk) 576 self.field_data.update(read_fluids) 577
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/geometry/geometry_handler.pyc in _read_fluid_fields(self, fields, dobj, chunk) 533 selector, 534 fields_to_read, --> 535 chunk_size) 536 for field in fields_to_read: 537 ftype, fname = field
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/frontends/ramses/io.pyc in _read_fluid_selection(self, chunks, selector, fields, size) 47 d = {} 48 for field in fields: ---> 49 d[field] = np.concatenate(tr.pop(field)) 50 return d 51
KeyError: ('gas', 'Density')
yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Thanks for this, Matt! Will copy the PR over and let you know if I come unstuck. Sam
On 31/01/14 19:11, Matthew Turk wrote:
Hi Sam,
Looks like rays weren't implemented for octrees. I've issued a PR to implement them here:
https://bitbucket.org/yt_analysis/yt/pull-request/697/enable-rays-to-be-trac...
Once fido reports that the unit tests are all still correct, I will accept it. I've verified it with this:
http://paste.yt-project.org/show/4264/
-Matt
On Fri, Jan 31, 2014 at 11:54 AM, Sam Geen samgeen@astro.ox.ac.uk wrote:
Hi,
I'm trying to read data from a RAMSES output using a ray (c.f. http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#line...)
- I basically call:
import yt.mods pf = yt.mods.load("output_00007/info_00007.txt") ray = pf.h.ray((0.5,0.5,0.5),(0,0,0)) ray["Density"] # <-- throws exception here
It works fine up until when I try to query the density, whereupon it throws a KeyError (ray.keys() is also empty). It seems to find all the fields fine when creating the ray object. Error log at the bottom of the e-mail.
I'm pretty sure I'm using the latest version of YT from the yt-3.0 branch of the yt repository, but if I'm the only one getting this error I can double-check.
Anyone have any ideas? Failing that, if there's a better way to sample data along a line in YT, let me know.
Thanks!
Sam
In [5]: print ray["Density"]
KeyError Traceback (most recent call last) <ipython-input-5-dbeb4caf2ed1> in <module>() ----> 1 print ray["Density"]
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in __getitem__(self, key) 189 return self.field_data[f] 190 else: --> 191 self.get_data(f) 192 # Note that this is less succinct so that we can account for the case 193 # when there are, for example, no elements in the object.
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in get_data(self, fields) 573 # need to be generated. 574 read_fluids, gen_fluids = self.hierarchy._read_fluid_fields( --> 575 fluids, self, self._current_chunk) 576 self.field_data.update(read_fluids) 577
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/geometry/geometry_handler.pyc in _read_fluid_fields(self, fields, dobj, chunk) 533 selector, 534 fields_to_read, --> 535 chunk_size) 536 for field in fields_to_read: 537 ftype, fname = field
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/frontends/ramses/io.pyc in _read_fluid_selection(self, chunks, selector, fields, size) 47 d = {} 48 for field in fields: ---> 49 d[field] = np.concatenate(tr.pop(field)) 50 return d 51
KeyError: ('gas', 'Density')
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

Hi Matt,
I've just had a chance to try out this PR. Out of interest, what's the best way to plot the ray as a profile (e.g. for Density, Temperature, etc)? I tried ray["t"] but the points aren't ordered* and sorting them (and the y-values with np.argsort) the result seems odd too (the values seem OK, but the values at each radius along the line seem unordered).
Also, in the docs (dev version), there seems to be a reference to a field "dts" that doesn't exist: http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#line... (I suspect it's a typo; "dt" works fine).
I can host up a snapshot from my simulation if you want to try it out.
Thanks,
Sam
* For a ray running from (0.5,0.5,0.5) to (0,0,0) in a 128x128x128 box with no AMR: In [7]: print ray["t"] [ 0.984375 0.96875 0.734375 0.71875 0.859375 0.84375 0.609375 0.59375 0.953125 0.9375 0.703125 0.6875 0.828125 0.8125 0.578125 0.5625 0.921875 0.90625 0.671875 0.65625 0.890625 0.875 0.640625 0.625 0.796875 0.78125 0.546875 0.53125 0.765625 0.75 0.515625 0.5 0.484375 0.46875 0.234375 0.21875 0.359375 0.34375 0.109375 0.09375 0.453125 0.4375 0.203125 0.1875 0.328125 0.3125 0.078125 0.0625 0.421875 0.40625 0.171875 0.15625 0.390625 0.375 0.140625 0.125 0.296875 0.28125 0.046875 0.03125 0.265625 0.25 0.015625 -0. ]
On 31/01/14 19:11, Matthew Turk wrote:
Hi Sam,
Looks like rays weren't implemented for octrees. I've issued a PR to implement them here:
https://bitbucket.org/yt_analysis/yt/pull-request/697/enable-rays-to-be-trac...
Once fido reports that the unit tests are all still correct, I will accept it. I've verified it with this:
http://paste.yt-project.org/show/4264/
-Matt
On Fri, Jan 31, 2014 at 11:54 AM, Sam Geen samgeen@astro.ox.ac.uk wrote:
Hi,
I'm trying to read data from a RAMSES output using a ray (c.f. http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#line...)
- I basically call:
import yt.mods pf = yt.mods.load("output_00007/info_00007.txt") ray = pf.h.ray((0.5,0.5,0.5),(0,0,0)) ray["Density"] # <-- throws exception here
It works fine up until when I try to query the density, whereupon it throws a KeyError (ray.keys() is also empty). It seems to find all the fields fine when creating the ray object. Error log at the bottom of the e-mail.
I'm pretty sure I'm using the latest version of YT from the yt-3.0 branch of the yt repository, but if I'm the only one getting this error I can double-check.
Anyone have any ideas? Failing that, if there's a better way to sample data along a line in YT, let me know.
Thanks!
Sam
In [5]: print ray["Density"]
KeyError Traceback (most recent call last) <ipython-input-5-dbeb4caf2ed1> in <module>() ----> 1 print ray["Density"]
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in __getitem__(self, key) 189 return self.field_data[f] 190 else: --> 191 self.get_data(f) 192 # Note that this is less succinct so that we can account for the case 193 # when there are, for example, no elements in the object.
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/data_objects/data_containers.pyc in get_data(self, fields) 573 # need to be generated. 574 read_fluids, gen_fluids = self.hierarchy._read_fluid_fields( --> 575 fluids, self, self._current_chunk) 576 self.field_data.update(read_fluids) 577
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/geometry/geometry_handler.pyc in _read_fluid_fields(self, fields, dobj, chunk) 533 selector, 534 fields_to_read, --> 535 chunk_size) 536 for field in fields_to_read: 537 ftype, fname = field
/home/samgeen/.local/lib/python2.7/site-packages/yt-3.0dev-py2.7-linux-x86_64.egg/yt/frontends/ramses/io.pyc in _read_fluid_selection(self, chunks, selector, fields, size) 47 d = {} 48 for field in fields: ---> 49 d[field] = np.concatenate(tr.pop(field)) 50 return d 51
KeyError: ('gas', 'Density')
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

I think there is a bigger problem here. When you do a profile of a field (with some weight field), the values you get out are the weight-average of the field such that: profile (field, weight_field) = Sum (field * weight_field) / Sum(weight_field)
You are comparing profile(H2_Density) / profile(Density) with profile(H2_Density / Density)
Mathematically, these are not the same.
Or, in other words: mean(x * y) != mean(x) * mean(y)
On Mon, Jan 27, 2014 at 5: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.comwrote:
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.comwrote:
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
participants (5)
-
Britton Smith
-
Matthew Turk
-
poetaste@gmail.com
-
Sam Geen
-
Stefano Bovino