[yt-users] getting abundance of elements contained within a sphere through Profile1D funcion

Nathan Goldbaum nathan12343 at gmail.com
Thu Jun 30 09:28:12 PDT 2016


On Thu, Jun 30, 2016 at 9:10 AM, tazkera haque <h.tazkera at 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 at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160630/32efac59/attachment.htm>


More information about the yt-users mailing list