I would like to extract part of the merger tree of some subhalos which follow main progenitor branch, but I want to extract, apart of the first progenitor line, every subhalo which merged with first progenitor line. I used full trees (onlyMPB=False option in tree function).I tried to identify subhalos using algorithm: find all subhalos in i-th snapshot which have descendant ID equal to the subhalo ID of the subhalo with most massive history on ( i+1)-th snapshot (which is in first iteration our subhalo in 135. snapshot). It's very simple algorithm, and it works for about 85% of the starting subhalos, but for about 15% of the sample identifying subhalos with same descendant ID breaks and gives me empty sub-dataframe. I can't find fault in my algorithm as much as I try, so I thought maybe to ask if you have any ideas (and if this isn't type of question you usually answer, I sincerely apologize ).
This is algorithm:
gal_max_mass=new_wtree[new_wtree.snap_num==135].shID.values #start value of subhalo with most massive history, whole tree is stored in new_wtree dataframe
mlp=new_wtree[new_wtree.snap_num==135].mlpID.values #main leaf progenitor subhalo ID of the starter subhalo
mincount=new_wtree[new_wtree.shID.values==mlp].snap_num.values #debt of tree I want to go is snapshot of the main leaf progenitor
untree=untree.append(new_wtree[new_wtree.snap_num==135]) #saving part of the tree I need starting with subhalo on 135. snapshot
for i in range(134,mincount-1,-1):
small=new_wtree[(new_wtree.snap_num==i) & (new_wtree.dID.values==gal_max_mass)] #extracting part of the tree: in small dataframe is stored every subhalo on i-th snapshot which have same descendant ID on i+1-th snapshot which is equal to subhalo with the most massive history on i+1-th snapshot
untree=untree.append(small) #storing extracted part of the tree
gal_max_mass=gal_max_mass+1 #subhalo with the most massive history on i-th snapshot (following first progenitor line)
This is the breaking point of one of the subhalos:
As you can see, for the 26-th subhalo we have breaking of the algorithm on the 43-rd snapshot.
If you have any ideas, I would be very greatful.
The merger tree algorithms are generally allowed to "skip" one (or possibly more) snapshots in locating a descendant. This is because a given subhalo may temporarily disappear (i.e. not be detected) by the substructure finder, for a given snapshot.
This might be what you're seeing - i.e., if you can adapt your algorithm to consider, if it doesn't find a match on (i+1), then to consider e.g. (i+2).
Thank you so much, Dylan, that helped tremendously!