[galaxy] deal with simulation without epoch field
This commit is contained in:
@@ -133,15 +133,19 @@ def ring_analysis(pp, r=4, dr=0.5, dphi=0.125, z=0, dz=0.5, do_mean=True):
|
||||
|
||||
def get_time_from_relax(pp):
|
||||
pp.load_parts()
|
||||
try:
|
||||
epoch = pp.parts["epoch"].copy()
|
||||
epoch *= pp.info["unit_time"].express(U.Myr)
|
||||
trelax = np.min(epoch[epoch > 0])
|
||||
tfromrelax = np.max(epoch - trelax)
|
||||
except KeyError:
|
||||
tfromrelax = 0.0
|
||||
return tfromrelax
|
||||
|
||||
|
||||
def get_last_sfr(pp):
|
||||
pp.load_parts()
|
||||
try:
|
||||
epoch = pp.parts["epoch"].copy()
|
||||
epoch *= pp.info["unit_time"].express(U.year)
|
||||
mass = pp.parts["mass"].copy()
|
||||
@@ -150,6 +154,8 @@ def get_last_sfr(pp):
|
||||
masstot, time = np.histogram(epoch[mask], weights=mass[mask], bins=100)
|
||||
dtime = np.diff(time)
|
||||
sfr = masstot[-1] / dtime[-1]
|
||||
except KeyError:
|
||||
sfr = 0.0
|
||||
return sfr
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user