Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import yt
import numpy as np
def StellarMass2(field, data):
return data['STAR', 'particle_mass'].in_units("Msun")
def deposit_density2(field, data):
mass = data['deposit', 'STAR_sum_mass2']
return mass / data['index', 'cell_volume']
d = yt.load("rei10_a0.1001/")
d.add_field(("STAR", "mass2"), function=StellarMass2,
sampling_type="particle", units="Msun")
("STAR", "mass2"), "sum", weight_field='particle_ones')
d.add_field(("deposit", "STAR_density2"), function=deposit_density2,
sampling_type='cell', units='Msun/pc**3')
xcen = d.arr([5, 5, 5], "Mpccm/h")
s = d.sphere(xcen, (100, "kpc"))
sf = ('STAR', 'mass2')
df = ('deposit', 'STAR_sum_mass2')
print(np.amax(s[sf]), np.amax(s[df]))
print(s[sf].sum(), s[df].sum())
print((s['deposit', 'STAR_density2']*s['index', 'cell_volume']).sum().to('Msun'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.