I also have a follow-up question. My previous question was about the
build-in deposited fields. But when I try to do that myself, units seem
to be screwed up.
-----------------------
import yt
import numpy as np
def StellarMass2(field,data):
ms = data[('STAR','particle_mass')]
if('FieldDetector' in str(type(data))):
return ms
else:
return ms.in_units("Msun")
d = yt.load("rei10_a0.1001/rei10_a0.1001.art")
d.add_field(("STAR","mass2"),function=StellarMass2,sampling_type="particle",units="Msun")
d.add_deposited_particle_field(("STAR","mass2"),"nearest",weight_field='particle_ones')
xcen = d.arr([5,5,5],"Mpccm/h")
s = d.sphere(xcen,(100,"kpc"))
sf = ('STAR','mass2')
df = ('deposit','STAR_nn_mass2')
print(np.amax(s[sf]),np.amax(s[df]))
----------------------------
>
1625.2196373326824 Msun 1625.2196373326824 Msun
I.e, the units of the deposited field are that of mass, rather than density.
Even worse, if I treat the deposited field as the mass per cell rather
than density, it does not add up:
print("sum=%9.3e
int=%9.3e"%(np.sum(s[sf].in_units("Msun")),np.sum(s[df].in_units("Msun"))))
> sum=3.252e+04 int=1.521e+05
So, I am totally lost about what add_deposited_particle_field() function
actually does.
n