HaloMass

Yeimy dallana Camargo camargo
  • 13 Jun

Hello Dylan,

I'm asking you because I have a problem, I want obtain the mass of all halos (Group_M_Crit200?), it's positions (GroupPos?) and its formation time on Illustris-3, my actual code is:

import groupcat as GC
import sublink as SL
import numpy as np
import lhalotree as LH

GroupFirstSub = GC.loadHalos(basePath,135,fields=['GroupFirstSub'])
Halos=GC.loadHalos(basePath,135,fields=['Group_M_Crit200','GroupPos'])

for i in range(start,start+5):
tree = SL.loadTree(basePath,135,GroupFirstSub[i],fields=fields,onlyMPB=True)
def find_formation_time(sublinktree):
.
.
.
.
.

fields = ['SnapNum','Group_M_Crit200']

start = 0
n_halos = len(Halos['Group_M_Crit200'])
formation_time = []
final_mass = []
for i in range(start,start+n_halos):
tree = SL.loadTree(basePath,135,GroupFirstSub[i],fields=fields,onlyMPB=True)
formation_time.append(find_formation_time(tree))
final_mass.append(tree['Group_M_Crit200'][0])

len(Halos['Group_M_Crit200'])= 131727, then in Illustris-3 simulation have 131727 halos, but an error occurs: ValueError: Index (4294906691) out of range (0-60604).

I don't understand whats happen, can you help me please?
Thanks in advance

Dylan Nelson
  • 13 Jun

Hi Yeimy,

I think you hit a little annoying detail, which is described under the description of GroupFirstSub: "Index into the Subhalo table of the first/primary/most massive Subfind group within this FoF group. Note: This value is signed (or should be interpreted as signed)! In this case, a value of -1 indicates that this FoF group has no subhalos."

This large value of 4294906691 is actually -1, indicating the group has no subhalos. You could load also GroupNsubs and do e.g. if GroupNsubs==0: continue before you try to load the tree.

Yeimy dallana Camargo camargo
  • 13 Jun

Hi,
don't works,

fields = ['SubhaloMass','SnapNum','Group_M_Crit200']
start = 0
n_halos =len(Halos['Group_M_Crit200'])
formation_time = []
final_mass = []
for i in range(start,start+n_halos):
if GroupNsubs.all()==0:
tree = SL.loadTree(basePath,135,GroupFirstSub[i],fields=fields,onlyMPB=True)
formation_time.append(find_formation_time(tree))
final_mass.append(tree['Group_M_Crit200'][0])

Again, an error occurs: ValueError: Index (4294906691) out of range (0-60604).

Dylan Nelson
  • 13 Jun

Hi,

I'm not sure about GroupNsubs.all()==0, I meant more like:

for i in range(start, start+n_halos):
    if GroupNsubs[i] == 0:
        continue
     tree = ...
Yeimy dallana Camargo camargo

Hi Dylan,
The problem now is:
I try obtain the mass of halos ('Group_M_Crit200' and its formation time on Illustris-3) with Sublink (the same code above)

import groupcat as GC
import sublink as SL
import numpy as np
import lhalotree as LH
GroupFirstSub = GC.loadHalos(basePath,135,fields=['GroupFirstSub'])
Halos=GC.loadHalos(basePath,135,fields=['Group_M_Crit200','GroupPos'])

for i in range(start,start+5):
    tree = SL.loadTree(basePath,135,GroupFirstSub[i],fields=fields,onlyMPB=True)
def find_formation_time(sublinktree):
.
.
.
.
.

fields = ['SnapNum','Group_M_Crit200']

start = 0
n_halos = len(Halos['Group_M_Crit200'])
formation_time = []
final_mass = []

for i in range(start,start+n_halos):
    if GroupNsubs[i] != 0:
        tree = SL.loadTree(basePath,135,GroupFirstSub[i],fields=fields,onlyMPB=True)
        formation_time.append(find_formation_time(tree))
        final_mass.append(tree['Group_M_Crit200'][0])   *#*****line of error*****

ERROR:
final_mass = sublinktree['Group_M_Crit200'][0]
TypeError: 'NoneType' object is not subscriptable

This error is with Sublink, but if I try the same code with LHalo tree (it works!).
I print the Halos with mass different off 0 (and GroupNsubs[i] == 0) and I obtain some Halos but are not same Halos with mass different 0 (and GroupNsubs[i] == 0:)
of Gropus_135_x.hdf5 files.
I don't understand whats happen with Sublink,
can you help me please?
Thanks in advance

Dylan Nelson
  • 4 Sep

Hello,

basePath = 'sims.illustris/Illustris-3/output/'
import illustris_python as il

halos = il.groupcat.loadHalos(basePath, 135, fields=['Group_M_Crit200','GroupPos','GroupFirstSub','GroupNsubs'])

 for i in range(0,halos['Group_M_Crit200'].size):
    if halos['GroupNsubs'][i] == 0:
        continue
    tree = il.sublink.loadTree(basePath, 135, halos['GroupFirstSub'][i], fields=['SnapNum','Group_M_Crit200'], onlyMPB=True)
    assert tree['Group_M_Crit200'][0] == halos['Group_M_Crit200'][i]
    print(i,tree['Group_M_Crit200'][0])

produces for halo ID 72285

...
Warning, empty return. Subhalo [89811] at snapNum [135] not in tree.
---------------------------------------------------------------------------

TypeError: 'NoneType' object is not subscriptable
> <ipython-input-15-c12ecdc29fd5>(5)<module>()
      3         continue
      4     tree = il.sublink.loadTree(basePath, 135, halos['GroupFirstSub'][i], fields=['SnapNum','Group_M_Crit200'], onlyMPB=True)
----> 5     assert tree['Group_M_Crit200'][0] == halos['Group_M_Crit200'][i]
      6     print(i,tree['Group_M_Crit200'][0])

this is the expected behavior. Because this subhalo is not in the SubLink tree, the returned tree is None. You should check for this and skip, e.g.

 for i in range(0,halos['Group_M_Crit200'].size):
    if halos['GroupNsubs'][i] == 0:
        continue

    tree = il.sublink.loadTree(basePath, 135, halos['GroupFirstSub'][i], fields=['SnapNum','Group_M_Crit200'], onlyMPB=True)
    if tree is None:
        #final_mass.append(np.nan)
        continue

    assert tree['Group_M_Crit200'][0] == halos['Group_M_Crit200'][i]
    print(i,tree['Group_M_Crit200'][0])
  • Page 1 of 1