Calculation of enclosed mass for a given radius
Hi Guys, I want to compute the enclosed mass for a given radius to make use of it for computing other quantities. I would like to define a new field like EnclosedMass. How can i use accumulation flag in combination with new defined field to compute the enclosed mass(like in prof.add_fields case). Unfortunately, add_field does not accept it. May be there be there is another way to do this. Any help in this regard will appreciated. prof.add_fields("CellMass",weight=None,accumulation=True) def EnclosedMass(field,data): return data["Density"]*data["CellVolume"] add_field("EnclosedMass", function=EnclosedMass,weight=None,accumulation=True) Thanks in advance! Cheers Latif
Hi Latif, 1) You have to do the derived field before your pf is loaded; this will hopefully change at some point. You're also using add_field here as would normally be done for a profile, but you're using it to define a new derived field. 2) We have "CellMassMsun" and "CellMass" fields already -- which do what you're looking to do. You should be able to do exactly what you are doing, prof.add_fields(["CellMass"], accumulation=True, weight=None) which will sum from the low bins to the high bins. I don't think you need any additional derived fields. Does that help? We'll add a recipe to do this to the cookbook. -Matt On Thu, Jul 19, 2012 at 7:41 AM, Latif <latifne@gmail.com> wrote:
Hi Guys, I want to compute the enclosed mass for a given radius to make use of it for computing other quantities. I would like to define a new field like EnclosedMass. How can i use accumulation flag in combination with new defined field to compute the enclosed mass(like in prof.add_fields case). Unfortunately, add_field does not accept it. May be there be there is another way to do this. Any help in this regard will appreciated.
prof.add_fields("CellMass",weight=None,accumulation=True)
def EnclosedMass(field,data): return data["Density"]*data["CellVolume"]
add_field("EnclosedMass", function=EnclosedMass,weight=None,accumulation=True)
Thanks in advance! Cheers Latif
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Matt, Many thanks!
1) You have to do the derived field before your pf is loaded; this will hopefully change at some point. You're also using add_field here as would normally be done for a profile, but you're using it to define a new derived field.
Sorry, i did not explain it very well. Yes, you are very right one has to add a new derived field before loading a pf. I used add_field here as i wanted to make use of it for computing profiles at the moment.
2) We have "CellMassMsun" and "CellMass" fields already -- which do what you're looking to do. You should be able to do exactly what you are doing,
As you know "CellMass" is not computing the enclosed mass( it does not sum up the mass with in a certian radius) . Prof.add_fields with accumulation flag true computes the enclosed mass radial profile. What i want is to store the computed enclosed mass in a new profile field or variable so that i can make use of it to compute other profiles like keplerian velocity etc. At the moment i do not know how to store enlcosed mass. That is why i thought to add a new prof field for this purpose. Does it make sense? Please let me know it is not clear. Cheers Latif
prof.add_fields(["CellMass"], accumulation=True, weight=None)
which will sum from the low bins to the high bins. I don't think you
need any additional derived fields.
Does that help? We'll add a recipe to do this to the cookbook.
-Matt
On Thu, Jul 19, 2012 at 7:41 AM, Latif <latifne@gmail.com> wrote:
Hi Guys, I want to compute the enclosed mass for a given radius to make use of it for computing other quantities. I would like to define a new field like EnclosedMass. How can i use accumulation flag in combination with new defined field to compute the enclosed mass(like in prof.add_fields case). Unfortunately, add_field does not accept it. May be there be there is another way to do this. Any help in this regard will appreciated.
prof.add_fields("CellMass",weight=None,accumulation=True)
def EnclosedMass(field,data): return data["Density"]*data["CellVolume"]
add_field("EnclosedMass", function=EnclosedMass,weight=None,accumulation=True)
Thanks in advance! Cheers Latif
_______________________________________________ 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 Latif, On Thu, Jul 19, 2012 at 8:57 AM, Latif <latifne@gmail.com> wrote:
Hi Matt, Many thanks!
1) You have to do the derived field before your pf is loaded; this will hopefully change at some point. You're also using add_field here as would normally be done for a profile, but you're using it to define a new derived field.
Sorry, i did not explain it very well. Yes, you are very right one has to add a new derived field before loading a pf. I used add_field here as i wanted to make use of it for computing profiles at the moment.
2) We have "CellMassMsun" and "CellMass" fields already -- which do what you're looking to do. You should be able to do exactly what you are doing,
As you know "CellMass" is not computing the enclosed mass( it does not sum up the mass with in a certian radius) . Prof.add_fields with accumulation flag true computes the enclosed mass radial profile. What i want is to store the computed enclosed mass in a new profile field or variable so that i can make use of it to compute other profiles like keplerian velocity etc. At the moment i do not know how to store enlcosed mass. That is why i thought to add a new prof field for this purpose. Does it make sense? Please let me know it is not clear.
Ah, I see. You can do this: prof = BinnedProfile1D( ... ) prof.add_fields(["CellMass"], weight = None, accumulation = True) prof["MassSquared"] = prof["CellMass"]**2.0 Does that give you a hint where you can go? -Matt
Cheers Latif
prof.add_fields(["CellMass"], accumulation=True, weight=None)
which will sum from the low bins to the high bins. I don't think you need any additional derived fields.
Does that help? We'll add a recipe to do this to the cookbook.
-Matt
On Thu, Jul 19, 2012 at 7:41 AM, Latif <latifne@gmail.com> wrote:
Hi Guys, I want to compute the enclosed mass for a given radius to make use of it for computing other quantities. I would like to define a new field like EnclosedMass. How can i use accumulation flag in combination with new defined field to compute the enclosed mass(like in prof.add_fields case). Unfortunately, add_field does not accept it. May be there be there is another way to do this. Any help in this regard will appreciated.
prof.add_fields("CellMass",weight=None,accumulation=True)
def EnclosedMass(field,data): return data["Density"]*data["CellVolume"]
add_field("EnclosedMass", function=EnclosedMass,weight=None,accumulation=True)
Thanks in advance! Cheers Latif
_______________________________________________ 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 Matt, Thanks a lot !
Ah, I see. You can do this:
prof = BinnedProfile1D( ... ) prof.add_fields(["CellMass"], weight = None, accumulation = True)
prof["MassSquared"] = prof["CellMass"]**2.0
Does that give you a hint where you can go?
Yes, indeed i want some thing very similar. It should solve my problem Cheers Latif
-Matt
Cheers Latif
prof.add_fields(["CellMass"], accumulation=True, weight=None)
which will sum from the low bins to the high bins. I don't think you need any additional derived fields.
Does that help? We'll add a recipe to do this to the cookbook.
-Matt
On Thu, Jul 19, 2012 at 7:41 AM, Latif <latifne@gmail.com> wrote:
Hi Guys, I want to compute the enclosed mass for a given radius to make use of it for computing other quantities. I would like to define a new field like EnclosedMass. How can i use accumulation flag in combination with new defined field to compute the enclosed mass(like in prof.add_fields case). Unfortunately, add_field does not accept it. May be there be there is another way to do this. Any help in this regard will appreciated.
prof.add_fields("CellMass",weight=None,accumulation=True)
def EnclosedMass(field,data): return data["Density"]*data["CellVolume"]
add_field("EnclosedMass", function=EnclosedMass,weight=None,accumulation=True)
Thanks in advance! Cheers Latif
_______________________________________________ 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
participants (2)
-
Latif -
Matthew Turk