<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Works! Thank you so much.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-10 16:33 GMT-04:00 Andrew James Emerick <span dir="ltr"><<a href="mailto:aje2123@columbia.edu" target="_blank">aje2123@columbia.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">sorry, that should be "np.sum" instead of "sum"<div><br></div><div><br></div><div><br></div><div>Andrew E.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 10, 2015 at 4:32 PM, Andrew James Emerick <span dir="ltr"><<a href="mailto:aje2123@columbia.edu" target="_blank">aje2123@columbia.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Jingjing,<div><br></div><div>There may be a prettier way to do this, but I would go about this like so:</div><div><br></div><div>1) calculate the HI mass in each cell as HI_density * cell_volume:</div><div><br></div><div>HI_mass = sp['enzo','HI_Density'] * sp['dx']**3</div><div><br></div><div>2) then summing:</div><div><br></div><div>total_mass = sum(HI_mass)</div><div><br></div><div><br></div><div><br></div><div>Andrew E.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Apr 10, 2015 at 4:20 PM, Chen Jingjing <span dir="ltr"><<a href="mailto:chenjj235@gmail.com" target="_blank">chenjj235@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Dear yt-users,<div>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 </div><div><br></div><div>HI_Mass = sphere['enzo','HI_Density'].in_units('Msun').sum()</div><div><br></div><div>But I got an error that says the unit code_mass/code_length**3 cannot be converted to code_mass.</div><div><br></div><div>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?</div><div><br></div><div>Thanks,</div><div>Jingjing</div><span><font color="#888888"><div><div><br></div>-- <br><div><div dir="ltr"><pre>Jingjing Chen [ <a href="mailto:chenjj235@gmail.com" target="_blank">chenjj235@gmail.com</a> ]
Department of Astronomy
Columbia University
550 West 120th Street
New York, New York 10027<br>Cell Phone: <a href="tel:%2B1%28347%295746709" value="+13475746709" target="_blank">+1(347)5746709</a><br></pre></div></div>
</div></font></span></div>
<br></div></div>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div style="font-family:arial;font-size:small">Graduate Student </div><div style="font-family:arial;font-size:small">Columbia University</div><div style="font-family:arial;font-size:small">Department of Astronomy</div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div style="font-family:arial;font-size:small">Graduate Student </div><div style="font-family:arial;font-size:small">Columbia University</div><div style="font-family:arial;font-size:small">Department of Astronomy</div></div></div>
</div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><pre>Jingjing Chen [ <a href="mailto:chenjj235@gmail.com" target="_blank">chenjj235@gmail.com</a> ]
Department of Astronomy
Columbia University
550 West 120th Street
New York, New York 10027<br>Cell Phone: +1(347)5746709<br></pre></div></div>
</div>