1. Matthew Turk
  2. yt.workshop2012.fields

Source

yt.workshop2012.fields / scripts / derived_fields_tq.py

from yt.mods import *

@derived_field(name = "Dinosaurs", units = "TRexPerS")
def Dinosaurs(field, data):
    return (data["Density"]**(2./3) /
            data["Temperature"]**(0.5))

pf = load("Enzo_64/DD0023/data0023")
dd = pf.h.all_data()

dinosaurs, = dd.quantities["TotalQuantity"](["Dinosaurs"])
print "Total T-Rexes per Second: %0.3e" % (dinosaurs)