Created
June 1, 2018 20:37
-
-
Save ngoldbaum/a1ea4dc0c8cde6ca1630f251a350b110 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/rei10_a0.1001.art") | |
d.add_field(("STAR", "mass2"), function=StellarMass2, | |
sampling_type="particle", units="Msun") | |
d.add_deposited_particle_field( | |
("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