Paste #107

Welcome To LodgeIt

Welcome to the LodgeIt pastebin. In order to use the notification feature a 31 day cookie with an unique ID was created for you. The lodgeit database does not store any information about you, it's just used for an advanced pastebin experience :-). Read more on the about lodgeit page. Have fun :-)

hide this notification

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
import yt

from yt.data_objects.particle_filters import \
     particle_filter

@particle_filter("star", requires=["creation_time"])
def _dm_filter(pfilter, data):
    dt = data.ds.quan(20, "Myr")
    return data['creation_time'] >= data.ds.current_time - dt

def _sfr_density(field, data):
    dt = data.ds.quan(20, "Myr")
    return data['deposit', 'star_density'] / dt

if __name__ == "__main__":
    ds = yt.load("DD0046/DD0046")
    ds.add_particle_filter('star')
    ds.add_field(('gas', 'sfr_density'),
                 function=_sfr_density,
                 units='Msun/yr/pc**3',
                 sampling_type='cell')