having a little trouble with merger trees. I seem to be able to load the tree fine and all the right arrays are there, but trying to use: il.sublink.numMergers gives me an error I cant get my head around.
Any help would be appreciated!
tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=True)
numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
Traceback (most recent call last):
File "", line 1, in
File "illustris_python/sublink.py", line 216, in numMergers
npMass, npSnapshot = maxPastMass_old(tree, npIndex, massPartType)
File "illustris_python/sublink.py", line 184, in maxPastMass_old
branchSize = tree['MainLeafProgenitorID'][index] - tree['SubhaloID'][index] + 1
IndexError: index 9638194 is out of bounds for axis 0 with size 100
Dylan Nelson
30 Nov '20
Hi Steven,
Can you post a complete example so I can look more carefully? E.g. what are basePath and halo_id?
Steven Gough-Kelly
30 Nov '20
import illustris_python as il
basePath = '/virgo/data/IllustrisTNG/TNG50-1/output/'
halo_id = 562029
tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=True)
numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
Traceback (most recent call last):
File "", line 1, in
File "illustris_python/sublink.py", line 216, in numMergers
npMass, npSnapshot = maxPastMass_old(tree, npIndex, massPartType)
File "illustris_python/sublink.py", line 184, in maxPastMass_old
branchSize = tree['MainLeafProgenitorID'][index] - tree['SubhaloID'][index] + 1
IndexError: index 43993 is out of bounds for axis 0 with size 99
Dylan Nelson
30 Nov '20
Hi Steven,
The main progenitor branch (MPB) contains only the single, direct progenitor of the subhalo at each previous snapshot. So if there are 100 snapshots, loadTree(..., onlyMPB=True) should return ~100 values for each field, e.g. mass.
This means by definition subhalos which merge into this branch, i.e. merger events, are not contained in this dataset.
So you need to load with onlyMPB=False, if you want to measure any properties or statistics about mergers, including use of the numMergers() function.
p.s. you should also write subhalo_id = 562029 instead of halo_id, as all trees work on a (subfind) subhalo, not a (fof) halo.
Steven Gough-Kelly
30 Nov '20
Hey Dylan, thanks for getting back to me. Pulling the whole branch results in the following error.
tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=False)
numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
Traceback (most recent call last):
File "", line 1, in
File "illustris_python/sublink.py", line 222, in numMergers
if ratio >= minMassRatio and ratio <= invMassRatio:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Dylan Nelson
30 Nov '20
I'm afraid I can't reproduce, this works for me.
$ ipython
Python 3.8.0 (default, Nov 6 2019, 21:49:08)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.10.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import illustris_python as il
In [2]: basePath = '/virgo/data/IllustrisTNG/TNG50-1/output/'
In [3]: halo_id = 562029
In [4]: tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=False)
In [5]: numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
In [6]: numMergers
Out[6]: 7
What version of python are you running?
Steven Gough-Kelly
2 Dec '20
Hey Dylan,
so I was using an old environment in python. I have now upgraded to python 3.8.0 and has given the following error instead:
Traceback (most recent call last):
File "", line 1, in
File "/isaac/u/sgoughkelly/TNG/pullTNGgalaxy/illustris_python/sublink.py", line 219, in numMergers
if fpMass > 0.0 and npMass > 0.0:
TypeError: '>' not supported between instances of 'tuple' and 'float'
Dylan Nelson
2 Dec '20
You'll have to check which of fpMass or npMass is a tuple rather than a number, and go backwards and figure out why this happened.
Steven Gough-Kelly
17 Dec '20
Hi Dylan,
just to follow up on this I have located the error within sublink.py - numMergers
while fpID != -1:
fpIndex = index + (fpID - rootID)
fpMass = maxPastMass_old(tree, fpIndex, massPartType)
# explore breadth
npID = tree['NextProgenitorID'][fpIndex]
while npID != -1:
npIndex = index + (npID - rootID)
npMass, npSnapshot = maxPastMass_old(tree, npIndex, massPartType)
# count if both masses are non-zero, and ratio exceeds threshold
if fpMass > 0.0 and npMass > 0.0:
ratio = npMass / fpMass
if ratio >= minMassRatio and ratio <= invMassRatio:
numMergers += 1
Hi all,
having a little trouble with merger trees. I seem to be able to load the tree fine and all the right arrays are there, but trying to use: il.sublink.numMergers gives me an error I cant get my head around.
Any help would be appreciated!
tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=True)
numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
Traceback (most recent call last):", line 1, in
File "
File "illustris_python/sublink.py", line 216, in numMergers
npMass, npSnapshot = maxPastMass_old(tree, npIndex, massPartType)
File "illustris_python/sublink.py", line 184, in maxPastMass_old
branchSize = tree['MainLeafProgenitorID'][index] - tree['SubhaloID'][index] + 1
IndexError: index 9638194 is out of bounds for axis 0 with size 100
Hi Steven,
Can you post a complete example so I can look more carefully? E.g. what are
basePath
andhalo_id
?import illustris_python as il
basePath = '/virgo/data/IllustrisTNG/TNG50-1/output/'
halo_id = 562029
tree = il.sublink.loadTree(basePath,99,halo_id,onlyMPB=True)
numMergers = il.sublink.numMergers(tree,minMassRatio=1./5.)
Traceback (most recent call last):", line 1, in
File "
File "illustris_python/sublink.py", line 216, in numMergers
npMass, npSnapshot = maxPastMass_old(tree, npIndex, massPartType)
File "illustris_python/sublink.py", line 184, in maxPastMass_old
branchSize = tree['MainLeafProgenitorID'][index] - tree['SubhaloID'][index] + 1
IndexError: index 43993 is out of bounds for axis 0 with size 99
Hi Steven,
The main progenitor branch (MPB) contains only the single, direct progenitor of the subhalo at each previous snapshot. So if there are 100 snapshots,
loadTree(..., onlyMPB=True)
should return ~100 values for each field, e.g. mass.This means by definition subhalos which merge into this branch, i.e. merger events, are not contained in this dataset.
So you need to load with
onlyMPB=False
, if you want to measure any properties or statistics about mergers, including use of thenumMergers()
function.p.s. you should also write
subhalo_id = 562029
instead of halo_id, as all trees work on a (subfind) subhalo, not a (fof) halo.Hey Dylan, thanks for getting back to me. Pulling the whole branch results in the following error.
I'm afraid I can't reproduce, this works for me.
What version of python are you running?
Hey Dylan,
so I was using an old environment in python. I have now upgraded to python 3.8.0 and has given the following error instead:
Traceback (most recent call last):", line 1, in
File "
File "/isaac/u/sgoughkelly/TNG/pullTNGgalaxy/illustris_python/sublink.py", line 219, in numMergers
if fpMass > 0.0 and npMass > 0.0:
TypeError: '>' not supported between instances of 'tuple' and 'float'
You'll have to check which of
fpMass
ornpMass
is a tuple rather than a number, and go backwards and figure out why this happened.Hi Dylan,
just to follow up on this I have located the error within sublink.py - numMergers
Here:
the function maxPastMass_old returns:
so fpMass becomes a tuple. I have adjusted my code to make:
I am going to use the largest value of fpSnapshot or npSnapshot to return when these mergers take place.
I see the changes in the public repo of illustris_python which corrects for this.
Many thanks!
Hi Steven,
Thanks for the update, sounds like an annoying problem to track down!
I don't see that the official repositories ever had code like that, I assume that you received a modified version from someone - good it's solved now.