getting abundance of elements contained within a sphere through Profile1D funcion

Hi, I am trying to find abundance of C contained within a sphere through the Profile1D function in yt. I tried something like this: *ds=yt.load(filename)* * sp = ds.sphere("max", (10.0, 'kpc'))* * profile = yt.Profile1D(sp, "x", 32, rmin, rmax, False, weight_field=None)* * profile.add_fields(["cell_mass"])* * profile.add_fields(["c12 "])* * profile.add_fields(["x"])* *print profile ["cell_mass"].sum()/Msun* *print profile ["c12 "]*["cell_mass"].sum()/Msun* and got the following error: * File "profile_1D.py", line 74, in <module>* * print profile ((["c12 "]*["cell_mass"]).sum())/Msun* *TypeError: can't multiply sequence by non-int of type 'list'* *is there any way I can calculate the C12 abundance here?* *Best* *Tazkera*

On Thu, Jun 30, 2016 at 9:10 AM, tazkera haque <h.tazkera@gmail.com> wrote:
Hi,
I am trying to find abundance of C contained within a sphere through the Profile1D function in yt. I tried something like this:
*ds=yt.load(filename)* * sp = ds.sphere("max", (10.0, 'kpc'))* * profile = yt.Profile1D(sp, "x", 32, rmin, rmax, False, weight_field=None)*
* profile.add_fields(["cell_mass"])* * profile.add_fields(["c12 "])* * profile.add_fields(["x"])* *print profile ["cell_mass"].sum()/Msun* *print profile ["c12 "]*["cell_mass"].sum()/Msun*
and got the following error:
* File "profile_1D.py", line 74, in <module>* * print profile ((["c12 "]*["cell_mass"]).sum())/Msun* *TypeError: can't multiply sequence by non-int of type 'list'*
Maybe you meant to do something like: print (profile['c12'] * profile['cell_mass']).sum() ? The code you have in that error involves doing something like ['c12'] * ['cell_mass'], and indeed you can't multiply two lists together.
*is there any way I can calculate the C12 abundance here?*
*Best* *Tazkera*
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

thanks, Nathan, solves my problem Best On Thu, Jun 30, 2016 at 10:28 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
On Thu, Jun 30, 2016 at 9:10 AM, tazkera haque <h.tazkera@gmail.com> wrote:
Hi,
I am trying to find abundance of C contained within a sphere through the Profile1D function in yt. I tried something like this:
*ds=yt.load(filename)* * sp = ds.sphere("max", (10.0, 'kpc'))* * profile = yt.Profile1D(sp, "x", 32, rmin, rmax, False, weight_field=None)*
* profile.add_fields(["cell_mass"])* * profile.add_fields(["c12 "])* * profile.add_fields(["x"])* *print profile ["cell_mass"].sum()/Msun* *print profile ["c12 "]*["cell_mass"].sum()/Msun*
and got the following error:
* File "profile_1D.py", line 74, in <module>* * print profile ((["c12 "]*["cell_mass"]).sum())/Msun* *TypeError: can't multiply sequence by non-int of type 'list'*
Maybe you meant to do something like:
print (profile['c12'] * profile['cell_mass']).sum()
?
The code you have in that error involves doing something like ['c12'] * ['cell_mass'], and indeed you can't multiply two lists together.
*is there any way I can calculate the C12 abundance here?*
*Best* *Tazkera*
_______________________________________________ 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)
-
Nathan Goldbaum
-
tazkera haque