[yt-users] Derived Field

Chen Jingjing chenjj235 at gmail.com
Fri Apr 10 13:39:20 PDT 2015


Works! Thank you so much.


2015-04-10 16:33 GMT-04:00 Andrew James Emerick <aje2123 at columbia.edu>:

> sorry, that should be "np.sum" instead of "sum"
>
>
>
> Andrew E.
>
> On Fri, Apr 10, 2015 at 4:32 PM, Andrew James Emerick <
> aje2123 at columbia.edu> wrote:
>
>> Hi Jingjing,
>>
>> There may be a prettier way to do this, but I would go about this like so:
>>
>> 1) calculate the HI mass in each cell as HI_density * cell_volume:
>>
>> HI_mass = sp['enzo','HI_Density'] * sp['dx']**3
>>
>> 2) then summing:
>>
>> total_mass = sum(HI_mass)
>>
>>
>>
>> Andrew E.
>>
>> On Fri, Apr 10, 2015 at 4:20 PM, Chen Jingjing <chenjj235 at gmail.com>
>> wrote:
>>
>>> Dear yt-users,
>>> I am trying to calculate the total HI mass within a sphere. I have a
>>> field called 'HI_Density'. And I tried to use the script
>>>
>>> HI_Mass = sphere['enzo','HI_Density'].in_units('Msun').sum()
>>>
>>> But I got an error that says the unit code_mass/code_length**3 cannot be
>>> converted to code_mass.
>>>
>>> So I thought I might need to create a derived_field called 'HI_Mass'
>>> which mutiplies the HI_Density with code_length**3. But I don't see that
>>> there is any existing field of cell length/volume. So how should I do
>>> this?  Or is there an easier way to compute the total HI mass without
>>> deriving a field?
>>>
>>> Thanks,
>>> Jingjing
>>>
>>> --
>>>
>>> Jingjing Chen [ chenjj235 at gmail.com ]
>>> Department of Astronomy
>>> Columbia University
>>> 550 West 120th Street
>>> New York, New York 10027
>>> Cell Phone: +1(347)5746709
>>>
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>>
>>
>>
>> --
>> Graduate Student
>> Columbia University
>> Department of Astronomy
>>
>
>
>
> --
> Graduate Student
> Columbia University
> Department of Astronomy
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>


-- 

Jingjing Chen [ chenjj235 at gmail.com ]
Department of Astronomy
Columbia University
550 West 120th Street
New York, New York 10027
Cell Phone: +1(347)5746709
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150410/29861726/attachment.html>
-------------- next part --------------
_______________________________________________
yt-users mailing list
yt-users at lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org


More information about the yt-users mailing list