aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-29 00:10:32 +0800
committerAaron LI <aly@aaronly.me>2019-01-29 00:10:32 +0800
commite2e1606538d3f412ee210171ff5f4d64c4da903b (patch)
tree3bcb21cf355681a5483d3ab093496542a96412b2 /fg21sim/extragalactic
parent5b3da36203cb3db85d699b14d99150981e899074 (diff)
downloadfg21sim-e2e1606538d3f412ee210171ff5f4d64c4da903b.tar.bz2
clusters/formation: Implement history() method
Compared to the original mergers() method, this method extracts all formation history (i.e., both mergers and accretions). The mergers() method is now simply wraps on the history() method.
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r--fg21sim/extragalactic/clusters/formation.py52
1 files changed, 36 insertions, 16 deletions
diff --git a/fg21sim/extragalactic/clusters/formation.py b/fg21sim/extragalactic/clusters/formation.py
index b4b0107..65e32b6 100644
--- a/fg21sim/extragalactic/clusters/formation.py
+++ b/fg21sim/extragalactic/clusters/formation.py
@@ -1,5 +1,5 @@
-# Copyright (c) 2017-2018 Weitian LI <weitian@aaronly.me>
-# MIT license
+# Copyright (c) 2017-2019 Weitian LI <wt@liwt.net>
+# MIT License
"""
Simulate cluster formation (i.e., merging history) using the extended
@@ -17,6 +17,7 @@ References
"""
import logging
+import operator as op
import numpy as np
import scipy.integrate
@@ -253,38 +254,57 @@ class ClusterFormation:
else:
return event_max
- def mergers(self, mtree=None):
+ def history(self, mtree=None, merger_only=False):
"""
- Extract and return all the merger events.
+ Extract and return all the formation events, e.g., merger and
+ accretion.
Parameters
----------
mtree : `~MergerTree`, optional
- Specify the merger tree from which to identify the most
- recent merger event.
- Default: self.mtree
+ The simulated merger tree from which to extract the history.
+ Default: ``self.mtree``
+ merger_only : bool, optional
+ If ``True``, only extract the merger events.
Returns
-------
evlist : list[event]
- List of merger events with each element being a dictionary
- same as the return of ``self.recent_major_merger``.
+ List of events with each element being a dictionary of the
+ event properties.
"""
if mtree is None:
mtree = self.mtree
evlist = []
for main, sub in mtree.itermain():
+ z, age, M_main = op.itemgetter("z", "age", "mass")(main)
if sub:
- evlist.append({
- "M_main": main["mass"],
- "M_sub": sub["mass"],
- "R_mass": main["mass"] / sub["mass"],
- "z": main["z"],
- "age": main["age"]
- })
+ # merger
+ M_sub = sub["mass"]
+ R_mass = M_main / M_sub
+ else:
+ # accretion
+ if merger_only:
+ continue
+ M_sub, R_mass = None, None
+
+ evlist.append({
+ "z": z,
+ "age": age,
+ "M_main": M_main,
+ "M_sub": M_sub,
+ "R_mass": R_mass,
+ })
+
return evlist
+ def mergers(self, mtree=None):
+ """
+ Extract and return all the merger events.
+ """
+ return self.history(mtree=mtree, merger_only=True)
+
def _trace_main(self):
"""
Iteratively trace the merger and accretion events of the main